generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support post deployment actions - update (#3193)
* support post deployment actions - update * update hosted service grammar
- Loading branch information
1 parent
88f4288
commit d91790f
Showing
39 changed files
with
864 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
legend-engine-xts-functionActivator/legend-engine-xt-functionActivator-compiler/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2020 Goldman Sachs | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xts-functionActivator</artifactId> | ||
<version>4.63.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>legend-engine-xt-functionActivator-compiler</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Legend Engine - XT - Function Activator - Compiler</name> | ||
|
||
|
||
<dependencies> | ||
<!--ENGINE--> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-language-pure-compiler</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-shared-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-protocol-pure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xt-functionActivator-pure</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.finos.legend.engine</groupId> | ||
<artifactId>legend-engine-xt-functionActivator-protocol</artifactId> | ||
</dependency> | ||
<!--ENGINE--> | ||
|
||
<!--ECLIPSE--> | ||
<dependency> | ||
<groupId>org.eclipse.collections</groupId> | ||
<artifactId>eclipse-collections</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.collections</groupId> | ||
<artifactId>eclipse-collections-api</artifactId> | ||
</dependency> | ||
<!--ECLIPSE--> | ||
</dependencies> | ||
</project> |
35 changes: 35 additions & 0 deletions
35
...ionActivator/compiler/toPureGraph/postDeployment/HelperPostDeploymentCompilerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.language.functionActivator.compiler.toPureGraph.postDeployment; | ||
|
||
import org.eclipse.collections.api.list.MutableList; | ||
import org.eclipse.collections.impl.utility.ListIterate; | ||
import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; | ||
import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; | ||
import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; | ||
|
||
import java.util.List; | ||
|
||
public class HelperPostDeploymentCompilerBuilder | ||
{ | ||
public static MutableList<Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction> resolveDeploymentAction(List<PostDeploymentAction> actions, CompileContext context) | ||
{ | ||
List<IPostDeploymentCompilerExtension> extensions = IPostDeploymentCompilerExtension.getExtensions(); | ||
return ListIterate.collect(actions, action -> IPostDeploymentCompilerExtension.process( | ||
action, | ||
ListIterate.flatCollect(extensions, IPostDeploymentCompilerExtension::getExtraPostDeploymentActionProcessors), | ||
context)); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...nctionActivator/compiler/toPureGraph/postDeployment/IPostDeploymentCompilerExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.language.functionActivator.compiler.toPureGraph.postDeployment; | ||
|
||
import org.eclipse.collections.api.block.function.Function2; | ||
import org.eclipse.collections.api.factory.Lists; | ||
import org.eclipse.collections.impl.list.mutable.FastList; | ||
import org.eclipse.collections.impl.utility.ListIterate; | ||
import org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext; | ||
import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; | ||
import org.finos.legend.engine.protocol.functionActivator.metamodel.PostDeploymentAction; | ||
import org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType; | ||
import org.finos.legend.engine.shared.core.operational.errorManagement.EngineException; | ||
import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.ServiceLoader; | ||
|
||
public interface IPostDeploymentCompilerExtension extends CompilerExtension | ||
{ | ||
static List<IPostDeploymentCompilerExtension> getExtensions() | ||
{ | ||
return Lists.mutable.withAll(ServiceLoader.load(IPostDeploymentCompilerExtension.class)); | ||
} | ||
|
||
static Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction process(PostDeploymentAction postDeploymentAction, List<Function2<PostDeploymentAction, CompileContext, Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction>> processors, CompileContext context) | ||
{ | ||
return process(postDeploymentAction, processors, context, "Post Deployment Compiler Extension"); | ||
} | ||
|
||
static <T, U> U process(T item, List<Function2<T, CompileContext, U>> processors, CompileContext context, String type) | ||
{ | ||
return ListIterate | ||
.collect(processors, processor -> processor.value(item, context)) | ||
.select(Objects::nonNull) | ||
.getFirstOptional() | ||
.orElseThrow(() -> new EngineException("Unsupported " + type + " type '" + item.getClass() + "'", EngineErrorType.COMPILATION)); | ||
} | ||
|
||
default List<Function2<PostDeploymentAction, CompileContext, Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction>> getExtraPostDeploymentActionProcessors() | ||
{ | ||
return FastList.newList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
.../org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentActionLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.functionActivator.postDeployment; | ||
|
||
import org.eclipse.collections.api.list.MutableList; | ||
import org.eclipse.collections.impl.factory.Lists; | ||
import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; | ||
import org.finos.legend.pure.generated.Root_meta_external_function_activator_FunctionActivator; | ||
|
||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
public class PostDeploymentActionLoader | ||
{ | ||
private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(PostDeploymentContract.class); | ||
private static final AtomicReference<MutableList<PostDeploymentContract>> INSTANCE = new AtomicReference<>(); | ||
|
||
public static MutableList<PostDeploymentContract> extensions() | ||
{ | ||
return INSTANCE.updateAndGet(existing -> | ||
{ | ||
if (existing == null) | ||
{ | ||
MutableList<PostDeploymentContract> extensions = Lists.mutable.empty(); | ||
for (PostDeploymentContract extension : ServiceLoader.load(PostDeploymentContract.class)) | ||
{ | ||
try | ||
{ | ||
extensions.add(extension); | ||
} | ||
catch (Throwable throwable) | ||
{ | ||
LOGGER.error("Failed to load execution extension '" + extension.getClass().getSimpleName() + "'"); | ||
} | ||
} | ||
return extensions; | ||
} | ||
return existing; | ||
}); | ||
} | ||
|
||
public static List<ActionContent> generateActions(Root_meta_external_function_activator_FunctionActivator activator) | ||
{ | ||
List<ActionContent> actionsContent = Lists.mutable.empty(); | ||
extensions().forEach(e -> | ||
{ | ||
actionsContent.addAll(e.generate(activator._actions())); | ||
}); | ||
|
||
return actionsContent; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.functionActivator.postDeployment; | ||
|
||
import org.eclipse.collections.api.RichIterable; | ||
import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorArtifact; | ||
import org.finos.legend.engine.protocol.functionActivator.deployment.FunctionActivatorDeploymentConfiguration; | ||
import org.finos.legend.engine.protocol.functionActivator.deployment.PostDeploymentActionResult; | ||
import org.finos.legend.engine.protocol.functionActivator.postDeployment.ActionContent; | ||
import org.finos.legend.engine.shared.core.identity.Identity; | ||
import org.finos.legend.pure.generated.Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction; | ||
|
||
import java.util.List; | ||
|
||
public interface PostDeploymentContract | ||
{ | ||
List<ActionContent> generate(RichIterable<? extends Root_meta_external_function_activator_postDeploymentAction_PostDeploymentAction> actions); | ||
|
||
List<PostDeploymentActionResult> processAction(Identity identity, FunctionActivatorArtifact artifact); | ||
} |
Oops, something went wrong.