elsa-core/src/modules
Sipke Schoorstra b6689c7e2b
Fix Race Condition in WorkflowDefinitionActivity (#5315)
* Refactor hash method in Hasher.cs

The Hash method in the Hasher.cs file has been refactored to use more efficient code. Instead of creating a SHA256 instance, it directly hashes the data using SHA256.HashData. As a result, the private Hash method and its usage, which only has relevance to the previous approach, have been removed.

* Replace GetHashCode with SHA256 for script caching

Two unused namespaces, Esprima and Esprima.Ast, have been removed, and two new ones, System.Security.Cryptography and System.Text, have been added. These changes in Elsa.JavaScript's JintJavaScriptEvaluator file were made to replace the basic GetHashCode method, which was used earlier to generate a cache key for JavaScript scripts, with SHA256 hash function to ensure uniqueness and avoid possible hash collisions. This greatly increases the reliability of the caching mechanism.

* Set HTTP client timeout in WorkflowServer

The client timeout in WorkflowServer has been set to 1 minute for `ResrService` and `client` methods. This was done to manage long running requests and prevent timeouts.

* Refactor code and add validation in ScheduleActivityAsync methods

An unnecessary line of code in the ScheduleActivityAsync method under the ActivityExecutionContext file has been removed to simplify the function. Meanwhile, validation has been added to ensure that specified activities are part of the workflow. This improves code clarity and prevents potential errors caused by incorrect activity scheduling.

* Refactor ActivityVisitor to use ActivityVisitorContext

The ActivityVisitor class in Elsa.Workflows.Core was refactored to use an ActivityVisitorContext class. The introduction of this context class replaced the multiple hashsets that were used within function signatures, consolidating them into a single object and reducing function complexity. This change improves readability and code organization.

* Refactor WorkflowDefinitionActivity to use WorkflowGraph

Adjusted the WorkflowDefinitionActivity class in the Elsa.Workflows.Management module. The changes include migration from using Workflow to WorkflowGraph objects and condensing code blocks for clearer readability. Additionally, a new 'IsInitialized' field is added to eliminate potential race conditions during the graph construction process.

* Add activity validation to WorkflowExecutionContext

A check has been implemented in the WorkflowExecutionContextExtensions to validate that a specified activity is part of the workflow. This prevents incorrect activity references when scheduling tasks in the workflow.

* Refactor to use WorkflowGraph instead of Workflow

The codebase has been refactored to utilize the WorkflowGraph instead of the Workflow while running and manipulating workflows. Additional changes include restructuring WorkflowRunner and WorkflowDefinitionService classes, introducing WorkflowGraphBuilder usage, and mapping updates in WorkflowDefinitionMapper. The WorkflowHost, WorkflowDispatcher, and WorkflowExecutionContext have also been updated accordingly.

* Add WorkflowGraph and related services

This commit introduces the IWorkflowGraphBuilder interface, the WorkflowGraph model, and an implementation of the interface in the WorkflowGraphBuilder class. The purpose of these additions is to establish the building and structure of a workflow graph. The WorkflowGraph model also includes activity node handling and hashing capabilities.

* Add tests to ensure exception when scheduling an activity not part of workflow

Several unit tests were written to ensure that the right behavior is exhibited when scheduling an activity that is not part of the workflow. An exception is expected to be thrown in this case. Additionally, new service definitions, workflow definitions and workflow queries were added for more comprehensive testing.

* Update WorkflowGraph class and add comment descriptions

This commit updates the WorkflowGraph class by extending its descriptions and implementing an explicit mention to the Workflow reference. Additionally, more attribute descriptions have been added to increase code readability and comprehension.

* Removed unnecessary brackets

* Remove unused services from workflow management

This commit deletes "ExpressionDescriptorRegistryPopulator.cs" and "ScopedWorkflowDefinitionLookup.cs" files from Elsa.Workflows.Management.Services. These files, containing obsolete services, are no longer used in the workflow management process. The services' registration has been removed as well from "WorkflowManagementFeature.cs".

* Remove TestWorkflowDefinitionService.cs from component tests

A file, TestWorkflowDefinitionService.cs, was removed under Elsa.Workflows.ComponentTests. This is part of the improvement process where inefficient or unnecessary test files are cleaned up.

* Add comments to WorkflowDefinitionActivityTests

This commit adds explanatory comments to the WorkflowDefinitionActivityTests file. The comments provide information about the purpose of these tests and a reference to a related issue in the project's Github repository.

* Updated duplicate and missing package references

---------

Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
2024-05-01 14:53:37 +02:00
..
Elsa.Alterations Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.Alterations.Core Refactor serializer options usage and enhance caching in workflow serialization (#5275) 2024-04-25 11:42:48 +02:00
Elsa.Alterations.MassTransit Add alteration notifications and management (#5097) 2024-03-20 10:58:59 +01:00
Elsa.AzureServiceBus Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.Caching Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) 2024-04-15 10:06:27 +02:00
Elsa.Caching.Distributed Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) 2024-04-15 10:06:27 +02:00
Elsa.Caching.Distributed.MassTransit Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) 2024-04-15 10:06:27 +02:00
Elsa.Common Refactor serializer options usage and enhance caching in workflow serialization (#5275) 2024-04-25 11:42:48 +02:00
Elsa.CSharp Add 'From' methods and mark 'Get' methods as obsolete 2024-02-14 11:39:47 +01:00
Elsa.Dapper Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.Dapper.Migrations Alterations with Queries (#5032) 2024-03-13 20:34:46 +01:00
Elsa.Dsl Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.Elasticsearch Update packages (#5286) 2024-04-26 20:07:34 +02:00
Elsa.Email Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.EntityFrameworkCore fix: Fix the property SerializedValue in RuntimeDbContext for Oracle (#5231) 2024-04-26 15:45:14 +02:00
Elsa.EntityFrameworkCore.Common Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.EntityFrameworkCore.MySql Regenerate V3.1 EF Core migrations with custom runtime schema support (#5155) 2024-03-29 21:15:23 +01:00
Elsa.EntityFrameworkCore.PostgreSql Regenerate V3.1 EF Core migrations with custom runtime schema support (#5155) 2024-03-29 21:15:23 +01:00
Elsa.EntityFrameworkCore.Sqlite Regenerate V3.1 EF Core migrations with custom runtime schema support (#5155) 2024-03-29 21:15:23 +01:00
Elsa.EntityFrameworkCore.SqlServer Regenerate V3.1 EF Core migrations with custom runtime schema support (#5155) 2024-03-29 21:15:23 +01:00
Elsa.Environments Remove version number from Elsa.Environments project file 2024-02-12 19:11:18 +01:00
Elsa.Expressions Refactor serializer options usage and enhance caching in workflow serialization (#5275) 2024-04-25 11:42:48 +02:00
Elsa.FileStorage #5107 Add framework reference & package removal (#5128) 2024-03-28 21:35:47 +01:00
Elsa.Hangfire Implement dispatch channels (#4949) 2024-02-16 10:56:30 +01:00
Elsa.Hosting.Management Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.Http Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.Identity Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.JavaScript Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.KeyValues Refactor code and update comments for better readability 2024-02-20 11:26:52 +01:00
Elsa.Labels Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.Liquid Rename FluidFiltersDelegate to ConfigureFilters 2024-04-26 15:52:38 +02:00
Elsa.MassTransit Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.MassTransit.AzureServiceBus Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.MassTransit.RabbitMq Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.MongoDb Add caching to workflow runtime and workflow management stores (#5174) 2024-04-10 11:51:40 +02:00
Elsa.ProtoActor Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.ProtoActor.Cluster.AzureContainerApps Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.Python Add Component Testing Framework (#5261) 2024-04-26 15:49:14 +02:00
Elsa.Quartz Update packages (#5286) 2024-04-26 20:07:34 +02:00
Elsa.Quartz.EntityFrameworkCore.MySql update AppAny package version and fix MySql and SqlServer migration for Quartz (#4921) 2024-02-09 19:38:43 +01:00
Elsa.Quartz.EntityFrameworkCore.PostgreSql update AppAny package version and fix MySql and SqlServer migration for Quartz (#4921) 2024-02-09 19:38:43 +01:00
Elsa.Quartz.EntityFrameworkCore.Sqlite update AppAny package version and fix MySql and SqlServer migration for Quartz (#4921) 2024-02-09 19:38:43 +01:00
Elsa.Quartz.EntityFrameworkCore.SqlServer update AppAny package version and fix MySql and SqlServer migration for Quartz (#4921) 2024-02-09 19:38:43 +01:00
Elsa.SasTokens Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.Scheduling Add logging to ScheduledCronTask constructor and setup (#5122) 2024-03-21 19:46:52 +01:00
Elsa.Telnyx #5106 Cleanup packages to leverage framework (#5129) 2024-03-29 09:54:44 +01:00
Elsa.Webhooks Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
Elsa.WorkflowContexts replace configureawait.props and frameworks.props with Directory.Build.props 2024-01-26 19:04:39 +02:00
Elsa.WorkflowProviders.BlobStorage Add Component Testing Framework (#5261) 2024-04-26 15:49:14 +02:00
Elsa.Workflows.Api Add Component Testing Framework (#5261) 2024-04-26 15:49:14 +02:00
Elsa.Workflows.Core Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.Workflows.Management Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00
Elsa.Workflows.Runtime Fix Race Condition in WorkflowDefinitionActivity (#5315) 2024-05-01 14:53:37 +02:00