Commit graph

84 commits

Author SHA1 Message Date
Sipke Schoorstra d19fc6e976
Enable optional OpenTelemetry tracing configuration.
Added a feature flag (`useOtel`) to conditionally enable OpenTelemetry tracing. This allows developers to toggle tracing for debugging or testing without affecting the default behavior.
2025-03-08 22:03:13 +01:00
Sipke Schoorstra 13d7e91e0d
Remove agent-related configurations and dependencies.
This commit removes the "Agents" configuration section, related API keys, services, and persistence logic across the codebase. Unused agent-related NuGet packages and code references were also eliminated to simplify the project and focus on core functionality.
2025-03-02 16:08:51 +01:00
Sipke Schoorstra 42ab1a8944
Merge branch 'main' into feat/4832 2025-03-02 14:50:21 +01:00
Sipke Schoorstra 265254ec5b
Merge pull request #6427 from elsa-workflows/feat/otel-error-codes
Add OpenTelemetry error span handling infrastructure
2025-02-25 15:42:24 +01:00
Sipke Schoorstra 43157fb6d6
Remove Azure Service Bus integration and related tests
Deleted the entire Azure Service Bus module, including activities, configurations, tests, and supporting code. This removal eliminates features like message handling workflows, queue/topic providers, and unit testing utilities for Azure Service Bus.
2025-02-23 23:43:15 +01:00
Sipke Schoorstra 33d291cfcc
Add webhook configuration and support to Elsa Server
Integrated webhook sinks via appsettings.json for handling "Run Task" events. Enabled webhook functionality in the application pipeline and added the necessary project reference for Elsa.Webhooks. This enhances event-driven capabilities and improves extensibility.
2025-02-23 21:40:15 +01:00
Sipke Schoorstra 3beedb9ec0
Refactor activity execution state tracking
Introduce `IsExecuting` flag to explicitly track activity execution state, improving clarity and control over workflow activity handling. Adjust scheduling intervals and add concurrency handling for database updates to enhance reliability and performance in interrupted workflows.
2025-02-22 19:45:44 +01:00
Sipke Schoorstra 037b82dc49
Update inactivity threshold and adjust related timings
Renamed 'WorkflowLivenessThreshold' to 'InactivityThreshold' for clarity and updated its usage across affected files. Adjusted timings for workflow restarts and delays to improve consistency, including increasing task delay and updating scheduler intervals. These changes enhance readability and align with revised task execution timelines.
2025-02-22 16:22:33 +01:00
Sipke Schoorstra 0a21b5201a
Add workflow restart functionality for handling interruptions
Introduced a mechanism to identify and restart interrupted workflows. This includes a new `IWorkflowRestarter` contract, its default implementation, and a recurring task for handling restarts. Additionally, updated configurations and added extensions to improve workflow instance filtering and liveness tracking.
2025-02-22 15:10:52 +01:00
Sipke Schoorstra 7261cd8443
Add OpenTelemetry tracing and error handling enhancements
Introduced OpenTelemetry tracing with AlwaysOnSampler and console exporter, integrated into the Elsa framework. Added error handling capabilities via custom `IErrorSpanHandler` implementations. Updated project dependencies to include OpenTelemetry-related packages.
2025-02-20 20:34:07 +01:00
Sipke Schoorstra 6bb83c538a
Merge pull request #6413 from CODEdire/main
Add IBusRegistrationContext to Transport Configuration Actions
2025-02-19 15:25:54 +01:00
Sipke Schoorstra 5dc9d4f40f
Disable multitenancy in Elsa.Server.Web
Multitenancy has been turned off by setting `useMultitenancy` to `false`. This change might simplify the current configuration and reduce complexity for single-tenant use cases.
2025-02-18 19:44:31 +01:00
Thomas Yates c12982dd88 Added minor changes to MassTransitFeature to start using MassTransitOptions as the source for the prefetch count as the new source for this information is in the base MassTransitOptions. Created a new ConfigureTransportBus in both RabbitMQ and Azure Service Bus to support the context in the configuration action. Marked the old ConfigureServiceBus to persuade migration over to the contextual action. Currently, it will run the legacy action first and then the new contextual action second. The Elsa.Server.Web was also updated to use the new ConfigureTransportBus. 2025-02-15 13:04:45 -06:00
Sipke Schoorstra 58f0c48f66 Refactor workflow management to utilize mediator requests.
Replaced direct store interactions in workflow management with mediator-based requests using `IMediator`, improving consistency and modularity. Added new handlers and requests for workflow definition operations, and updated existing services to align with mediator patterns.
2025-02-12 22:08:09 +01:00
Sipke Schoorstra d83bb3b834 Add customizable tenant header support for HTTP routing
Introduced `MultitenancyHttpOptions` to configure the tenant header name used for HTTP routing. Updated `HeaderTenantResolver` to utilize this option and modified the server setup to allow overriding the default header name. This enables more flexible multitenancy configurations.
2025-02-09 08:24:55 +01:00
Matt 1029580712
Merge branch 'main' into main 2025-02-06 21:20:12 +00:00
Sipke Schoorstra aa09708268
Merge pull request #6343 from elsa-workflows/feature/4835
Controlled Commit States Feature Implementation
2025-02-06 16:44:48 +01:00
Sipke Schoorstra 6c0d1ea66c Refactor database setup and EFCore provider configurations.
Revised database initialization scripts to better handle Postgres and Oracle environments, introduced schema-specific configurations for Oracle EFCore, and cleaned up obsolete or redundant entity model setup. Streamlined project structure by relocating and renaming files for SQLite and Oracle EFCore setups, improving maintainability and readability.
2025-01-31 19:51:24 +01:00
Sipke Schoorstra 26e2b1fb56 Add Oracle database support to the project
This commit introduces Oracle database integration by adding necessary configurations, entity mappings, and Docker Compose setup. Oracle-specific mappings ensure compatibility with NCLOB for large data handling. The changes also include updates to appsettings, enum for SqlDatabaseProvider, and project references to support Oracle.
2025-01-31 00:31:09 +01:00
Sipke Schoorstra 01a41f6d62 Refactor commit strategies to use AddStandardStrategies method
Extracted commit strategies setup into a reusable AddStandardStrategies method for better code clarity and modularity. Simplified PeriodicWorkflowStrategy by replacing the factory method with a constructor-based interval initialization. These changes improve maintainability and reduce redundancy across the codebase.
2025-01-30 18:10:38 +01:00
Sipke Schoorstra ef97ef415f Update strategy registration methods to use 'Add'
Replaced 'RegisterStrategy' with 'Add' in strategy registration methods for both workflows and activities. This simplifies the naming, enhances consistency, and aligns with modern API design principles.
2025-01-30 15:20:51 +01:00
Sipke Schoorstra e151810600 Refactor commit strategy architecture for flexibility.
Replaces direct strategy registration with metadata-based registrations, introducing `ObjectRegistration`, `CommitStrategyMetadata`, and associated helpers. Updates existing strategies and APIs to use the new metadata-driven approach, improving extensibility and maintainability.
2025-01-30 15:14:58 +01:00
Sipke Schoorstra ce859efc4a Refactor commit state handling with a strategy-based approach
Replaced the legacy commit state behavior enums and options with a flexible, strategy-based system for activities and workflows. Introduced new interfaces, models, and strategies to enable fine-grained control of commit state logic. Updated related code to integrate the new commit strategies, ensuring modular and extensible commit handling.
2025-01-30 11:59:47 +01:00
Sipke Schoorstra d500817468 Simplify DbContext creation with ActivatorUtilities.
Replaced Activator.CreateInstance with ActivatorUtilities.CreateInstance to streamline the DbContext instantiation. This improves dependency injection support and ensures better compatibility with service provider configurations.
2025-01-29 19:03:59 +01:00
Sipke Schoorstra 3262e7493f Enable variable copying in Elsa.Server.Web configuration
Updated the `disableVariableCopying` flag to `false` in `Program.cs`. This change allows variables to be copied, potentially addressing scenarios where variable duplication is needed. Ensure to test for any side effects this might introduce.
2025-01-21 19:29:56 +01:00
Sipke Schoorstra a7360ed922 Add option to disable variable copying in Jint engine
Introduce a `DisableVariableCopying` option to improve performance by preventing workflow variables from being copied into the Jint engine or back into the workflow context. Updated related logic to honor this setting and ensure compatibility with existing behavior.
2025-01-21 19:11:31 +01:00
Sipke Schoorstra efd114944c Refactor and enhance JavaScript and object conversions.
Replaced InputProxy with alternative implementations, adding flexibility to handle inputs. Introduced a JsonElementConverter to deepen JavaScript and JSON element integration. Enhanced testing and object conversion logic, improving type handling and support for complex JSON scenarios.
2025-01-14 23:16:29 +01:00
Sipke Schoorstra 60db7cb964 Disable multitenancy and streamline NuGet publishing workflow.
Multitenancy is now disabled by default in `Program.cs` to simplify configuration. Additionally, removed the `publish_preview_nuget` step and refined conditions for `publish_nuget` to improve the workflow and align with the release process.
2025-01-11 19:55:06 +01:00
Sipke Schoorstra 48c453d153 Enable customizable Hangfire job storage and deprecate obsolete APIs.
Added support for configuring Hangfire job storage per database provider, including PostgreSql, SQLite, and SQL Server. Introduced new methods for flexible Hangfire setup, while marking older APIs and storage configuration extensions as obsolete. Refactored related configurations for streamlined and centralized job scheduling logic.
2025-01-11 19:12:38 +01:00
Sipke Schoorstra 03344bdc20 Adjust caching options and disable secrets usage
Enabled CachingOptions configuration and set a 1-day cache duration while disabling the use of secrets. These changes improve caching behavior and streamline application setup by avoiding secret dependencies.
2025-01-10 10:09:35 +01:00
Sipke Schoorstra 288097d503 Simplify and optimize workflow instance creation.
Replaced asynchronous instance creation methods with streamlined synchronous alternatives where applicable. Introduced `CreateAndCommitWorkflowInstanceAsync` for combined instantiation and persistence, along with a separate `CreateWorkflowInstance` method for non-committal instantiation. Refactored related code to improve readability, maintainability, and runtime performance.
2025-01-09 19:34:53 +01:00
Sipke Schoorstra 5e2644f751 Refactor workflow runtime structure and update handlers.
Moved `CancelWorkflowsCommandHandler` to the shared runtime module. Updated related project references, features, and configurations accordingly. Improved `WorkflowInstance` actor to save state using `IWorkflowInstanceManager`.
2025-01-02 11:43:21 +01:00
Sipke Schoorstra 6c0f7a48e7 Refactor recurring tasks scheduling logic.
Removed `ConfigureRecurringTasksScheduleStartupTask` and moved its functionality into `RecurringTaskScheduleManager`. Simplified recurring task configuration and streamlined dependencies, improving maintainability. Added retention policies to `Elsa.Server.Web`.
2025-01-02 11:11:42 +01:00
Matthew Knibbs c4e04c4434 Adds SQL Activities. Includes implimentations for MS SQL Server, PostgreSql, MySql and Sqlite. 2025-01-01 23:14:09 +00:00
Sipke Schoorstra 4ed58c67e6 Enable primitive collections and refactor MySQL EF options.
Added support for primitive collections and parameterized collection translation in MySQL EF configurations. Removed redundant `EnablePrimitiveCollectionsSupport` calls in program configuration to centralize the behavior.
2024-12-28 20:06:33 +01:00
Sipke Schoorstra 021795f53a Enable MySQL primitive collections support and update configs
Add support for EF Core primitive collections in MySQL by specifying `EnablePrimitiveCollectionsSupport()` in the DbContext configuration. Updated the Docker Compose file to rename the MySQL volume and adjusted appsettings.json to include a MySQL connection string and set MySQL as the default database provider.
2024-12-28 18:56:29 +01:00
Sipke Schoorstra 4793c6eac5 Refactor ProtoActor and workflow testing logic
Reorganized ProtoActor configuration to be conditionally applied based on runtime settings. Updated test workflows to simplify signal handling and improved test structure by introducing scoped dependencies and removing unused event subscriptions.
2024-12-14 09:59:29 +01:00
Sipke Schoorstra c3e5624321 Regenerate 3.3 EF Core migrations for backwards compat with 3.2 2024-12-12 22:24:39 +01:00
Robin Sue 4d6b7a17fb Add .NET 9.0 target 2024-12-10 21:06:42 +01:00
Sipke Schoorstra 60f88e4704 Disable SignalR in Server And Studio project 2024-12-10 20:21:08 +01:00
Sipke Schoorstra a2448523a9
Fix race condition and add rate limiting to bookmark queue processing (#6187)
* Fix race condition and add rate limiting to bookmark queue processing

Introduce rate-limited function invocation for bookmark queue processing using ThrottleDebounce library to optimize performance. Update related classes and interfaces to support asynchronous and cancellation-aware operations, improving system responsiveness. Adjust logging to provide more detailed information during bookmark queue handling.

* Enable workflows on bug branches

This change updates the GitHub Actions workflow configuration to trigger on branches with the 'bug/*' pattern. This allows for automated actions on bug fix branches alongside the main branch, improving development and testing processes.
2024-12-07 17:34:10 +01:00
Sipke Schoorstra 692937d7d7
Enhance Multitenancy with Runtime Tenant Management and Task Handling (#6173)
* Work in progress: Add DefaultTenantService for tenant management

Introduce `DefaultTenantService` and its corresponding interface `ITenantService` to manage tenant operations such as finding, getting, and listing tenants. Update `MultitenantBackgroundService` to utilize `DefaultTenantService` for handling tenant lifecycle events. This enhancement standardizes tenant operations and improves the maintainability of the multitenancy feature.

* WIP

* Add multitenancy event handlers and task interfaces

Implemented new interfaces IBackgroundTaskStarter and ITaskExecutor to manage task lifecycle events efficiently. Introduced new classes such as RunBackgroundTasks, RunStartupTasks, and StartRecurringTasks for handling tenant activation and deactivation events. Modified TaskExecutor to implement these interfaces and adjusted tenant registration logic to invoke these new handlers.

* Refactor multitenancy and task management services.

Remove background and recurring task runners, and integrate tenant activation and deactivation into the multitenancy feature. Enable multitenancy in the server application and create a new service for tenant activation and deactivation. This refactor simplifies the management of tenant-specific tasks and enhances the modularity of the platform.

* Refactor background service to use startup tasks

Replaced hosted service implementation with startup tasks for executing multi-tenant tasks and EF Core migrations. Introduced `PriorityAttribute` to manage task execution order, ensuring migrations run before other services that require database access. This simplifies tenant activation with an ordered task execution and removes redundant classes.

* Refactor MultitenancyFeature service registrations

Reorganized service registrations for better clarity and maintainability. Changed the registration of some services to use factory delegates for retrieving existing services to ensure correct dependencies. This refactor improves the flexibility of the tenant lifecycle event handling.

* Update V3_3 migration files

* Add tenant management endpoints and enhance tenant handling

Implemented tenant management endpoints including Add, Get, List, and Update. Enhanced tenant handling by introducing configuration and store-based providers, and improved error logging for tenant updates. Adjusted various internal functionalities to better support multitenancy features through different persistence providers.

* Implement tenant deletion endpoint and refactor migration setup.

Introduce a new API endpoint to handle tenant deletions while providing appropriate responses based on successful or unsuccessful attempts. Refactor migration handling by replacing startup tasks with hosted services across various modules to streamline the migration execution process.

* Add and integrate ConfigurationJsonConverter

Introduce a `ConfigurationJsonConverter` to handle JSON serialization and deserialization of `IConfiguration` objects. This change centralizes configuration serialization logic, leading to cleaner and more maintainable code. Updated various parts of the codebase to use the new serialization utility, ensuring a consistent approach throughout the application.

* Refactor JSON conversion and update tenant endpoint.

Removed unused workflow references and streamlined JSON handling in `ConfigurationJsonConverter`. Simplified tenant ID handling by removing `IIdentityGenerator` and setting a default value for `UpdatedTenant.Id`.

* Add logging for cancelled recurring tasks

Integrated ILogger to log information when a recurring task is canceled due to an OperationCanceledException. This change enhances troubleshooting by providing clearer insights into task cancellations and their underlying reasons, improving maintainability and observability of the task execution process.

* Disable multitenancy support and adjust default Tenant ID.

Multitenancy is now disabled by setting 'useMultitenancy' to false in the configuration. Additionally, the default Tenant's ID has been changed from null to an empty string to prevent potential null reference issues.

* Remove MultitenantHostedService abstraction file

The MultitenantHostedService.cs file was removed as it is no longer necessary. Its responsibilities have likely been refactored or integrated into another service, indicating a simplification or restructuring of the multitenancy handling in the codebase.

* Rename PriorityAttribute to OrderAttribute for clarity.

This change improves the clarity of the code by renaming PriorityAttribute to OrderAttribute, reflecting its actual purpose. All occurrences of the attribute in the codebase have been updated accordingly to maintain consistency. This makes the intent of the code more understandable for future maintenance and development.

* Fix message key retrieval in ProduceMessage activity

Update the ProduceMessage activity to use GetOrDefault for retrieving the message key. This change ensures that a null key is used if no explicit key is provided or if the key is empty or whitespace, preventing potential errors during message production.

* Refactor multitenancy and scheduling services.

Removed DefaultTenantContextInitializer interface and class, refactored tenant activation/deactivation to use try-catch logging, and updated tenant context handling to use IDisposable for context push. New activities and workflows added in Elsa.Server.Web, and scheduling services enhanced to schedule jobs with explicit job keys and groups. Also, adjusted configurations to enable multitenancy, providing improved maintainability and flexibility.

* Remove Example1 activities and disable multitenancy

Deleted Example1Activity, Example1Workflow, and FirstActivity classes to clean up unused code and simplify the codebase. Disabled multitenancy by setting useMultitenancy to false, likely to streamline configuration and resource utilization.

* Fix and normalize URL path concatenation.

Ensure that the base URLs in both base path providers consistently end with a forward slash. This normalization prevents potential issues with endpoint routing and path concatenation, improving overall URL construction robustness.
2024-12-03 15:07:55 +01:00
Sipke Schoorstra 844af43f39 Refactor database provider configuration logic
Moved SQL Database Provider initialization from a constant to configuration-based dynamic parsing. Enhanced logging configuration for specific components and removed unused tenant and Kafka configurations in appsettings.json for clarity and efficiency.
2024-12-01 09:15:42 +01:00
Sipke Schoorstra 6022df165c
Kafka: Update ProduceMessage activity with support for specifying a Key (#6166)
* Add Key to Kafka ProduceMessage activity

Deleted unnecessary Consumer and Producer workflow classes and the OrderReceived message class to clean up code. Refactored Kafka producer interface and implementation to include message keys for improved message handling. Updated configuration to enable Kafka and removed unused service registrations.

* Add Kafka factory classes and type alias registry

Introduce GenericConsumerFactory and GenericProducerFactory for handling Kafka consumer and producer creation. Implement a TypeAliasRegistry to manage type aliases, enabling cleaner configuration through aliases. Update the OrderReceived message class and ensure better integration with the server web program via these new components.

* Handle empty topics and predicates in Kafka worker.

Ensure the Kafka consumer unsubscribes when no topics are available to subscribe to. Additionally, add a check to handle empty string values for predicates, allowing workflow triggers to proceed in this scenario.

* Disable Kafka usage in Elsa Server Web configuration

Kafka has been disabled in the current configuration by setting the useKafka constant to false. This change might be intended to switch to a different messaging system or to simplify the current setup by removing unnecessary services. Ensure that any dependencies on Kafka are handled elsewhere in the application.
2024-11-29 19:49:31 +01:00
Sipke Schoorstra c5ce511e8b Switch to Distributed runtime and MassTransit caching.
Updated the workflow runtime to Distributed and the distributed caching transport to MassTransit for better scalability and performance. Also, disabled the use of secrets to enhance security and simplify configuration.
2024-11-26 21:21:26 +01:00
Sipke Schoorstra d74159d594 Add bookmark queue purging and ExecuteWorkflow stimulus
Introduce BookmarkQueuePurgeOptions and ExecuteWorkflowStimulus classes for managing workflow queue purging and stimulus handling. Implement related handler and activity modifications to support waiting for child workflows and purging old bookmark queue entries.
2024-11-26 20:35:41 +01:00
Sipke Schoorstra 90644f04f0 Disable Kafka in server configuration
This change updates the server configuration to disable Kafka by setting `useKafka` to false. Additionally, an unused import statement for `Elsa.EntityFrameworkCore` has been removed to clean up the code.
2024-11-22 20:48:17 +01:00
Sipke Schoorstra b534b42a60
Update Kafka Module: Add Support for Configuring Consumer and Producer Factories (#6139)
* Enable Kafka Worker Factory and Refactor Worker Implementation

Introduce a flexible worker factory mechanism allowing custom worker creation with DefaultWorkerFactory as the initial implementation. Enhance Worker class to be generic, remove manual consumer configuration, and streamline message processing logic, improving code maintainability and extensibility.

* Refactor Kafka configuration properties

Renamed configuration properties in Consumer and Producer entities. Updated references in the codebase to use the new `Config` property instead of `ConsumerConfig` and `BootstrapServers`. Adjusted appsettings.json to match the new configuration schema.

* Add Kafka producer and consumer implementation

Implemented classes and interfaces to handle Kafka producers and consumers, including `ProducerProxy`, `ConsumerProxy`, and related context classes and factories. Refactored existing code to utilize these new implementations, replacing worker terminology with consumer and addressing context-specific fields.

* Remove redundant code in DefaultConsumerFactory and SendMessage

Removed commented-out unused return statement in DefaultConsumerFactory. Also eliminated explicit producer.Dispose() call in SendMessage, as the 'using' statement already handles resource cleanup.

* Add ExpandoObject producer and consumer factories

Replaced DefaultSerializers with new JsonSerializer and JsonDeserializer classes. Introduced ExpandoObjectProducerFactory and ExpandoObjectConsumerFactory to handle dynamic types. Updated workflow and configuration to use the new factories.

* Refactor bookmark processing and manage worker subscriptions

Refactored bookmark processing logic to utilize extension methods. Optimized worker subscriptions by centralizing topic subscription management and added logging for subscribed topics. This improves maintainability and clarity of the codebase.

* Refactor worker creation to use ActivatorUtilities

Updated WorkerManager to instantiate workers using ActivatorUtilities for better dependency injection support. This enhances code readability and maintains consistency with the service provider approach used throughout the codebase.
2024-11-22 20:07:14 +01:00
Sipke Schoorstra 1ed6695872
Add ExecuteWorkflow activity (#6134)
* Add ExecuteWorkflow activity and enable multitenancy

Introduced the ExecuteWorkflow activity to create and execute workflow instances, and updated runtime settings to use ProtoActor for distributed caching transport. Enabled multitenancy for the Elsa Server Web application.

* Namespace renames (#6135)

* Create ExecuteWorkflows tests and workflows

Add unit tests for executing workflows, including MainWorkflow and SubroutineWorkflow. Also, rename ExecutedWorkflowResult to ExecuteWorkflowResult in the runtime module for consistency.

* Add output definitions to WorkflowBuilder

Refactored the `WithInput` method for clarity and added multiple `WithOutput` methods to support different ways of defining workflow outputs. These changes enhance the flexibility and readability of the workflow configuration process by providing a consistent API for input and output definitions.

* Refactor namespaces in component tests

Updated namespaces from Helpers to specific contexts like Fixtures, Abstractions, Consumers, Decorators, etc., to improve code organization and readability. This change affects multiple files across different test scenarios and modules.

* Disable RabbitMQ and multitenancy, rename test class

Commented out RabbitMQ usage in WorkflowServer.cs to focus on other transports. Changed multitenancy flag to false in Program.cs. Renamed DispatchWorkflowsTests to ExecuteWorkflowsTests for clarity.
2024-11-21 16:44:25 +01:00
Sipke Schoorstra 984908a279 Update base URL, package versions, and Kafka usage
Changed the default base URL in _Host.cshtml for local development. Upgraded Elsa.Studio package versions to 3.3.0-preview.630. Disabled Kafka usage in Program.cs.
2024-11-19 11:33:42 +01:00