Commit graph

1451 commits

Author SHA1 Message Date
raymonddenhaan 5cfd6d9860
Extended check when to update dependent workflows (#5598) 2024-06-13 11:15:25 +02:00
Sipke Schoorstra c88e5a846d Add 'Data' category to Workflow Management Feature
The 'Data' category has been added to the Workflow Management Feature. This includes support for byte arrays and Stream types, extending the type capabilities of the feature.
2024-06-13 07:11:02 +02:00
Sipke Schoorstra bbc7d502d5 Move HTTP OutputExtensions to a shared library for reuse 2024-06-12 23:38:47 +02:00
Sipke Schoorstra f04cb0af9d
Fix MT consumer registration when DisableConsumers is set (#5578)
* Fix Azure Service Bus MassTransit feature to only register consumers if consumers are not marked as disabled.

* Add comment explaining NPGSQL version override

* Update `WorkflowDefinitionActivityRegistryUpdater`

FirstOrDefault will exit the loop immediately, which is faster, than SingleOrDefault, which will go through the end of the list to ensure only a single item matches the predicate.

* Ensure temporary consumers are registered

* Add flag to control if consumer should ignore ConsumersDisabled flag
2024-06-12 19:59:39 +02:00
Sipke Schoorstra 783e16f3f7 Add V3_2 migration to Elsa modules
This commit adds a new migration, V3_2, to various Elsa modules including MySql, SqlServer, Sqlite and PostgreSql. It includes the creation of new migration files for both alterations and runtime aspects. The commit applies to Elsa's EntityFrameworkCore-based modules and forms part of the database schema evolution process.
2024-06-10 20:54:23 +02:00
Sipke Schoorstra 0422435be9
Fix workflow variable scope inconsistency (#5558)
* Refactor variable handling in ExpressionExecutionContextExtensions

The core change in this commit is the refactoring of the handling of variables within the ExpressionExecutionContextExtensions. The methods GetVariable, CreateVariable, and GetVariableBlock have been altered for clarity and simplified reducing redundant code. Unnecessary parameters and returns in method documentation have been removed, and overall code formatting has been improved to enhance readability.

* Simplify MemoryRegister creation in Workflow.cs

The creation of the MemoryRegister object in the file Workflow.cs was simplified to one line. The previous method, which declared a new object then called the Declare method before returning, was removed.

* Map controller routes in server web program

Added a line of code in the Elsa.Server.Web program.cs file to map controller routes. This change ensures that HTTP requests are correctly directed to their corresponding controller actions.

* Update workflow state extraction logic

The logic in the WorkflowStateExtractor has been updated to retain the root Workflow activity context even if it's completed. This change is necessary to keep workflow-level variables accessible.

* Remove RequiresUnreferencedCode attribute from ConvertTo method

The RequiresUnreferencedCode attribute was removed from the ConvertTo method in the ObjectConverter class.

* Remove unused services and rename test file

Unused services in the AutoUpdateTests.cs class were removed, reducing clutter and improving code readability. Additionally, the DeleteWorkflow_Clustered.cs test file has been renamed to DeleteWorkflowClustered.cs for better naming consistency.

* Add CountdownStep activity and CountdownWorkflow for testing

This commit introduces new component tests for simulations involving counters. It includes a new CountdownStep activity that decrements a counter variable, as well as a CountdownWorkflow which consists of a loop based on the aforementioned activity. It also involves a CountdownWorkflowTests class for testing counter persistence across workflow runs.

* Remove unnecessary whitespace in CountdownWorkflowTests

This commit eliminates the superfluous whitespace in the CountdownWorkflowTests.cs file. It maintains the proper formatting and ensures code consistency across the test component.

* Refactor CountdownWorkflowTests constructor

Simplified the constructor of the CountdownWorkflowTests class. The changes remove the unnecessary constructor body and pass the 'app' object directly to the base AppComponentTest class, enhancing the code's readability and maintainability.

* Add application roles and configure them in MassTransit

A new enum ApplicationRole has been added for distinguishing among different roles (Hybrid, Api, Worker) an application can take. In the configuration of MassTransit, it is now possible to disable the consumers based on application role, which can help optimize the usage of resources and increase application efficiency.

* Update Program.cs

Switch to Memory broker

* Update Program.cs

Simplify DisableConsumers assignment.

* Update ApplicationRole.cs

Rename Hybrid to Default.

* Update appsettings.json
2024-06-10 10:51:23 +02:00
Sipke Schoorstra 29742db513
Add application roles and configure them in MassTransit (#5561)
A new enum ApplicationRole has been added for distinguishing among different roles (Hybrid, Api, Worker) an application can take. In the configuration of MassTransit, it is now possible to disable the consumers based on application role, which can help optimize the usage of resources and increase application efficiency.
2024-06-10 10:45:12 +02:00
rosca-sabina 5ebf4302d3
Fixed DI registration for MongoAlterationPlanStore (#5564) 2024-06-09 17:36:36 +02:00
rosca-sabina da7bff83b7
Added MongoDB implementation for alteration storage (#5555) 2024-06-09 15:18:30 +02:00
Sipke Schoorstra 551c91bb4f Refactor response handling in workflow API
Simplified the response creation and sending in the `Post` endpoint of `WorkflowDefinitions` in the `Elsa.Workflows.Api` module. Previous logic was replaced with a streamlined approach of creating and sending the JSON response. Additionally, `Response` data model in the same endpoint has been updated to include an `AlreadyPublished` field.
2024-06-07 18:24:20 +02:00
Sipke Schoorstra effa850909 Remove logging scope from OnChildCompletedAsync method
The logging scope that was created within the OnChildCompletedAsync method in the Flowchart.cs file has been removed. Additionally, some trivial code formatting adjustments were made to increase readability and maintain consistency. No significant functionality changes were introduced.
2024-06-07 18:04:31 +02:00
Sipke Schoorstra bcc6071644 Merge branch 'patch/alpha' 2024-06-07 18:01:09 +02:00
Raymond den Haan c0ee30be5f Made ActivityRegistryUpdateService provider specific 2024-06-07 14:01:14 +02:00
Raymond den Haan 90d9561e76 Moved logic for updating the Activity Registry 2024-06-07 14:01:14 +02:00
Raymond den Haan e7863da413 Fix naming issues 2024-06-07 14:01:14 +02:00
Sipke Schoorstra f52c163fe0 Refactor logging instances in DefaultTriggerScheduler.cs
This commit changes the reference to the logger instance in the DefaultTriggerScheduler class. It corrects the reference from a private instance to the correct instance 'logger'. Moreover, the string formatting of the second logger warning message has been updated for standardization.
2024-06-07 14:01:14 +02:00
Raymond den Haan 4a44037710 Revert "Fixed issue when more than 100 workflows as activities are available"
This reverts commit b4d62e1c5fe1707e907c383ae60cf490f31f1687.
2024-06-07 14:01:14 +02:00
Raymond den Haan dc355413ce Fix Sonar maintainability issues
Improved logging
Added missing comments
2024-06-07 14:01:14 +02:00
Raymond den Haan 48523c4ecd Add HTTP cache invalidation on auto-update of consuming workflows 2024-06-07 14:01:14 +02:00
Raymond den Haan e37a0d4a4b Add handling for workflow definition versions update events
Fixed updating the ActivityRegistry when workflows get updated due to the `auto update consuming workflows` option
2024-06-07 14:01:14 +02:00
Raymond den Haan 5dcf6f382a Fix workflow deletion and updates handling 2024-06-07 14:01:14 +02:00
Raymond den Haan 0a86729040 Fix handling of definition retracted, created and published events
Fixed handling of UsableAsActivity property on definitions
2024-06-07 14:01:14 +02:00
Raymond den Haan b092d62bcc Added Service for searching through ActivityRegistry
Added Refreshing of registry on miss when searching
2024-06-07 14:01:14 +02:00
Raymond den Haan 2abe58fa10 Update activity registry & workflow definitions
This commit removes unnecessary calls related to populating activity registry and reinitializing workflow definitions.
2024-06-07 14:01:14 +02:00
Raymond den Haan 3272938c8e Add "UsableAsActivity" field to workflow events in MassTransit module
Updated event handling to only update activity registry for workflows marked as usable as activity
2024-06-07 14:01:14 +02:00
Raymond den Haan 2ee823ba30 Fixed issue when more than 100 workflows as activities are available 2024-06-07 14:01:14 +02:00
Raymond den Haan 90651b4735 Updated local handling of workflow definition events for updating activity registry 2024-06-07 14:01:14 +02:00
Raymond den Haan db079ae41b Updated distributed workflow definition event handling for activity registry 2024-06-07 14:01:14 +02:00
Raymond den Haan ef65580d1f Fix naming 2024-06-07 13:13:47 +02:00
Raymond den Haan 1d4d3ea108 Extend publish workflow response
Added IsPublished property to response instead of sending separate message.
2024-06-07 13:13:47 +02:00
Raymond den Haan b05449c031 Do not send error if workflow is already published 2024-06-07 13:13:47 +02:00
Raymond den Haan fb3b5339f4 Made Updating workflow references part of Publish logic 2024-06-07 13:13:47 +02:00
Raymond den Haan 38cbd9662e Add activity existence check in Flowchart
This update prevents the creation of multiple flow activities by checking if the activity is already set to be created while the activity context has not yet been created.
2024-06-06 15:29:02 +02:00
Sipke Schoorstra 07c889f489 Update logger scope state in Flowchart activity
The logger scope state within the Flowchart activity has been updated to use the current managed thread ID from the Environment class. Additionally, a new property 'TaskId' has been incorporated for providing the current task ID, defaulting to 'N/A' in case null.
2024-06-06 12:03:47 +02:00
Sipke Schoorstra de433b39f9 Add warning for ID mismatch in workflow definitions
Added a check and corresponding log warning in the 'DefaultWorkflowDefinitionStorePopulator' class for cases where an imported workflow definition has a different ID than the existing one in the store. This will help in identifying ID discrepancies that may impact workflow execution or management. Future updates may include storing these discrepancies for troubleshooting purposes.
2024-06-05 18:09:39 +02:00
Sipke Schoorstra dc2184fba4 Add warning for ID mismatch in workflow definitions
Added a check and corresponding log warning in the 'DefaultWorkflowDefinitionStorePopulator' class for cases where an imported workflow definition has a different ID than the existing one in the store. This will help in identifying ID discrepancies that may impact workflow execution or management. Future updates may include storing these discrepancies for troubleshooting purposes.
2024-06-05 18:07:48 +02:00
Sipke Schoorstra 65604b6563 Remove signal capturing phase (#5501)
* Add logging to the WorkflowRunner service

The WorkflowRunner service now uses the Microsoft.Extensions.Logging namespace to log the workflow execution context. These changes include passing the ILogger<WorkflowRunner> logger dependency through the constructor and implementing the context logging functionality in the RunAsync method.

* Update error handling in FindActivityDescriptor method

FindActivityDescriptor method's error handling has been updated. Now, instead of throwing exception, it returns null when an activity descriptor can't be found. Also, a logger warning has been added to indicate when this situation occurs. This change helps avoiding unexpected disruptions and improving debugging experiences.

* Add ReSharper properties to .editorconfig

This commit introduces specific ReSharper properties to the .editorconfig file. This update will maintain a consistent configuration of ReSharper across different development environments, intending to improve coding standard consistency.

* Add thread and activity ID to Flowchart logging scope

The Flowchart activity in Elsa Workflows Core module has been modified to include thread and activity ID in its logging scope. This change will provide more granular information when debugging workflow execution. Additionally, the definition for outcomeNames has been streamlined.

* Add ActivityInstanceId to logger scope

Added "ActivityInstanceId" as part of the logging scope dictionary in the Flowchart module. The new key records the context's target context's id for improved debugging capabilities.

* Remove signal capturing functionality from workflow activities

Removed the functionality related to signal capturing from the Elsa workflow activities. This refactor involves changes in core classes such as Activity, Behavior, and Flowchart and removes associated methods and handlers. This simplifies the signal handling process by only allowing activities to receive signals, eliminating the previous two-step process of capturing and receiving.

* Update debugging messages in Flowchart.cs

Clarified the debugging message when there's an existing join context. Removed unnecessary logging for "No pending work found", "No faulted activities found", and "Completing flowchart". This will make the debugging log less cluttered and more focused on relevant information.

* Refactor logging messages in Flowchart activity

The commit removes the verbose logging message indicating the completion of a terminal activity in the flowchart Context. This logging message was unnecessary and was generating excessive log messages. The log message for new join activities was also updated to accurately reflect the creation of a new join context.

* Disable SonarCloud analysis from workflow

The SonarCloud analysis steps, including scan setup, run and end steps have been commented out in the GitHub workflow. This is a temporary change to speed up build times while troubleshooting an issue.

* Uncommented SonarCloud analysis related code in packages.yml

In this commit, the parts of the code related to the set up of JDK 17, SonarScanner for .NET, Coverlet for code coverage, and SonarCloud analysis were uncommented in the GitHub Actions workflow packages.yml file. This will enable those tools and services during the execution of the workflow, improving code quality and test coverage.

* Change position of root assignment comment in .editorconfig

* Format method signatures in WorkflowRunner

Changed the method signatures in the WorkflowRunner class to be in a single line for readability and to follow coding standards. The refactor involves three RunAsync method overloads, contributing to the overall cleanliness and readability of the source code.
2024-06-04 16:44:23 +02:00
Sipke Schoorstra bd2e70cbe1
Remove signal capturing phase (#5501)
* Add logging to the WorkflowRunner service

The WorkflowRunner service now uses the Microsoft.Extensions.Logging namespace to log the workflow execution context. These changes include passing the ILogger<WorkflowRunner> logger dependency through the constructor and implementing the context logging functionality in the RunAsync method.

* Update error handling in FindActivityDescriptor method

FindActivityDescriptor method's error handling has been updated. Now, instead of throwing exception, it returns null when an activity descriptor can't be found. Also, a logger warning has been added to indicate when this situation occurs. This change helps avoiding unexpected disruptions and improving debugging experiences.

* Add ReSharper properties to .editorconfig

This commit introduces specific ReSharper properties to the .editorconfig file. This update will maintain a consistent configuration of ReSharper across different development environments, intending to improve coding standard consistency.

* Add thread and activity ID to Flowchart logging scope

The Flowchart activity in Elsa Workflows Core module has been modified to include thread and activity ID in its logging scope. This change will provide more granular information when debugging workflow execution. Additionally, the definition for outcomeNames has been streamlined.

* Add ActivityInstanceId to logger scope

Added "ActivityInstanceId" as part of the logging scope dictionary in the Flowchart module. The new key records the context's target context's id for improved debugging capabilities.

* Remove signal capturing functionality from workflow activities

Removed the functionality related to signal capturing from the Elsa workflow activities. This refactor involves changes in core classes such as Activity, Behavior, and Flowchart and removes associated methods and handlers. This simplifies the signal handling process by only allowing activities to receive signals, eliminating the previous two-step process of capturing and receiving.

* Update debugging messages in Flowchart.cs

Clarified the debugging message when there's an existing join context. Removed unnecessary logging for "No pending work found", "No faulted activities found", and "Completing flowchart". This will make the debugging log less cluttered and more focused on relevant information.

* Refactor logging messages in Flowchart activity

The commit removes the verbose logging message indicating the completion of a terminal activity in the flowchart Context. This logging message was unnecessary and was generating excessive log messages. The log message for new join activities was also updated to accurately reflect the creation of a new join context.

* Disable SonarCloud analysis from workflow

The SonarCloud analysis steps, including scan setup, run and end steps have been commented out in the GitHub workflow. This is a temporary change to speed up build times while troubleshooting an issue.

* Uncommented SonarCloud analysis related code in packages.yml

In this commit, the parts of the code related to the set up of JDK 17, SonarScanner for .NET, Coverlet for code coverage, and SonarCloud analysis were uncommented in the GitHub Actions workflow packages.yml file. This will enable those tools and services during the execution of the workflow, improving code quality and test coverage.

* Change position of root assignment comment in .editorconfig

* Format method signatures in WorkflowRunner

Changed the method signatures in the WorkflowRunner class to be in a single line for readability and to follow coding standards. The refactor involves three RunAsync method overloads, contributing to the overall cleanliness and readability of the source code.
2024-06-04 09:54:27 +02:00
Sipke Schoorstra 547ab4a135 Refactor Elsa.Workflows.Core for improved logging
Logging functionality has been improved within the Elsa.Workflows.Core module. Logging has been introduced into the WorkflowRunner class, allowing for better tracking of workflow instance execution. Various debug log statements throughout the Flowchart activity have been removed or refactored to improve readability and efficiency of the code.
2024-06-03 15:05:39 +02:00
Sipke Schoorstra 26389f0482 Add validation for empty cron expression
This commit adds validation for cron expressions in the DefaultTriggerScheduler class. The system now checks if the cron expression provided is empty and issues a warning if that's the case. This prevents attempts to schedule triggers with an empty cron expression, which would fail.
2024-06-03 15:01:19 +02:00
Sipke Schoorstra 100ece8278
Add JSON Serialization for Elsa expression (#5490)
* Add JSON Serialization for Elsa expression

Extended the expression serialization. Added new classes ExpressionJsonConverter and ExpressionJsonConverterFactory implementing serialization of expression objects. Also, made respective changes in different serializers and related files for seamless integration.

* Fix XML comments

* Set initial builder Id in ClrWorkflowProvider

This commit involves a modification in ClrWorkflowProvider.cs where an Id was set for the builder. The Id was set with the format `workflowBuilderType.Name`:1.0, providing a deterministic identifier for each builder instance.

* Add MysteriousPondWorkflow and associated HTTP endpoints

A new workflow, MysteriousPondWorkflow, has been introduced along with HTTP endpoints to interact with it. The workflow simulates throwing an arbitrary amount of rupees into a mysterious pond and getting a luck prediction for the day based on the amount. An integration of this workflow is registered in the main Program.cs file, and the necessary directories to handle this workflow have been added to relevant project files.
2024-06-03 08:38:18 +02:00
Sipke Schoorstra 038d29b792 Refactor code to fix incorrect logger reference
In the DefaultTriggerScheduler.cs file, a wrong reference to _logger was corrected. It caused issues during attempts to log a warning when the 'cronExpression' parameter is empty. Now the correct local logger object is used.
2024-05-31 16:46:03 +02:00
Sipke Schoorstra efbfe8ea9a Add validation for empty cron expression
This commit adds validation for cron expressions in the DefaultTriggerScheduler class. The system now checks if the cron expression provided is empty and issues a warning if that's the case. This prevents attempts to schedule triggers with an empty cron expression, which would fail.
2024-05-31 14:41:08 +02:00
Sipke Schoorstra 51cd3fa851
Update and optimize WorkflowDefinitionStore logic (#5462)
The update involves optimizing the WorkflowDefinitionStore logic. The minor change is that it removed an unneeded space in the CountDistinctAsync method. More importantly, an upgrade issue with 'IsSystem' from older versions of Elsa to 3.2 has been rectified by adding checks and conditions to suit legacy versions. In the future, once all systems are updated, this check can be removed.
2024-05-29 10:35:42 +02:00
Sipke Schoorstra 411151d748
Refactor DefaultTriggerScheduler and handle past StartAt triggers (#5463)
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.
2024-05-29 10:34:44 +02:00
Sipke Schoorstra 4393d95505 Add validation before getting workflow in GenerateWorkflowInputAccessors
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.
2024-05-28 23:00:47 +02:00
Sipke Schoorstra 41110774a1 Merge branch 'main' of github.com:elsa-workflows/elsa-core 2024-05-28 21:13:19 +02:00
Sipke Schoorstra f162186a5f Refactor ElsaDbContextBase to clean up schema setup
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.
2024-05-28 21:12:45 +02:00
jdevillard a130363a41
add text/html content parser as string content (#5460)
* add text/html content parser as string content

* add text/html content parser in configuration

---------

Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-05-28 21:06:22 +02:00
jdevillard ad236f626f
Add Http Response Behavior to answer synchronously using the HttpResponse Activity (#5446)
* Update WriteHttpResponse.cs to call response.CompleteAsync()

* Add options in HttpActivityOptions

---------

Co-authored-by: Ciaran ODonnell <wannabedeveloper@live.com>
Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-05-27 21:14:25 +02:00