From 25e36c3467200b7abaeffd56cb73fa5793a62d5f Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 12 May 2025 14:13:01 +0200 Subject: [PATCH] Remove unused activities, messages, and dependencies Deleted unused custom activity classes, message types, and related registrations from the codebase. Also cleaned up surplus library references and configurations from Program.cs to streamline and simplify the project. --- .../Elsa.Server.Web/Activities/CustomDelay.cs | 19 -------------- .../Elsa.Server.Web/Activities/CustomEvent.cs | 18 ------------- .../Activities/CustomHttpEndpoint.cs | 23 ----------------- .../Elsa.Server.Web/Activities/CustomTimer.cs | 18 ------------- .../Elsa.Server.Web/Messages/OrderReceived.cs | 6 ----- src/apps/Elsa.Server.Web/Program.cs | 18 ------------- src/apps/Elsa.Server.Web/SampleWorkflow.cs | 25 ------------------- src/apps/Elsa.Server.Web/SlowActivity.cs | 15 ----------- 8 files changed, 142 deletions(-) delete mode 100644 src/apps/Elsa.Server.Web/Activities/CustomDelay.cs delete mode 100644 src/apps/Elsa.Server.Web/Activities/CustomEvent.cs delete mode 100644 src/apps/Elsa.Server.Web/Activities/CustomHttpEndpoint.cs delete mode 100644 src/apps/Elsa.Server.Web/Activities/CustomTimer.cs delete mode 100644 src/apps/Elsa.Server.Web/Messages/OrderReceived.cs delete mode 100644 src/apps/Elsa.Server.Web/SampleWorkflow.cs delete mode 100644 src/apps/Elsa.Server.Web/SlowActivity.cs diff --git a/src/apps/Elsa.Server.Web/Activities/CustomDelay.cs b/src/apps/Elsa.Server.Web/Activities/CustomDelay.cs deleted file mode 100644 index 700f8d5f4..000000000 --- a/src/apps/Elsa.Server.Web/Activities/CustomDelay.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Elsa.Extensions; -using Elsa.Workflows; - -namespace Elsa.Server.Web.Activities; - -public class CustomDelay : Activity -{ - protected override ValueTask ExecuteAsync(ActivityExecutionContext context) - { - context.DelayFor(TimeSpan.FromSeconds(5), OnDelayElapsedAsync); - return default; - } - - private async ValueTask OnDelayElapsedAsync(ActivityExecutionContext context) - { - Console.WriteLine("Delay elapsed"); - await context.CompleteActivityAsync(); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/Activities/CustomEvent.cs b/src/apps/Elsa.Server.Web/Activities/CustomEvent.cs deleted file mode 100644 index a1f40ad6c..000000000 --- a/src/apps/Elsa.Server.Web/Activities/CustomEvent.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Workflows; -using Elsa.Workflows.Runtime.Activities; - -namespace Elsa.Server.Web.Activities; - -public class CustomEvent : EventBase -{ - protected override string GetEventName(ExpressionExecutionContext context) - { - return "MyEvent"; - } - - protected override void OnEventReceived(ActivityExecutionContext context, object? eventData) - { - Console.WriteLine("Event received with data: " + eventData); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/Activities/CustomHttpEndpoint.cs b/src/apps/Elsa.Server.Web/Activities/CustomHttpEndpoint.cs deleted file mode 100644 index a1ac1154d..000000000 --- a/src/apps/Elsa.Server.Web/Activities/CustomHttpEndpoint.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Elsa.Http; -using Elsa.Http.Extensions; -using Elsa.Workflows; - -namespace Elsa.Server.Web.Activities; - -public class CustomHttpEndpoint : HttpEndpointBase -{ - protected override HttpEndpointOptions GetOptions() - { - return new() - { - Path = "my-path", - Methods = [HttpMethods.Get], - }; - } - - protected override async ValueTask OnHttpRequestReceivedAsync(ActivityExecutionContext context, HttpContext httpContext) - { - httpContext.Response.StatusCode = 200; - await httpContext.Response.WriteAsync("Hello World", context.CancellationToken); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/Activities/CustomTimer.cs b/src/apps/Elsa.Server.Web/Activities/CustomTimer.cs deleted file mode 100644 index 3a9cdfdef..000000000 --- a/src/apps/Elsa.Server.Web/Activities/CustomTimer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Scheduling.Activities; -using Elsa.Workflows; - -namespace Elsa.Server.Web.Activities; - -public class CustomTimer : TimerBase -{ - protected override TimeSpan GetInterval(ExpressionExecutionContext context) - { - return TimeSpan.FromSeconds(5); - } - - protected override void OnTimerElapsed(ActivityExecutionContext context) - { - Console.WriteLine("Timer elapsed"); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/Messages/OrderReceived.cs b/src/apps/Elsa.Server.Web/Messages/OrderReceived.cs deleted file mode 100644 index 32151ae81..000000000 --- a/src/apps/Elsa.Server.Web/Messages/OrderReceived.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.Server.Web.Messages; - -public class OrderReceived -{ - public string OrderId { get; set; } = null!; -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/Program.cs b/src/apps/Elsa.Server.Web/Program.cs index f5b998778..28fb61c49 100644 --- a/src/apps/Elsa.Server.Web/Program.cs +++ b/src/apps/Elsa.Server.Web/Program.cs @@ -5,11 +5,9 @@ using Elsa.Caching.Options; using Elsa.Common.Codecs; using Elsa.Common.DistributedHosting.DistributedLocks; using Elsa.Common.RecurringTasks; -using Elsa.Common.Serialization; using Elsa.Dapper.Extensions; using Elsa.Dapper.Services; using Elsa.DropIns.Extensions; -using Elsa.EntityFrameworkCore; using Elsa.EntityFrameworkCore.Extensions; using Elsa.EntityFrameworkCore.Modules.Alterations; using Elsa.EntityFrameworkCore.Modules.Identity; @@ -21,7 +19,6 @@ using Elsa.Extensions; using Elsa.Features.Services; using Elsa.Identity.Multitenancy; using Elsa.Kafka; -using Elsa.Kafka.Factories; using Elsa.MassTransit.Extensions; using Elsa.MongoDb.Extensions; using Elsa.MongoDb.Modules.Alterations; @@ -30,7 +27,6 @@ using Elsa.MongoDb.Modules.Management; using Elsa.MongoDb.Modules.Runtime; using Elsa.MongoDb.Modules.Tenants; using Elsa.OpenTelemetry.Middleware; -using Elsa.Resilience.Extensions; using Elsa.Retention.Extensions; using Elsa.Retention.Models; using Elsa.Secrets.Extensions; @@ -39,7 +35,6 @@ using Elsa.Secrets.Persistence; using Elsa.Server.Web; using Elsa.Server.Web.Extensions; using Elsa.Server.Web.Filters; -using Elsa.Server.Web.Messages; using Elsa.Tenants.AspNetCore; using Elsa.Tenants.Extensions; using Elsa.Workflows; @@ -47,9 +42,7 @@ using Elsa.Workflows.Api; using Elsa.Workflows.CommitStates.Strategies; using Elsa.Workflows.IncidentStrategies; using Elsa.Workflows.LogPersistence; -using Elsa.Workflows.Management; using Elsa.Workflows.Management.Stores; -using Elsa.Workflows.Memory; using Elsa.Workflows.Options; using Elsa.Workflows.Runtime.Distributed.Extensions; using Elsa.Workflows.Runtime.Options; @@ -65,11 +58,7 @@ using JetBrains.Annotations; using Medallion.Threading.FileSystem; using Medallion.Threading.Postgres; using Medallion.Threading.Redis; -using Microsoft.Data.Sqlite; using Microsoft.Extensions.Options; -using OpenTelemetry; -using OpenTelemetry.Exporter; -using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; using OpenTelemetry.Trace; @@ -126,10 +115,6 @@ var distributedLockProviderName = configuration.GetSection("Runtime:DistributedL var appRole = Enum.Parse(configuration["AppRole"] ?? "Default"); var sqlDatabaseProvider = Enum.Parse(configuration["DatabaseProvider"] ?? "Sqlite"); -// Optionally create type aliases for easier configuration. -TypeAliasRegistry.RegisterAlias("OrderReceivedProducerFactory", typeof(GenericProducerFactory)); -TypeAliasRegistry.RegisterAlias("OrderReceivedConsumerFactory", typeof(GenericConsumerFactory)); - if (useManualOtelInstrumentation) { services.AddOpenTelemetry() @@ -329,7 +314,6 @@ services management.SetDefaultLogPersistenceMode(LogPersistenceMode.Inherit); management.UseReadOnlyMode(useReadOnlyMode); - management.AddVariableTypeAndAlias("Application"); }) .UseWorkflowRuntime(runtime => { @@ -445,7 +429,6 @@ services options.AllowClrAccess = true; options.DisableWrappers = disableVariableWrappers; options.DisableVariableCopying = disableVariableCopying; - options.RegisterType(); options.ConfigureEngine(engine => { engine.Execute("function greet(name) { return `Hello ${name}!`; }"); @@ -546,7 +529,6 @@ services elsa.UseMassTransit(massTransit => { massTransit.DisableConsumers = appRole == ApplicationRole.Api; - massTransit.AddMessageType(); if (massTransitBroker == MassTransitBroker.AzureServiceBus) { diff --git a/src/apps/Elsa.Server.Web/SampleWorkflow.cs b/src/apps/Elsa.Server.Web/SampleWorkflow.cs deleted file mode 100644 index 8c8ff1507..000000000 --- a/src/apps/Elsa.Server.Web/SampleWorkflow.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Activities; -using Elsa.Extensions; -using Elsa.Workflows.CommitStates.Strategies; - -namespace Elsa.Server.Web; - -public class SampleWorkflow : WorkflowBase -{ - protected override void Build(IWorkflowBuilder builder) - { - builder.WorkflowOptions.CommitStrategyName = "Every 10 seconds"; - builder.Root = new Sequence - { - Activities = - { - new WriteLine("Commit before executing").SetCommitStrategy(nameof(ExecutingActivityStrategy)), - new WriteLine("Commit after executing").SetCommitStrategy(nameof(ExecutedActivityStrategy)), - new WriteLine("Commit before & after executing").SetCommitStrategy(nameof(CommitAlwaysActivityStrategy)), - new WriteLine("Commit only based on the workflow commit options").SetCommitStrategy(null), - new WriteLine("Never commit the workflow when this activity is about to execute or has executed").SetCommitStrategy(nameof(CommitNeverActivityStrategy)), - } - }; - } -} \ No newline at end of file diff --git a/src/apps/Elsa.Server.Web/SlowActivity.cs b/src/apps/Elsa.Server.Web/SlowActivity.cs deleted file mode 100644 index 31bb11783..000000000 --- a/src/apps/Elsa.Server.Web/SlowActivity.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Attributes; - -namespace Elsa.Server.Web; - -[Activity(Kind = ActivityKind.Task)] -public class SlowActivity : CodeActivity -{ - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - Console.WriteLine("Starting..."); - await Task.Delay(TimeSpan.FromSeconds(45)); - Console.WriteLine("Done."); - } -} \ No newline at end of file