* Add database initialization script and update dependencies Added a script to initialize the 'tracelens' database and modified the Docker setup to include this script. Refactored and improved the ProtoActorFeature class, added OpenTelemetry dependencies, and updated project settings. * Enable OpenTelemetry integration for Proto.Actor Added OpenTelemetry environment configuration details to the README and included the Proto.OpenTelemetry package in the project file. Updated the ProtoActorFeature to apply tracing with OpenTelemetry to WorkflowInstanceActor. * Refactor VariablePersistenceManager to use primary constructor This refactor simplifies the VariablePersistenceManager by moving the storageDriverManager initialization into the primary constructor. It removes the redundant field and constructor, aligning with the concise nature of modern C# syntax, and ensures consistency in accessing the storageDriverManager throughout the class. * Remove unused Open Telemetry code from Program.cs The code for configuring Open Telemetry was commented out but not removed, cluttering the file. This commit cleans up Program.cs by deleting these unused lines, maintaining a cleaner and more readable codebase. * Add metrics and tracing configurations for ProtoActorFeature Introduced methods to enable metrics and tracing in ProtoActorFeature. Removed redundant properties and updated the workflow runtime to utilize the new configurations. * Add Directory.Build.props for shared project settings Introduce Directory.Build.props to centralize common project settings and dependencies. Consolidate target framework, language version, and package references to reduce duplication. Remove redundant property definitions from Elsa.Server.Web.csproj. * Move apps from bundles to apps folder and Elsa module to modules folder
108 lines
4.1 KiB
C#
108 lines
4.1 KiB
C#
using Elsa.EntityFrameworkCore.Extensions;
|
|
using Elsa.EntityFrameworkCore.Modules.Labels;
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
|
using Elsa.Extensions;
|
|
using Elsa.ProtoActor.ProtoBuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using Microsoft.Data.Sqlite;
|
|
using Proto.Cluster.AzureContainerApps;
|
|
using Proto.Cluster.AzureContainerApps.ClusterProviders;
|
|
using Proto.Cluster.AzureContainerApps.Stores.Redis;
|
|
using Proto.Cluster.AzureContainerApps.Utils;
|
|
using Proto.Persistence.Sqlite;
|
|
using Proto.Remote;
|
|
using Proto.Remote.GrpcNet;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var services = builder.Services;
|
|
var configuration = builder.Configuration;
|
|
var sqliteConnectionString = configuration.GetConnectionString("Sqlite")!;
|
|
var redisConnectionString = configuration.GetConnectionString("Redis")!;
|
|
var identitySection = configuration.GetSection("Identity");
|
|
var identityTokenSection = identitySection.GetSection("Tokens");
|
|
var protoActorSection = configuration.GetSection("ProtoActor");
|
|
var protoActorClusterSection = protoActorSection.GetSection("Cluster");
|
|
|
|
// Configure Proto Actor cluster provider services.
|
|
services.AddAzureContainerAppsProvider(
|
|
ArmClientProviders.DefaultAzureCredential,
|
|
sc => sc.AddRedisClusterMemberStore(redisConnectionString),
|
|
options => protoActorClusterSection.GetSection("AzureContainerApps").Bind(options));
|
|
|
|
// Add Elsa services.
|
|
services
|
|
.AddElsa(elsa => elsa
|
|
.AddActivitiesFrom<Program>()
|
|
.UseIdentity(identity =>
|
|
{
|
|
identity.TokenOptions = options => identityTokenSection.Bind(options);
|
|
identity.UseConfigurationBasedUserProvider(options => identitySection.Bind(options));
|
|
identity.UseConfigurationBasedApplicationProvider(options => identitySection.Bind(options));
|
|
identity.UseConfigurationBasedRoleProvider(options => identitySection.Bind(options));
|
|
})
|
|
.UseDefaultAuthentication()
|
|
.UseWorkflowManagement(management =>
|
|
{
|
|
// Use EF core for workflow definitions and instances.
|
|
management.UseEntityFrameworkCore(m => m.UseSqlite(sqliteConnectionString));
|
|
})
|
|
.UseWorkflowRuntime(runtime =>
|
|
{
|
|
// Use EF core for triggers and bookmarks.
|
|
runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString));
|
|
|
|
// Use Proto.Actor for workflow execution.
|
|
runtime.UseProtoActor(protoActor =>
|
|
{
|
|
var advertisedHost = IPUtils.FindSmallestIpAddress().ToString();
|
|
|
|
protoActor.CreateClusterProvider = sp => sp.GetRequiredService<AzureContainerAppsProvider>();
|
|
|
|
protoActor.ConfigureRemoteConfig = _ => GrpcNetRemoteConfig
|
|
.BindTo(advertisedHost)
|
|
.WithProtoMessages(EmptyReflection.Descriptor)
|
|
.WithProtoMessages(SharedReflection.Descriptor)
|
|
.WithLogLevelForDeserializationErrors(LogLevel.Critical)
|
|
.WithRemoteDiagnostics(true); // required by proto.actor dashboard
|
|
|
|
protoActor.PersistenceProvider = _ => new SqliteProvider(new SqliteConnectionStringBuilder(sqliteConnectionString));
|
|
});
|
|
})
|
|
.UseLabels(labels => labels.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)))
|
|
.UseScheduling()
|
|
.UseWorkflowsApi(api => api.AddFastEndpointsAssembly<Program>())
|
|
.UseJavaScript()
|
|
.UseLiquid()
|
|
.UseHttp()
|
|
);
|
|
|
|
services.AddHealthChecks();
|
|
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
|
|
|
|
// Configure middleware pipeline.
|
|
var app = builder.Build();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
// CORS.
|
|
app.UseCors();
|
|
|
|
// Health checks.
|
|
app.MapHealthChecks("/");
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
// Elsa API endpoints for designer.
|
|
app.UseWorkflowsApi();
|
|
|
|
// Captures unhandled exceptions and returns a JSON response.
|
|
app.UseJsonSerializationErrorHandler();
|
|
|
|
// Elsa HTTP Endpoint activities
|
|
app.UseWorkflows();
|
|
|
|
// Run.
|
|
app.Run(); |