Commit graph

4325 commits

Author SHA1 Message Date
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
Sipke Schoorstra 17c20c53f7 Change MongoUserStore to non-abstract class
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.
2024-05-27 13:56:08 +02:00
Sipke Schoorstra 4af488cf6a Remove unnecessary properties from WorkflowDefinition models
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`.
2024-05-27 10:11:10 +02:00
MariusVuscanNx d817d7ccaf
Global read-only and read-only workflows (#5406)
* 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>
2024-05-27 10:06:39 +02:00
Sipke Schoorstra f03c62a7a4
Revert sending input as global state instead of parameter (#5425)
* 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.
2024-05-22 17:22:19 +02:00
Raymond den Haan 0cbd4f310d Update Npgsql package versions
Override versions used of Npgsql to ensure usage of versions without known vulnerability
2024-05-22 16:33:57 +02:00
Sipke Schoorstra 5241bd790d Update configuration for DistributedLockProvider
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.
2024-05-21 21:33:14 +02:00
Sipke Schoorstra d89a07d391
Add distributed locking to MassTransitWorkflowDispatcher (#5418)
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.
2024-05-21 21:32:27 +02:00
Sipke Schoorstra a2908960a4
Add Fault Code, Category and Type (#5362)
* 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.
2024-05-10 15:30:32 +02:00
Stephan Melzer 016fa22145
Bugfixes for heartbeats using MongoDB (#5337)
* 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>
2024-05-08 20:19:40 +02:00
Nick Rubenstein 33178f41c1
#5313 Include dropdown when using a nullable enum in an activity input (#5320)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-05-08 20:16:43 +02:00