elsa-core/src/modules/Elsa.Workflows.Core
Sipke Schoorstra 568cefa629
Optimize Workflow Execution and Messaging (#5243)
* Add conditional index triggers in workflow populator

The trigger indexing in the workflow populator is now conditional. A boolean parameter has been added to the PopulateStoreAsync and AddAsync methods to determine whether to index triggers or not. Additionally, some code cleanups and refactoring have been made for efficient and cleaner code.

* Update method call in DefaultWorkflowRegistry

The method `AddAsync` in `DefaultWorkflowRegistry` has been updated to include a new first parameter set to true. This change aligns with recent modifications to the `AddAsync` method signature, ensuring proper function execution.

* Add new branch triggers to GitHub workflow

The updated GitHub workflow now includes triggers for branches with 'feat/*', 'enh/*', 'perf/*', 'hotfix/*', and 'chore/*' prefixes. This is to ensure that the workflow runs not only for the main, feature, issue, bug, enhancement, patch, and fix branches, but also on all new branches, improving coverage and visibility on all changes.

* Add FindByIdAsync method to WorkflowInstanceManager

This commit introduces a new method, FindByIdAsync, to the WorkflowInstanceManager service. This method fetches a WorkflowInstance using its Id. Also, an interface declaration for the new method is added to IWorkflowInstanceManager.

* Refactor workflow definitions and add indexTriggers parameter

The code for creating workflow definition filters has been refactored for brevity. Additionally, two sets of overloaded methods named `PopulateStoreAsync` and `AddAsync` were added to "IWorkflowDefinitionStorePopulator" and implemented in "DefaultWorkflowDefinitionStorePopulator". These methods allow specifying whether triggers should be indexed.

* Refactor WorkflowDefinitionActivity code

The refactoring is focused on an improved way of finding and passing ActivityDescriptor within WorkflowDefinitionActivity class. Previously, the service provider was passed to the DeclareInputAsVariables and DeclareOutputAsVariables methods, leading to a less readable and harder to maintain code. Now, we pass the ActivityDescriptor directly, making the code easier to understand and modify.

* Update PolymorphicObjectConverter exception handling

Fixes have been applied to the PolymorphicObjectConverter by adding the handling of TargetException. Additionally, the System.Reflection namespace has been included, and the addSetMethod invocation for the HashSet has been streamlined for better readability and performance.

* Remove unnecessary whitespace in PersistWorkflowExecutionLogMiddleware

This change simply removes an unneeded line of whitespace in the corresponding Middleware file. This change is consistent with the goal of maintaining clean and easy-to-read code.

* Refactor MassTransitWorkflowDispatcher and add new methods

Systematic refactor of the MassTransitWorkflowDispatcher class which initially focused on restructuring the DispatchAsync methods. New methods have been added that deal specifically with triggering and bookmarking workflows thus enhancing the readability of the code while also improving its autonomous function. The logging for non-found workflows has been improved as well.

* Update event handler names in Workflow cache eviction

Evicting the cache prior to triggers being indexed fixes a bug where publishing workflow changes would not result in new triggers being found.

* Update Async calls and mark obsolete messages

The commit adjusts calls to AddAsync in DefaultWorkflowRegistry and DispatchAsync in DefaultWorkflowInbox to improve readability. Also, it marks DispatchResumeWorkflows and DispatchTriggerWorkflows in the Elsa.MassTransit.Messages namespace as obsolete, indicating their pending removal in future releases.

* Refactor workflow dispatch code to a separate method

The changes remove duplication and improve readability by extracting the code responsible for dispatching a workflow into a separate method called DispatchWorkflowAsync. This method creates a workflow instance, gets the send endpoint, and then sends the message.

* Refactor exception handling in PolymorphicObjectConverter

This commit simplifies the two separate catch blocks for NotSupportedException and TargetException into a single block using the new 'or' pattern in C#. It also makes minor adjustments to improve the clarity and readability of the code relating to the 'addSetMethod' invocation.

* Update src/modules/Elsa.MassTransit/Services/MassTransitWorkflowDispatcher.cs

Co-authored-by: raymonddenhaan <155616759+raymonddenhaan@users.noreply.github.com>

* Fix an attempt to dispatch bookmark ID instead of workflow instance ID

The MassTransitWorkflowDispatcher.cs file is updated to improve readability and clarity. This includes changing the way bookmark and trigger filter objects are initialized, by breaking down the single-line initialization into multiple lines. Additionally, some logic has been updated in the DispatchBookmarksAsync function for better handling of workflow instance properties and input merging.

* Add logging to SendHttpRequestBase

The SendHttpRequestBase activity in the Elsa.Http module is updated to utilize the ILogger service. This extension enables the capture of HttpRequestException and TaskCanceledException events and logs their warnings, providing insight into potential issues during HTTP request sending.

---------

Co-authored-by: raymonddenhaan <155616759+raymonddenhaan@users.noreply.github.com>
2024-04-19 01:06:52 +02:00
..
Abstractions Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
ActivationValidators Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Activities Replace ScheduleOutcomesAsync with CompleteActivityWithOutcomesAsync (#5212) 2024-04-11 07:37:53 +02:00
Attributes Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Behaviors Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Builders Alterations with Queries (#5032) 2024-03-13 20:34:46 +01:00
Contexts Enhance BulkDispatchWorkflows Activity with Support for Multiple Input Keys and Customizable Input Key (#5182) 2024-04-04 16:07:32 +02:00
Contracts Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Enums LogRecord storage at differents levels (#4911) 2024-03-30 21:22:35 +01:00
Exceptions Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Expressions Add DecimalJsonConverter and update usage 2024-03-14 09:59:22 +01:00
Extensions Enhance BulkDispatchWorkflows Activity with Support for Multiple Input Keys and Customizable Input Key (#5182) 2024-04-04 16:07:32 +02:00
Features Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) 2024-04-15 10:06:27 +02:00
Helpers Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
IncidentStrategies Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Memory Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Middleware Refactor logging to exclude activity state 2024-02-04 10:47:03 +01:00
Models Minor improvements and bug fixes following the 3.1 release (#5168) 2024-04-02 07:41:46 +02:00
Notifications Alterations with Queries (#5032) 2024-03-13 20:34:46 +01:00
Options Feature/cancel dispatched workflows (#5136) 2024-03-27 12:07:55 +01:00
Pipelines Fix Alteration Runner (#5142) 2024-03-29 19:58:35 +01:00
PortResolvers Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) 2023-12-26 18:56:29 +01:00
Serialization Optimize Workflow Execution and Messaging (#5243) 2024-04-19 01:06:52 +02:00
Services Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) 2024-04-15 10:06:27 +02:00
Signals Add input parameter to ScheduleChildActivity signal 2024-01-17 22:32:06 +01:00
State Fix flowchart completion after faulted child activity cancellation (#5145) 2024-03-29 20:38:09 +01:00
UIHints Add UI hints for HTTP endpoint and single line fields 2023-12-28 20:52:04 +01:00
Elsa.Workflows.Core.csproj #5106 Cleanup packages to leverage framework (#5129) 2024-03-29 09:54:44 +01:00
Elsa.Workflows.Core.csproj.DotSettings Restructure models in Workflows.Core 2023-07-09 13:12:13 +02:00
FodyWeavers.xml Prepare projects for packaging 2022-11-03 21:40:23 +01:00
IsExternalInit.cs