The `DefaultTriggerScheduler` received a significant refactoring, with the injection of the `ISystemClock` service and a modification of several method calls. Additionally, a check is included to avoid scheduling `StartAt` triggers if their execution time is in the past. For these triggers, an information message is logged and scheduling is skipped.
This commit introduces a validation check in the GenerateWorkflowInputAccessors handler before trying to get the workflow. This prevents any potential issues if the workflow execution context is not available or retrievable. The code flow now first attempts to get the workflow execution context and if it's not available, it will return a completed task.
The schema setup in ElsaDbContextBase has been refactored for better readability and more efficient coding. The '_schema' private variable has been removed, and the 'Schema' property is now set directly within the constructor. This eliminates the need for extra code to handle the '_schema' variable, simplifying the overall approach. Additionally, minor formatting adjustments were made for better consistency in the code block.
The MongoUserStore class was initially defined as an abstract class in the UserStore.cs file. This commit updates it to be a regular, non-abstract class to allow instantiation. This is particularly beneficial in cases where there is a need to create an instance of MongoUserStore.
This commit removes a number of unnecessary properties from the `WorkflowDefinitionModel` and `WorkflowDefinitionSummary` classes. These changes help simplify the models and focus on the core properties required for workflow definitions. Specific properties removed include `Id`, `CreatedAt`, `Version`, and status flags such as `IsLatest` and `IsPublished`.
* Implemented global readonly and workflow readonly
* Fixed bug of unfilled versions
* Fixed failing test
* Updated pipeline
* Revert
* Pushed fixes based on the PR comments and fixed history bug
* Implemented changes based on PR comments
* Fixed issue in caused by AuthorizationHandler not being able to receive null resources
* Remove unused Google.Protobuf dependency in Program.cs
An unused Protobuf library import was found in Program.cs file. In order to clean up the code and improve readability, this import statement has been removed. No other changes have been made.
* Refactor code to reduce redundancy and improve readability
Optimize code by removing unnecessary constructor assignments and simplify function calls. The simplification is mainly achieved by directly passing the required services as constructor parameters instead of assigning them to private fields first. This results in a more readable and less redundant code.
---------
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
* Add distributed locking to MassTransitWorkflowDispatcher
This commit introduces a distributed lock to the MassTransitWorkflowDispatcher to prevent concurrent updates to the workflow instance. The lock is acquired before any interaction with the workflow instance and is released after the update operation is complete.
* Refactor MassTransitWorkflowDispatcher for simplified code
Removed unnecessary code in the MassTransitWorkflowDispatcher.cs class, previously used to handle input and properties. Refactored to directly include input and properties in the DispatchWorkflowInstanceRequest object, increasing efficiency and readability.
* Remove unused IDistributedLockProvider dependency
The IDistributedLockProvider dependency in the constructor of MassTransitWorkflowDispatcher class was removed because it was identified as unnecessary in this context. This results in less complicated code and improved maintainability.
* Add bulk dispatch workflows unit tests
Added a new file `BulkDispatchWorkflowsTests.cs` that contains tests for Bulk Dispatch Workflows. Also, two new workflow files `EmployeeGreetingWorkflow.cs` and `GreetEmployeesWorkflow.cs` were added to define workflows used in the unit tests. This will help ensure the Bulk Dispatch Workflows feature is working as expected.
The configuration for DistributedLockProvider has been changed from the root level to under the Runtime section in appsettings.json. The corresponding call to get this value in code was also updated to reflect this change.
This commit introduces a distributed lock to the MassTransitWorkflowDispatcher to prevent concurrent updates to the workflow instance. The lock is acquired before any interaction with the workflow instance and is released after the update operation is complete.
* Add error handling with fault categories and codes
The code now includes error handling through the introduction of fault categories and codes. New files containing constants for fault categories and codes have been added for different modules. FaultException has also been updated to include these properties. Changes are evident in various files where FaultException is thrown for error handling.
* Add DotSettings file for Elsa.Alterations module
A new DotSettings file is added for the Elsa.Alterations module. This includes configuration for namespace folders to be skipped during CodeInspection.
* Renamed "DefaultFaultKinds" to "DefaultFaultTypes" and updated usages
This commit renames the class "DefaultFaultKinds" to "DefaultFaultTypes" and updates all its references across the project files. The change is made keeping the more accurate naming context i.e., 'Types' suits better in the thrown exception scenarios.
* Added failing unit test
* Added fix for error 'Instance property 'Id' is not defined for type 'Elsa.KeyValues.Entities.SerializedKeyValuePair' (Parameter 'propertyName')'
* Added Bson class map for SerializedKeyValuePair. Ignoring _id field mapping.
---------
Co-authored-by: Stephan Melzer <s.melzer@mera-petfood.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
The class CachingBookmarkStore was removed from the project as it is no longer being used. The reference to this class in CachingWorkflowRuntimeFeature.cs was also eliminated as part of this change.
* Update property retrieval in FlowJoin activity
This commit modifies the way flowScope is retrieved within the FlowJoin activity in Elsa.Workflows.Core. Instead of directly calling GetProperty, a fallback value is now being provided in case the desired property is not found. This reduces the risk of null reference exceptions.
* Add FlowJoins component tests
Two new files have been created to facilitate component testing for the FlowJoins scenarios in the Elsa Workflows. The `Tests.cs` file includes a Fact to validate the successful execution of a Flowchart with a single FlowJoin. The `Workflows.cs` file defines a single join workflow for these tests.
* Add RabbitMq support to ComponentTests
Added RabbitMq to Infrastructure.cs for component testing, allowing both RabbitMqContainer and DbContainer to start and stop asynchronously. Also, adjusted WorkflowServer.cs to configure RabbitMq mass transit alongside existing PostgreSql support, aiming to improve testing robustness and coverage.
* Refactor placement of RemoveOrphanedSubscriptions service
Move the implementation of AddNotificationHandler<RemoveOrphanedSubscriptions>() from the notifier block to the singleton section in AzureServiceBusFeature.cs. This will help keep all service registration related to notifications in one place.
* Increase prefetch count
* 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>
* bumped versions to fix dependency vulnerabilities (#5256)
* Update patch version in GitHub workflows
The version number used in the branch checking step of the GitHub workflows has been updated. Instead of scanning for the branch containing the patch version 3.1.2, it now scans for the branch that contains version 3.1.3. This change is aligned with the updated product version.
* Update git branch grep pattern in workflow file
The git grep pattern has been corrected to properly identify tagged versions in the GitHub Actions workflow. The correction ensures that the workflow script fetches the right branches as per the release tag instead of patch.
* Update grep command in packages workflow
The grep command used in the 'packages.yml' GitHub workflow was previously looking for the exact 'refs/tags/3.1.3' string. This commit simplifies the command by making it only look for '3.1.3'. This adjustment will streamline the process and potentially prevent issues with branch recognition.
* Update package versions and refactor code for Elasticsearch and JavaScript modules
Updated versions of numerous packages in the Directory.Packages.props file to their latest stable releases. This includes updates to Elasticsearch, JavaScript, and MongoDB packages among others. Additionally, refactored parts of the code in the WorkflowInstanceConfiguration and JintJavaScriptEvaluator within the Elasticsearch and JavaScript modules, respectively, to improve index management and script preparation. The WorkflowInstanceStore also saw a minor adjustment.
---------
Co-authored-by: Steve Taylor <stevetayloruk@users.noreply.github.com>
This commit updates the name of the `FluidFiltersDelegate` method to `ConfigureFilters` across the Elsa.Liquid modules. The name change better represents the method's functionality and aligns with the common practice of using accurate naming for describing methods' actions in a more straightforward way.
* Add application component tests
Multiple new test files were added to deliver application component tests. This move improves testing by adding integration tests that cover overall system behavior and checking end-to-end actions. Ensuring the system functions correctly as a whole. In the process, updating some package versions to maintain compatibility.
* Add RefitSettings helper and revise API client service configuration
The commit introduces a 'RefitSettingsHelper' for Elsa API client and revises the way the API client services are configured. It also makes improvements to the WorkflowServerTestWebAppFactory for component testing. Some endpoint contracts related to workflow execution are also updated to have optional parameters.
* Remove old tests and add new workflow tests
This commit removes old, unnecessary tests and incorporates new workflow tests. It also improves the Elsa API client JSON serializer and adds a helper for HttpResponseMessage. Lastly, the commit introduces changes to properly configure the test logging and to manage application settings.
* Add HttpHelloWorld workflow tests
A new component test scenario, HttpHelloWorldTests, has been created for testing an HttpHelloWorld workflow. This involves asserting if a workflow responds correctly with "Hello World". Furthermore, an HTTP workflow client has been introduced in the WorkflowServerTestWebAppFactory class to provide a base address for workflow API calls.
* Add new test file and update workflow execution tests
This change adds a new test file "fork-1.json" to the Elsa.Workflows.Api.ComponentTests project. Also, updates were made throughout the tests to replace the WorkflowServerTestWebAppFactory with a fixture, allowing the tests to run in parallel. Lastly, unnecessary warning suppression was removed from the Elsa.Workflows.Core extension method.
* Add filter for .json and .elsa files in BlobStorageWorkflowProvider
This change adds a BrowseFilter in the BlobStorageWorkflowProvider options. This filter checks for files that end with .json or .elsa and includes only these files when browsing through the blob storage. This filter helps prioritize specific workflow file types.
* Rename WorkflowServerTestWebAppFactoryFixture and update usage
The old class name "WorkflowServerTestWebAppFactoryFixture" has been replaced with the more accurate "WorkflowServerWebAppFactoryFixture". All references to the previous name in other classes were also updated accordingly. In addition, the directory key in the method "CreateConvoyOptionsBuilder" has been updated from "Workflows" to "Scenarios".
* Update test fixture in workflow tests
The commit updates the test fixture in two test classes: HttpHelloWorldTests and HelloWorldTests. The former test fixture, WorkflowServerTestWebAppFactoryFixture, was replaced by WorkflowServerWebAppFactoryFixture to accurately match the testing needs.
* Update .csproj file paths and reorganize tests
The commit modifies the file paths for several test scenario files in the Elsa.Workflows.Api.ComponentTests.csproj, reflecting a reorganization of the tests. Previously static paths have been updated to new paths under 'Scenarios'. Additionally, two new test files related to 'LogPersistenceModes' have been included in the project.
* Add tests for log persistence modes
This commit introduces two new test scenarios for logging persistence modes and includes a related test called 'HelloWorldWorkflow'. These tests cover scenarios where certain workflow inputs should be stored and others shouldn't, thereby testing the log persistence feature. This ensures that the logging behavior respects the specified persistence mode.
* Add log persistence tests and update LogPersistenceMode enum
The commit contains the addition of new log persistence tests for verifying correctness of log persistence behavior. Furthermore, the LogPersistenceMode enum has been updated, replacing 'Default' with 'Inherit'. This change makes the mode's purpose clearer. Lastly, new test scenarios and test data files were added for more comprehensive testing.
* Remove obsolete component tests and support files
The files removed are no longer necessary for the current state of the application. They include various component tests and their related support files within the Elsa.Workflows.Api.ComponentTests project. By removing these, the project structure is cleaner and only contains relevant tests.
* Add dispatch workflow scenario tests and necessary helper classes
This commit includes two new tests for dispatching workflows, along with the creation of new 'ChildWorkflow' and 'DispatchAndWaitWorkflow' classes. Auxiliary helpers and services have been added to aid in managing workflow events and signals for these tests. The 'ComponentTest' has also been upgraded to support disposal handling.
* Remove ITestOutputHelper dependency from test classes
Removed the dependency on ITestOutputHelper in multiple test classes across various workflow scenarios. This change simplifies the test class constructors by reducing the number of required dependencies, contributing to cleaner and leaner code.
* Add 'Hello World' scenario to WorkflowCompletion tests
The 'Hello World' scenario was moved into WorkflowCompletion tests, along with changes in workflow definition identifiers. As part of these changes, the 'hello-world.json' file was updated; a new file under the same name was created in the WorkflowCompletion area and the workflow identifiers in basic and workflow completion tests were updated accordingly. Additionally, 'fork-1.json' has been renamed to 'fork.json'.
* Add support for cluster hosting tests
This commit introduces a suite of integration tests designed to validate the behaviour of hosting multiple instances of Elsa in a clustered environment. These tests simulate a typical clustered hosting scenario by using 'App', 'Cluster', and 'Infrastructure' objects to emulate different instances of the Elsa workflow engine running on separate servers. Name changes were made to certain classes and methods to reflect their new scopes and roles within the testing environment.
* Add performance tests and improve component tests
Added a new performance tests project scaffold, complete with its own project file, build properties file, and a dummy test. Updated component tests to improve multi-pod testing, primarily through the addition of additional service scopes and asserting activity registry synchronization. These changes also required updates to existing project and props files as well as the solution file.
* Update ActivityRegistrySyncTests and Infrastructure
Added a reference to Services in ActivityRegistrySyncTests and removed unnecessary whitespace in both files. The test component Elsa.Workflows has been modified to import newly added services, ensuring all tests are running with the expected resources and services.
* Fix comment
* Add NOOP implementations for stores
* Update PostgreSQL image and adjust test timings
The PostgreSQL image used for testing has been updated to the latest version from 13.3-alpine. Timeouts in ISignalManager and DispatchWorkflowsTests have been reduced for efficiency. A delay in the ChildWorkflow has also been decreased. Additionally, an 'ImportWorkflowActivity' test in ActivityRegistrySyncTests has been marked as not yet implemented.
* Refactor serializer options usage and enhance caching in workflow serialization
This update refactors multiple classes dealing with JSON serialization. The usage of serializer options now includes a caching mechanism to avoid unnecessary recomputation. 'CreateOptions' method is replaced by a 'GetOptions' method that considers cached options. Classes are adjusted to clone options when necessary, ensuring a fresh and accurate context each time.
* Refactor serializer options in workflow serialization
This commit refactors how options are handled for JSON serializers in Elsa's workflow modules. JSON serializer options are now handled more efficiently, by directly using the provided options in `JsonIgnoreCompositeRootConverter` and setting up internal serializer options in `ObjectConverter`. Unnecessary methods related to the cloning of serializer options have been removed.
* Add caching for scripts in Jint JavaScript engine
A new feature has been implemented to cache the scripts in the Jint JavaScript engine for performance improvement. A new property, "ScriptCacheTimeout", has been introduced to determine the script caching duration. The scripts will be recompiled after the specified duration has elapsed. If the value is null, the scripts will be cached indefinitely. Also, dependencies and changes have been made in the relevant classes to support this feature.
* Set default value for ScriptCacheTimeout in JintOptions
The change sets a default value for the ScriptCacheTimeout property in the JintOptions.cs file. Previously, ScriptCacheTimeout did not have a default value. Now, ScriptCacheTimeout defaults to one day if no other value is specified.
* Refactor JsonSerializerOptions creation in JintJavaScriptEvaluator
This change breaks down the creation of JsonSerializerOptions into several lines to improve readability. It also keeps JavaScriptEncoder as the encoder but presents the creation of the object in a more explicit manner.
The code changes involve updating the activity execution mapper in Elsa.Workflows.Runtime. The updated logic now consider the closest ancestor in the workflow hierarchy when determining the workflow persistence property. This provides a more accurate representation of the workflow's state, rather than relying solely on the workflow execution context.
Fixes#5252
* 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>
* Replace IServiceScopeFactory with IServiceProvider in WorkflowRunner
Unused dependencies were removed from the workflow runner service. The IServiceScopeFactory was replaced with IServiceProvider to better handle the creation and deletion of service scopes, resulting in cleaner code with less manual scope management. Microsoft.Extensions.DependencyInjection and System.Diagnostics.CodeAnalysis were removed as they were no longer necessary.
* Refactor WorkflowDefinitionActivity to use WorkflowDefinitionService
The WorkflowDefinitionActivity class has been refactored to make use of the WorkflowDefinitionService instead of the WorkflowDefinitionStore. This fixes#5222 by ensuring the same activity instances are used in the graph model of the workflow execution context.
* Add workflow filtering and caching functionality
Added methods to `WorkflowDefinitionService` to find workflow definitions and workflows using filter criteria. A key generation method for caching filtered workflows was also added to `WorkflowDefinitionCacheManager`. The implementation includes generating a hash of the filter parameters and using this hash as a cache key, providing efficient caching functionality for filtered searches.
* Refactor TriggerIndexer to handle only ITrigger activities
The code in TriggerIndexer has been refactored to deal specifically with ITrigger activities, streamlining its behavior. Removed code related to handling non-ITrigger activities and simplified the workflow creation process. The extraction of "startable" nodes now directly filters and casts to ITrigger, reducing complexity and increasing readability.
* Update caching service to support filter-based search
The CachingWorkflowDefinitionService has been updated to support workflow definition and workflow search based on filter criteria. The update also includes change of class scope from public to internal. Further, it resolves the missing reference by switching from Elsa.Caching.Contracts to Elsa.Caching.
* Optimize Elsa project imports and use explicit cache variable names
This commit removes superfluous import references, relocates the 'IChangeTokenSignaler' contract into the 'Elsa.Caching' namespace, and replaces ambiguous 'cache' variable names with more explicit 'memoryCache' across several files. Additionally, new package references have been added and access modifiers have been changed to improve encapsulation. Cleanup enhances readability and maintainability of the codebase.
* Add .DotSettings file to Elsa.Caching module
A new .DotSettings file has been added to the Elsa.Caching module. This file is used for namespace configuration, specifically to skip the "contracts" folder in code inspections.
* Update workflow interfaces to support filter queries
The update extends `IWorkflowDefinitionCacheManager` and `IWorkflowDefinitionService` interfaces. Functions are added to allow creating filter cache keys and finding workflow definitions and workflows using a new `WorkflowDefinitionFilter`. This enhances querying flexibility by enabling filtered searches.
* Add WorkflowDefinitionVersionId to WorkflowTriggerEqualityComparer
A new property, WorkflowDefinitionVersionId, has been added to the object being serialized in WorkflowTriggerEqualityComparer. This change allows for a more accurate comparison between workflow triggers, considering not just the workflow definition ID but also its version.
* Update service registration types in WorkflowsFeature
Changed the registration type for both IHasher and IBookmarkHasher services from Scoped to Singleton in the workflows feature configuration. This alteration aims to improve application performance and manage service lifetimes more efficiently.
* Remove Open.Linq.AsyncExtensions dependency
The Open.Linq.AsyncExtensions package reference was removed across the project. The usage within the CachingWorkflowDefinitionStore was updated accordingly to maintain functionality.
* Move System.Linq.Dynamic.Core package reference
The System.Linq.Dynamic.Core package reference was moved from the Directory.Build.props file to the Elsa.Workflows.Management.csproj file. This change reflects the specific dependency of the Elsa.Workflows.Management module on System.Linq.Dynamic.Core, without impacting other modules.
* Implement caching for HTTP workflows
This update introduces caching mechanisms for HTTP workflows, which significantly improves their performance. The changes involve creating a `CacheManager` and `CachingHttpWorkflowLookupService`, and modifying some existing components to use the new caching mechanism. Additionally, the `HttpWorkflowsCacheManager` was renamed to `HttpWorkflowsCacheInvalidationManager` to better reflect its role.
* Refactor cache management across modules
This commit refactor the cache management across various modules. The 'ICacheManager' interface now includes methods for triggering and getting change tokens, and the 'HttpWorkflowsCacheInvalidationManager' has been renamed to 'HttpWorkflowsCacheManager'. The caching functionality in 'WorkflowDefinitionService' and other similar services have been updated to use these new methods, improving consistency and maintainability.
* Enable caching in Elsa.Server.Web
The "useCaching" variable has been set to true to enable caching. Simultaneously, the method name "UseCachingStores" has been refactored to "UseCache". Conditional statements have been added to check the "useCaching" variable before invoking caching.
* Rename method UseCaching to UseCache
In the Elsa.Server.Web and Elsa.Http project files, the method UseCaching has been renamed to UseCache. This modification is aimed at bridging naming inconsistencies and maintaining naming standards across the application.
* Update HttpCacheFeature class description
The class summary for HttpCacheFeature has been revised. Originally, it stated that the class was used for installing services related to HTTP services and activities, but it actually focuses more on HTTP caching.
* Remove unused Configure method from HttpCacheFeature
The Configure method in HttpCacheFeature was found to be redundant as it wasn't doing any significant work or contributing to any functionality. It has therefore been removed to clean up the code and avoid confusion.
* Add 'bug/*' to workflow triggers
This commit includes 'bug/*' to the list of triggers in our GitHub Actions workflow. Now, any push or pull request under a 'bug/*' branch will trigger the workflow.
* Fix LogPersistenceMode default mapping logic
Fixes#5217
* Format adjustment in DefaultActivityExecutionMapper.cs
Applied minor code reformatting in the DefaultActivityExecutionMapper.cs file to maintain consistency and improve readability. This was mostly centered around adding spaces for proper code alignment and indentation to match the overall code style in the project. No functional changes were made.
* Refactor workflow dispatch and instance creation process
This update splits the process of dispatching a workflow into two steps: Initialization and Execution. Now, first, a new workflow instance is created and saved with the input parameters. Second, the new workflow instance is dispatched for execution. This process ensures that the size of the message dispatched does not exceed acceptable limits and enhances workflow dispatch efficiency. It also helps avoid data loss in case of premature process termination or failure in the initial stages of execution.
* Change default workflow substatus to 'Pending'
The code changes involve modifying the default WorkflowSubStatus from 'Executing' to 'Pending'. This minor adjustment is implemented to represent a more accurate initial state of a new workflow instance in the WorkflowManagement module in Elsa.
* Add support for existing workflow instances in WorkflowInstance grain
The change extends the WorkflowInstance grain to include an IWorkflowInstanceStore to support workflows that already exist. Additionally, the CreateWorkflowHostAsync method is enhanced to rebuild a workflow host if the instance already exists.
* Simplify XML comments format
* Refactor comments in `StartWorkflowHostParams` class
Removed unnecessary comment tags in the `StartWorkflowHostParams` class for better readability and simplicity. Also, unused lines of code from the `IWorkflowRuntime` interface have been commented out to enhance clarity and cleanliness in the codebase.
* Remove unnecessary comment in MassTransitWorkflowDispatcher
The obsolete comment about attaching a version header to the message was removed from 'MassTransitWorkflowDispatcher.cs'. This comment was no longer relevant as the dispatcher no longer performs the action described.
In the FlowFork.cs file of the Elsa.Workflows.Core module, the method ScheduleOutcomesAsync has been replaced with CompleteActivityWithOutcomesAsync. This fixes the issue of the activity not completing.
Fixes#5204
The commit adds a new task in the check list of the bounty-footer file. The new requirement compels the user to describe their proposed solution either in a comment on the issue or in a discussion linked to the bounty, before beginning their work.
The footer content in the bounty documentation has been expanded to provide clearer instructions for potential contributors. It includes instructions on how to announce an intention to claim a bounty and what to do before starting. An example template for bounty candidacy has also been added for the ease of contributors.