-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix Alteration Runner #5142
Merged
Merged
Fix Alteration Runner #5142
Conversation
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
The DefaultAlterationRunner.cs file was refactored to include a workflow middleware pipeline, replacing the previous method of updating workflow state. Comments were added to discuss potential solutions for reusing the same pipeline in the workflow runtime. The CancelActivityHandler was simplified by removing multiple functions and replacing them with a single CancelAsync method.
The commit introduces a new middleware, RunAlterationsMiddleware, that is designed to process workflow alterations. The middleware is in charge of executing alteration handlers and taking care of any required commit actions. The original code for handling alterations in DefaultAlterationRunner has been significantly reduced as it now delegates most of its responsibility to this new middleware.
In the IAlterationPlanManager interface, explanatory comments were added to each method. These include methods for getting a plan by ID, checking if all jobs in the plan have been completed, and completing an alteration plan. The changes made will greatly aid in understanding the purpose and functionality of each method.
The workflow execution pipeline has been refactored to allow for dynamic configuration. The middleware components are now retrievable properties and can be replaced individually. This change provides more extensibility with modifying the pipeline execution and replacing the DefaultActivitySchedulerMiddleware with desired middleware.
Simplified the pipeline alteration process in Elsa.Alterations. Instead of manually handling middleware delegates, added a new extension method, ReplaceTerminal, in WorkflowExecutionMiddlewareExtensions.cs to replace the terminal middleware component. This approach improves code readability and maintenance.
Removed an unnecessary extension class and updated the RunAlterationsMiddleware class to streamline its structure. The handlers are now initialized directly in the constructor, eliminating the need for an additional field. Renamed local variable for better code clarity.
The variable name 'handlers1' has been renamed to 'supportedHandlers' in the RunAlterationsMiddleware.cs file. This change improves code readability and makes it clear that the list contains only the handlers that can handle the given alteration.
The RunAsync function in the RunAlterationsMiddleware class no longer returns a boolean value. The returned 'false' has been replaced with a 'return' statement, and the 'return true' statement has been completely removed. This refactor simplifies the control flow when executing alterations.
MariusVuscanNx
approved these changes
Mar 28, 2024
src/modules/Elsa.Alterations/AlterationHandlers/CancelActivityHandler.cs
Show resolved
Hide resolved
src/modules/Elsa.Alterations/Middleware/Workflows/RunAlterationsMiddleware.cs
Show resolved
Hide resolved
...les/Elsa.Workflows.Core/Pipelines/WorkflowExecution/WorkflowExecutionMiddlewareExtensions.cs
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes the Alteration runner by ensuring it runs through the workflow execution middleware pipeline, which is responsible for persisting activity execution logs, workflow execution logs and persistent variables.
Fixes #5140