Refactored the BackgroundTaskDispatcher class to accept the INotificationSender service directly rather than the IServiceScopeFactory. This change simplifies the dispatch process. Also, adjusted the service lifecycle of RunTaskDispatcher, changing it from singleton to scoped.
* Made cancel API call dispatch the request
* Added ParentWorkflowInstanceId
* Recursively cancel child workflows
* Made single workflow cancellation include child workflows
* Updated migrations
* Processed comments
A ConfigureAwait tag was added to the FodyWeavers.xml file in the Elsa.Server.LoadBalancer bundle. This adjustment will influence how awaitable tasks are resumed in the .NET asynchronous programming model.
The Elsa.Server.LoadBalancer project settings have been updated to support multiple target frameworks (net7.0 and net8.0), with Linux defined as the default target OS for Docker. Additionally, the build.sh file reference has been added to the Elsa.sln solution.
Two new properties have been introduced in the Elsa.Server.LoadBalancer project file. These include setting the 'IsPackable' attribute to 'false', preventing the project from being packaged and setting the 'LangVersion' to 'latest', to use the latest available version of C#.
* Moved handler to correct namespace
* Added version deletion messages to activity registry handler
* Add MassTransit support for workflow management
* Moved logic from Workflow.Management.MassTransit project into Elsa.MassTransit project
* Added notifier to MT project for creating distributed messages
* Rename and update workflow consumer class
Renamed `WorkflowDefinitionConsumer` to `WorkflowDefinitionEventsConsumer` to better reflect its purpose. Updated references accordingly in the `MassTransitWorkflowManagementFeature` class to align with the new name.
* Shortened instance (queue) names
* Remove unnecessary comment in handler definition
An unnecessary comment mark ("/") was removed in the definition of the DistributedWorkflowDefinitionNotificationsHandler class. This change contributes to code cleanup and increases code readability.
* Add additional destinations in LoadBalancer settings
Three new destinations have been added to the LoadBalancer settings in Elsa Server. These are primarily intended to provide broader network coverage and improve overall server performance.
* Add MassTransit support in Elsa.Server
A new using directive for Elsa.MassTransit.Extensions has been included at the start of the script. In addition, under certain conditions, the system now uses the MassTransit Dispatcher in the workflow management system. These changes provide support for using MassTransit in the Elsa.Server component.
* Add MassTransitBroker enum for MassTransit setup
A new enum called MassTransitBroker has been added to represent different types of messaging brokers used in MassTransit. This has also been integrated into the Web project's Program.cs file to allow conditional usage of brokers in the MassTransit setup, enabling more flexible and dynamic configuration.
* Refactor WorkflowManagementFeature class
The WorkflowManagementFeature class has been cleaned up and its formatting has been corrected. A blank line was removed, a line break was added for readability in the AddVariableType method, and several stray spaces were also removed.
* Refactor RefreshActivityRegistryHandler.cs
This commit removes unnecessary whitespace and improves the code readability in RefreshActivityRegistryHandler.cs. The changes include deletion of extra lines and adjustment of indentation.
---------
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Create new docker-compose files for non-data dog and data dog services. New services include Postgres, cockroachdb, rabbitmq, redis, and elsa-server. Along with the services, a new bash script for migration and various new activities and endpoints are also added for the Elsa server. This set of changes broadens the operational environment of Elsa.
This commit introduces a new bundle for load balancing into the Elsa.Server solution. It includes initial configuration files, launch settings, and reverse proxy setup. The load balancer is configured with a RoundRobin policy and the project references the Yarp.ReverseProxy package.
The ScheduledCronTask now receives an ILogger instance and handles exceptions during timer setup by logging the error. Additionally, a constructor overload with the logger parameter has been added, and a new TrySetupTimer method encapsulates the timer setup with error handling.
* Add DryRun endpoint and workflow instance finder
Added a new DryRun endpoint for executing alteration plans and implemented the IWorkflowInstanceFinder interface to search for workflow instances. Refactored existing code to use new workflow instance finder service, resulting in cleaner activity implementation.
* Fix empty check in WorkflowInstanceFinder
Change the conditional logic to use `IsEmpty` method on filters rather than checking if the collection `workflowInstanceIds` is empty. This ensures that matching workflow instances are correctly identified when no specific filters are set.
* Refactor WorkflowInstanceFinder with WorkflowStatus default
The WorkflowInstanceFinder service has been refactored to include a default workflow status of Running and to utilize a new method WorkflowFilterIsEmpty, which checks if the workflow instance filter is empty. This improves code readability and encapsulates the logic for determining an empty filter.
* Fix callback clearing in workflow execution
The method ClearCompletionCallbacks in the ActivityExecutionContext was modifying the collection during enumeration, which can lead to issues. Converting to a List before removal ensures safe modification without side effects.
* Add log message sanitization for PostgreSQL
The new LogStringExtensions class provides methods to sanitize log messages, ensuring that null characters are replaced with "\0". These changes prevent issues with PostgreSQL's inability to store null characters in strings, improving log data compatibility with the database.
* Rename and update log extension class
Refactor LogStringExtensions to LogExtensions and update summary comment for clarity. This change emphasizes the broader application of the extension methods beyond string manipulation, focusing on sanitizing log messages.
* Add alteration notifications and management
Implement notification publishing for completed alteration plans and add related handlers and management logic to coordinate alterations workflow triggering and completion status updates.
* Refactor queue address configuration in MassTransit
The initialization of the queue address and mapping for the `RunAlterationJob` has been moved out of the `Apply` method to the module configuration.
* Refactor CompleteAlterationPlan activity description
The activity summary comment in CompleteAlterationPlan.cs was updated to accurately describe its functionality. The description has been changed from "Submits an alteration plan for execution" to "Marks an alteration plan as completed."
Refactor the ID generation for Alteration Plans to ensure the `planParams.Id` is always set directly before creating a DispatchWorkflowDefinitionRequest. This avoids the unnecessary extra variable and ensures the ID property is consistently used throughout the method.
Fixes 5093
Introduced support for PostgreSQL in the Elsa Server configuration and updated the docker-compose to reflect the new database option. Adjusted the dependencies to include the EntityFrameworkCore PostgreSQL project reference.
The previous implementation used the generic MongoCollectionBase service to retrieve workflow definition and instance collections. Now, the code has been updated to use IMongoCollection specifically designed for WorkflowDefinition and WorkflowInstance. This change ensures better typing and possibly performance improvements.
Removed unnecessary namespace in OrderBatchProcessor workflow and set a descriptive name for the workflow sequence. Updated the EF Core configuration in Program.cs to use SQLite with a specified connection string and ensure Order types are accessible in CSharp expressions.
Introduce a new DecimalJsonConverter class and refactor serialization setup. Renamed IntegerConverter to IntegerJsonConverter and updated its implementation to handle both number and string JSON tokens. Adjusted serializer options in ConfigurableSerializer and ObjectExpressionHandler accordingly.
Enhanced the clarity of the input field by adding a `DisplayName` attribute in the `BulkDispatchWorkflows` activity. This better describes the purpose of the input field for workflow definition selection.
Corrected the parameter token in the error log message to match the expected variable name, ensuring accurate logging when attempting to create duplicate workflows. This helps in diagnosing the root cause of issue #5033 more efficiently.
* Remove Elsa.Alteration Handlers and implement workflow alteration activities
The Elsa.Alterations.Handlers, Services, and Endpoints have been removed and replaced with Elsa.Alterations.Activities for various steps in executing an alteration plan. These activities include submitting an alteration plan, generating alteration jobs, and dispatching alteration jobs. New models for ActivityFilter, AlterationWorkflowInstanceFilter, and alteration activity summaries are also introduced for better management of alteration plans.
* Add 'PrintMessage' custom activity and update naming rules
A new 'PrintMessage' activity has been added to the custom activities of the ConsoleApp, which simply writes a 'Hello world!' message. On top of this, the naming rules in the code styling settings have been expanded, introducing separate rules for instance and static private fields.
* Remove V3_1 database migration files
The V3_1 database migration files were deleted across all database providers, including MySql, SQL Server, SQLite and PostgreSQL. This is indicative of a rollback or significant revision to the data migration strategy.
* Update product version and modify tables in Elsa DB context
Updated "Elsa" DbSet product version from "7.0.11" to "7.0.14". Additionally, added new properties as well as modified existing ones in tables like "Elsa.KeyValues.Entities.SerializedKeyValuePair" to improve data structure. Also properly ignored certain entities in the Alterations DbContext.
* Add V3_1 migration for Elsa
This commit introduces the V3_1 migration for the Elsa module. Changes involve the introduction of new tables and alteration of existing tables. Specifically, a new 'KeyValuePairs' table was added and several columns on various tables were renamed or altered.
* Remove multiple Elsa.EfCore V3_1 migration files
The commit removes several migration files related to the V3_1 migration in multiple Elsa.EntityFrameworkCore modules including SqlServer, PostgreSQL, and SQLite. These files encompass changes in table structures and alterations.
* Update default value for ArgumentDefinition Type
The default value for the `Type` property in the `ArgumentDefinition` class was updated to `typeof(object)`. The `Type` property of `inputDefinition` in the `WorkflowBuilder` class was also modified to be set as `typeof(T)`. These modifications enable more flexible type handling.
* Refactor SafeSerializer and serialization services
The SafeSerializer service and related serialization services have been comprehensively refactored. This includes the removal of internal notifications, the incorporation of [RequiresUnreferencedCode] attributes, and changes in method signatures. Methods have been simplified to return ValueTasks directly from the JsonSerializer, and the notification sender dependency was removed.
* Add JSON serialization for alterations
Implemented a JSON serializer and a custom converter for the IAlteration interface in the Elsa.Alterations.Core.Serialization namespace. Also, introduced a new IJsonSerializer interface and an implementation for standard JSON serialization in Elsa.Common. These serialization changes enhance modularity and extensibility of JSON operations, and improve handling of IAlteration objects.
* Add "IsSystem" field to Workflow Definitions and Instances
This update introduces a new boolean field "IsSystem" to the Workflow Definition and Workflow Instance models. This field is designed to identify system workflows which aren't meant to be modified by users. Management and Runtime module code, API endpoints, database migrations, and related classes have been updated to include this new field. The MongoDB indices and Dapper migrations have been updated as well, and serialization/deserialization processes for these types have been modified to handle this new attribute.
* Remove outdated database migrations
Deleted database migration files from the MySql, SqlServer, and PostgreSql projects.
* Add V3_1 migration for Elsa.EntityFrameworkCore.Sqlite
This commit introduces the V3_1 migration for the Elsa.EntityFrameworkCore.Sqlite module. It includes changes in Alterations, Runtime, Management, and Identity contexts. These changes involve table alterations, addition of new columns, and creation of new tables. Each context alteration encapsulates relevant changes for specific functionalities of the module.
* Add `IsSystem` property to workflow classes
The `IsSystem` property has been added to several sections of the codebase related to workflows, such as `WorkflowStateMapper.cs`, `ListWorkflowDefinitionsRequest.cs`, `WorkflowDefinitionStore.cs`, and `ListWorkflowInstancesRequest.cs`. This property flag allows us to include or filter system workflows in our queries and results.
* Add 'UsedImplicitly' attribute to Alteration Handlers and Types
The 'UsedImplicitly' attribute from JetBrains.Annotations has been added to all Alteration Handlers and Alteration Types in the Elsa.Alterations module. This change specifies that these classes are being used implicitly and helps tools like ReSharper prevent false unused code detection.
* Update migration script for efcore-3.1
The migration script efcore-3.1.sh has been updated. Module "Alterations" and provider "Sqlite" are added back into the lists while unused elements are removed for cleanup. The script now covers all necessary modules and providers, improving its overall effectiveness.
* Remove PrintMessage class from Elsa.Server.Web bundle
This commit deletes the PrintMessage.cs file that was previously part of the Elsa.Server.Web bundle.
* Refactor MassTransit service configuration
This commit reduces line code length by merging splitted long lines into one, improves maintainability of code. It also updates the Service configuration and removes unused namespaces across files, which help to simplify the codebase. Changes have also been made to switch the MassTransit broker from RabbitMq to memory and adjust the endpoint name formatter configuration.
* Remove extra whitespace in Program.cs
Removed a trailing whitespace on the line declaring the useSqlServer constant in the Program.cs file. No functionality changes were made, simply a minor formatting correction to maintain clean and consistent code.
* Remove AlterationJsonConverter and update other files
The AlterationJsonConverter class has been removed, simplifying the serialization process. The AlterationSerializer.cs file was updated with additional attribute tags, giving more information about serialization expectations. Lastly, the AlterationSerializationOptionConfigurator.cs was simplified by removing unnecessary overrides and the Elsa.Alterations.Core.csproj file was tidied up by removing unused services folder reference.
* Refactor code for improved readability and maintainability
The diff shows changes across multiple files in multiple modules. Primarily, these changes revolve around formatting edits such as removing unnecessary spaces or line breaks and adjusting alignments. A significant change was also made to the MySQL server version in the `DbContextOptionsBuilder.cs` file. These adjustments help improve the readability and maintainability of the code, making it easier to understand and modify in future iterations.
* Remove unnecessary notification files and refactor code
Several files pertaining to workflow serialization notifications were deemed unnecessary and removed. The Endpoint class in the `Elsa.Workflows.Api` module has been refactored for efficient usage of the `IWorkflowDefinitionStore` store, and similarly the `HttpFeature.cs` and `DesignTimeDbContextFactoryBase.cs` files have been slightly refactored for better readability and optimization.
* Refactor HttpFeature class on variable types order
The variable types order within the HttpFeature class in the Elsa Http module has been reorganized for cleaner code. No functional changes have been made - only the order of the types has been rearranged. This refactoring contributes to better readability and code maintenance.
* Add 'issue/*' branch to GitHub workflow triggers
This update includes 'issue/*' branches in the trigger configuration of GitHub workflows. Now, these branches will trigger specified GitHub actions, facilitating more effective issue tracking and resolution.
* Change version option in WorkflowDefinitionManager
The version option in the WorkflowDefinitionManager has been updated. Previously it was set to "LatestAndPublished", but this has been changed to "LatestOrPublished", adjusting the way the manager handles workflow versions.
* Update GitHub Actions to remove duplicate branch pattern
Removed the duplicated 'issue/*' entry from the branch trigger list in packages.yml to prevent redundancy in GitHub Actions workflow triggers. This ensures workflows are triggered correctly and efficiently for branch patterns intended for CI processes.
* Refactor job generation in GenerateAlterationJobs
Refactored the GenerateAlterationJobs activity to enhance code readability and maintainability. Broke down the ExecuteAsync method into smaller, purpose-specific private methods and added the missing `Elsa.Alterations.Core.Models` namespace.
* Refactor consumer concatenation logic in MassTransitFeature
Removed the commented-out code that filtered temporary queues, simplifying the concatenation of consumer types with workflow message consumers.
* Refactor whitespace and improve readability
Removed extraneous whitespaces and reformatted the `IsEmpty` property for better code readability. This enhances the code structure without affecting functionality.
* Refactor MassTransitFeature configuration
Moved transport configuration logic into the dedicated `ConfigureInMemoryTransport` method and removed unused usings to simplify the `MassTransitFeature` class setup. This streamlines setting up MassTransit in-memory transport and improves code maintainability.
---------
Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
Co-authored-by: Marius Vasile Vușcan <marius.vuscan@nexxbiz.io>
Added a sequence with WriteLine activity to log processing of each order. Also, ensured the activity execution context properly sets its Tag property when a completion callback is provided.
Refactor the endpoint for listing workflow instances to use a more robust enum parsing method and improve validation. Update models to accept string collections for statuses and sub-statuses, which enables validating and parsing these enums directly within the endpoint.
Refactor the endpoint for listing workflow instances to use a more robust enum parsing method and improve validation. Update models to accept string collections for statuses and sub-statuses, which enables validating and parsing these enums directly within the endpoint.
The FetchProducts.cs and Product.cs files have been removed as they are no longer needed. Additionally, changes in the OrderBatchProcessor.cs and FetchOrders.cs reflect updates to order fetching logic to accommodate these removals.
Extended ModuleExtensions with methods for adding variable types, including with an alias, to aid in workflow variable management and organization. These new methods allow module users to register custom variable types easily and associate them with a category or alias.
Added tests in `Elsa.Workflows.Core.UnitTests` and `Elsa.JavaScript.UnitTests` to ensure unicode string serialization works correctly. Added a shared `UnicodeRangeGenerator` for test data generation and updated project references accordingly. Renamed `WorkflowDefinitionActivityJavaScriptHandlerTests.cs` to `ToJsonTests.cs` to reflect the focused test purpose.
Introduced improved encoding by setting the JavaScriptEncoder to unicode ranges and added necessary using directives. Additionally, the Serialize method is now appropriately marked to indicate its use of code that requires unreferenced code during linking, following best practices for code that may be subject to trimming in a .NET environment.
The update enriches the serializers with Unicode encoding to handle a wider range of characters. Classes such as ConfigurableSerializer, ObjectConverter, and JsonContentFactory have been modified to use JavaScriptEncoder with UnicodeRanges.All, supporting serialization and deserialization of all Unicode characters. Furthermore, any unreferenced code now carries a note for JSON serializer stating that it's incompatible with .NET's trimming feature.
The commit adds a more comprehensive handling of different JsonValueKind values in DefaultExpressionDescriptorProvider.cs. Now `JsonValueKind.Undefined`, `JsonValueKind.Null`, `JsonValueKind.Object`, and `JsonValueKind.Array` are specifically addressed, improving the reliability of JSON manipulation within Elsa workflows.
The version option in the WorkflowDefinitionManager has been updated. Previously it was set to "LatestAndPublished", but this has been changed to "LatestOrPublished", adjusting the way the manager handles workflow versions.
* Refactor search filtering and move ListWorkflowDefinitionsRequest file
Updated the searching mechanism in `WorkflowDefinitionFilter.cs` by validating that Name and Description are not null before performing the search. In `ListWorkflowDefinitionsRequest.cs`, the file was moved from the Responses namespace to Requests and a new property `SearchTerm` was added, allowing filtering of workflow definitions by their name, ID or description.
* Update code style settings for csproj
The .DotSettings file for the project has been adjusted with changes to code naming rules and settings migration. These modifications adjust policies for naming conventions of Instance and Static fields, enhancing code style conformance. Also, an additional settings migration rule has been applied.
* Add 'issue/*' branch to GitHub actions workflow
The GitHub actions workflow has been updated to include the 'issue/*' branch. This ensures that any changes made in the 'issue/*' branches will trigger the workflow and any associated tests or builds, improving the overall continuous integration process.
* Remove Skip and Take methods from SqlServerDialect
The mentioned functions have been removed from SqlServerDialect class in the Elsa.Dapper module. The base class provides the correct default implementation for the SQL Server dialect.
List,Delete, and Revert endpoints for editing endpoints by version were set to allow anonymous, meaning no authorisation policies were applied.
I have changed these to apply permissions as per the rest of the API.