* Implement log persistence strategy management Added interfaces, services, and strategies for log persistence. Introduced new endpoint to list available log persistence strategies. Updated configurations and dependency injections accordingly. * Refactor log record methods to asynchronous Updated methods for extracting and persisting log records to be asynchronous, enhancing performance and scalability. This change includes modifying interfaces and implementations for better async support in workflow execution logging. * Remove commented code * Support nullable values in ActivityState dictionaries Update ActivityState to support nullable values by changing type to 'IDictionary<string, object?>'. Enhanced DefaultActivityExecutionMapper to handle multiple persistence strategies for logging inputs and outputs. * Rename ShouldPersistAsync to GetPersistenceModeAsync Refactor method names for log persistence strategies to improve readability and consistency. Added summary comments for clarification and removed redundant configurations from appsettings.json. Added implicit uses and updated namespaces for better maintainability. * Refactor activity payload and output retrieval logic Extract payload and output retrieval into `GetPayload` and `GetOutputs` methods respectively. This modularizes the code for better readability and maintainability, and allows for potential reusability of these methods in other parts of the codebase. * Add new project reference and update PostgreSQL provider usage Added a project reference to Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql in the test project file. Also modified the WorkflowServer setup to specify the assembly in the PostgreSQL provider configuration. * Add agent persistence to WorkflowServer Integrated agent support and persistence using PostgreSQL in WorkflowServer. This includes adding necessary project references and configuring agents in the workflow server setup.
98 lines
4.1 KiB
C#
98 lines
4.1 KiB
C#
using System.Net.Http.Headers;
|
|
using Elsa.Agents;
|
|
using Elsa.Alterations.Extensions;
|
|
using Elsa.AzureServiceBus.ComponentTests.Extensions;
|
|
using Elsa.EntityFrameworkCore.Extensions;
|
|
using Elsa.EntityFrameworkCore.Modules.Alterations;
|
|
using Elsa.EntityFrameworkCore.Modules.Identity;
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
|
using Elsa.Extensions;
|
|
using Elsa.Identity.Providers;
|
|
using Elsa.MassTransit.Extensions;
|
|
using Elsa.Testing.Shared.Handlers;
|
|
using Elsa.Testing.Shared.Services;
|
|
using FluentStorage;
|
|
using JetBrains.Annotations;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.AspNetCore.TestHost;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Elsa.AzureServiceBus.ComponentTests;
|
|
|
|
[UsedImplicitly]
|
|
public class WorkflowServer(Infrastructure infrastructure, string url) : WebApplicationFactory<Program>
|
|
{
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
|
{
|
|
var dbConnectionString = infrastructure.DbContainer.GetConnectionString();
|
|
var rabbitMqConnectionString = infrastructure.RabbitMqContainer.GetConnectionString();
|
|
|
|
builder.UseUrls(url);
|
|
|
|
if (Program.ConfigureForTest == null)
|
|
{
|
|
Program.ConfigureForTest = elsa =>
|
|
{
|
|
elsa.AddWorkflowsFrom<WorkflowServer>();
|
|
elsa.AddActivitiesFrom<WorkflowServer>();
|
|
elsa.UseDefaultAuthentication(defaultAuthentication => defaultAuthentication.UseAdminApiKey());
|
|
elsa.UseFluentStorageProvider(sp =>
|
|
{
|
|
var assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
var assemblyDirectory = Path.GetDirectoryName(assemblyLocation)!;
|
|
var workflowsDirectorySegments = new[]
|
|
{
|
|
assemblyDirectory, "Scenarios"
|
|
};
|
|
var workflowsDirectory = Path.Join(workflowsDirectorySegments);
|
|
return StorageFactory.Blobs.DirectoryFiles(workflowsDirectory);
|
|
});
|
|
elsa.UseMassTransit(massTransit =>
|
|
{
|
|
massTransit.UseRabbitMq(rabbitMqConnectionString);
|
|
});
|
|
elsa.UseIdentity(identity => identity.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString)));
|
|
elsa.UseWorkflowManagement(management =>
|
|
{
|
|
management.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString));
|
|
management.UseMassTransitDispatcher();
|
|
management.UseCache();
|
|
});
|
|
elsa.UseWorkflowRuntime(runtime =>
|
|
{
|
|
runtime.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString));
|
|
runtime.UseCache();
|
|
runtime.UseMassTransitDispatcher();
|
|
runtime.UseProtoActor();
|
|
});
|
|
elsa.UseAlterations(alterations =>
|
|
{
|
|
alterations.UseEntityFrameworkCore(e => e.UsePostgreSql(dbConnectionString));
|
|
});
|
|
elsa.UseHttp(http =>
|
|
{
|
|
http.UseCache();
|
|
});
|
|
elsa.UseAzureServiceBus();
|
|
elsa.UseAgents();
|
|
elsa.UseAgentPersistence(feature => feature.UseEntityFrameworkCore(ef => ef.UsePostgreSql(typeof(AgentsPostgreSqlProvidersExtensions).Assembly, dbConnectionString)));
|
|
};
|
|
}
|
|
|
|
builder.ConfigureTestServices(services =>
|
|
{
|
|
services.AddSingleton<SignalManager>();
|
|
services.AddSingleton<WorkflowEvents>();
|
|
services.AddNotificationHandlersFrom<WorkflowServer>();
|
|
services.AddNotificationHandlersFrom<WorkflowEventHandlers>();
|
|
services.AddAzureServiceBusTestServices();
|
|
});
|
|
}
|
|
|
|
protected override void ConfigureClient(HttpClient client)
|
|
{
|
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("ApiKey", AdminApiKeyProvider.DefaultApiKey);
|
|
}
|
|
} |