generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for post deployment actions #3176
Draft
Yasirmod17
wants to merge
1
commit into
finos:master
Choose a base branch
from
goldmansachs:review-postDeploymentAction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.62.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
66 changes: 66 additions & 0 deletions
66
...n/java/org/finos/legend/engine/functionActivator/postDeployment/PostDeploymentLoader.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,66 @@ | ||
// 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.engine.protocol.functionActivator.postDeployment.PostDeploymentContract; | ||
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 PostDeploymentLoader | ||
{ | ||
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to keep the naming consistent: This should be PostDeploymentActionLoader