-
Notifications
You must be signed in to change notification settings - Fork 49
added experimental support of Flexible Processes #1040
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Dmitrii Tikhomirov <[email protected]>
| for (Activity activity : flexibleProcess.getActivities()) { | ||
| TaskExecutorBuilder<?> builder = | ||
| factory.getTaskExecutor(position, activity.getTask(), definition); | ||
| TaskExecutor<?> executor = builder.build(); | ||
| executors.put(activity, executor); | ||
| } |
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.
This should be done on the builder classs, not as part of every execution.
Take a look to https://github.com/serverlessworkflow/sdk-java/blob/main/impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallFunctionExecutorBuilder.java
| } catch (Exception e) { | ||
| throw new RuntimeException("Error executing activity: " + activity.getName(), e); | ||
| } |
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.
We shoulds not catch exception generically
| executor | ||
| .apply(workflowContext, parentContext, input) | ||
| .join(); // blocking, because we run flexible process one by one |
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.
If we want to run one executor after another, rather that invoking join, we should chain completable future using thenAccept.
| exit = flexibleProcess.getExitCondition().test(input); | ||
| if (exit) { | ||
| break; | ||
| } | ||
| } | ||
| counter--; | ||
| if (counter <= 0) { | ||
| break; | ||
| } | ||
| } |
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.
I think the loop termination condition should be revised, why counter is not part of the while?
| .filter(activity -> activity.getKey().isRepeatable() || !activity.getKey().isExecuted()) | ||
| .filter(e -> e.getKey().getEntryCondition().test(input)) |
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.
These two filters can be merge into one
| return this; | ||
| } | ||
|
|
||
| public FlexibleProcessBuilder maxAttempts(Integer maxAttempts) { |
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.
Why not using a int parameter, so you do not have to care about null?
| flexibleProcess.exitCondition = | ||
| Objects.requireNonNull(this.exitCondition, "Exit condition must be provided"); | ||
| flexibleProcess.activities = | ||
| Objects.requireNonNull(this.activities, "Activities must be provided"); |
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.
If exitCondition and activities are mandatory, then, they should be provided when creating the builder rather than using with methods.
Builder pattern should be used when you have few mandatory parameter and a lot of optionals (or defaults)
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it:
Special notes for reviewers:
Additional information (if needed):