Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elastic updates #3623

Merged
merged 11 commits into from
Jan 13, 2023
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/v3' into v3-elasticsearch-updates
  • Loading branch information
sfmskywalker committed Jan 12, 2023
commit 70dae3d10eb02d832ba68b2ee7fea083abefee74
6 changes: 1 addition & 5 deletions src/bundles/Elsa.WorkflowServer.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Azure.Identity;
using Azure.ResourceManager;
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.Extensions;
using Elsa.Identity.Options;
Expand All @@ -8,9 +6,7 @@
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Microsoft.Data.Sqlite;
using Elsa.ProtoActor.Cluster.AzureContainerApps;
using Proto.Persistence.Sqlite;
using Proto.Remote.GrpcNet;

var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
Expand All @@ -35,7 +31,7 @@
.UseDefaultAuthentication()
.UseWorkflowManagement(management =>
{
management.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString));
management.UseDefaultManagement(m => m.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)));
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)));
})
.UseWorkflowRuntime(runtime =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreManagementPersistenceFeature UsePostgreSql(this EFCoreManagementPersistenceFeature feature, string connectionString)
public static EFCoreDefaultManagementPersistenceFeature UsePostgreSql(this EFCoreDefaultManagementPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaPostgreSql(connectionString);
return feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreManagementPersistenceFeature UseSqlServer(this EFCoreManagementPersistenceFeature feature, string connectionString)
public static EFCoreDefaultManagementPersistenceFeature UseSqlServer(this EFCoreDefaultManagementPersistenceFeature feature, string connectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlServer(connectionString);
return feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Elsa.EntityFrameworkCore.Extensions;

public static partial class Extensions
{
public static EFCoreManagementPersistenceFeature UseSqlite(this EFCoreManagementPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
public static EFCoreDefaultManagementPersistenceFeature UseSqlite(this EFCoreDefaultManagementPersistenceFeature feature, string connectionString = Constants.DefaultConnectionString)
{
feature.DbContextOptionsBuilder = (_, db) => db.UseElsaSqlite(connectionString);
return feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public static class WorkflowManagementFeatureExtensions
/// <summary>
/// Sets up the EF Core persistence provider.
/// </summary>
public static WorkflowManagementFeature UseEntityFrameworkCore(this WorkflowManagementFeature feature,
Action<EFCoreManagementPersistenceFeature>? configure = default)
public static DefaultManagementFeature UseEntityFrameworkCore(this DefaultManagementFeature feature,
Action<EFCoreDefaultManagementPersistenceFeature>? configure = default)
{
feature.Module.Configure(configure);
return feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public override void Configure()
feature.WorkflowStateStore = sp => sp.GetRequiredService<EFCoreWorkflowStateStore>();
feature.WorkflowTriggerStore = sp => sp.GetRequiredService<EFCoreTriggerStore>();
feature.BookmarkStore = sp => sp.GetRequiredService<EFCoreBookmarkStore>();
feature.WorkflowExecutionLogStore = sp => sp.GetRequiredService<EFCoreWorkflowExecutionLogStore>();
});
}

Expand All @@ -34,6 +33,5 @@ public override void Apply()
AddStore<WorkflowState, EFCoreWorkflowStateStore>();
AddStore<StoredTrigger, EFCoreTriggerStore>();
AddStore<StoredBookmark, EFCoreBookmarkStore>();
AddStore<WorkflowExecutionLogRecord, EFCoreWorkflowExecutionLogStore>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public static IModule UseWorkflowManagement(this IModule module, Action<Workflow
return module;
}

/// <summary>
/// Adds the default workflow management feature to the specified module.
/// </summary>
public static WorkflowManagementFeature UseDefaultManagement(this WorkflowManagementFeature feature, Action<DefaultManagementFeature>? configure = default)
{
feature.Module.Configure(configure);
return feature;
}

/// <summary>
/// Adds the workflow instance feature to workflow management module.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Elsa.Features.Abstractions;
using Elsa.Features.Services;

namespace Elsa.Workflows.Management.Features;

public class DefaultManagementFeature : FeatureBase
{
public DefaultManagementFeature(IModule module) : base(module)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite()));
elsa.UseWorkflowManagement(management =>
{
management.UseDefaultManagement(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()));
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Configure runtime feature to use EF Core.
elsa.UseWorkflowRuntime(runtime => runtime.UseDefaultRuntime(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite())));
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseDefaultRuntime(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
runtime.UseExecutionLogRecords(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Expose API endpoints.
elsa.UseWorkflowsApi(api => api.AddFastEndpointsAssembly<Program>());
Expand Down
12 changes: 10 additions & 2 deletions src/samples/aspnet/Elsa.Samples.MassTransitActivities/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite()));
elsa.UseWorkflowManagement(management =>
{
management.UseDefaultManagement(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()));
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Configure runtime feature to use EF Core.
elsa.UseWorkflowRuntime(runtime => runtime.UseDefaultRuntime(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite())));
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseDefaultRuntime(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
runtime.UseExecutionLogRecords(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Expose API endpoints.
elsa.UseWorkflowsApi();
Expand Down
38 changes: 21 additions & 17 deletions src/samples/aspnet/Elsa.Samples.TelnyxIntegration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,26 @@
// Add Elsa services.
services
.AddElsa(elsa => elsa
.UseWorkflowManagement(management => management
.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))
.AddActivity<WriteLine>()
.AddActivity<ReadLine>()
.AddActivity<If>()
.AddActivity<Flowchart>()
.AddActivity<FlowDecision>()
.AddActivity<FlowSwitch>()
.AddActivity<FlowJoin>()
.AddActivity<Elsa.Scheduling.Activities.Delay>()
.AddActivity<Elsa.Scheduling.Activities.Timer>()
.AddActivity<ForEach>()
.AddActivity<Switch>()
.AddActivity<RunJavaScript>()
.AddActivity<Event>()
.AddActivitiesFrom<Program>()
)
.UseWorkflowManagement(management =>
{
management
.UseDefaultManagement(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()))
.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()))
.AddActivity<WriteLine>()
.AddActivity<ReadLine>()
.AddActivity<If>()
.AddActivity<Flowchart>()
.AddActivity<FlowDecision>()
.AddActivity<FlowSwitch>()
.AddActivity<FlowJoin>()
.AddActivity<Elsa.Scheduling.Activities.Delay>()
.AddActivity<Elsa.Scheduling.Activities.Timer>()
.AddActivity<ForEach>()
.AddActivity<Switch>()
.AddActivity<RunJavaScript>()
.AddActivity<Event>()
.AddActivitiesFrom<Program>();
})
.UseIdentity(identity =>
{
identity.IdentityOptions = identityOptions;
Expand All @@ -58,6 +61,7 @@
//proto.PersistenceProvider = _ => new SqliteProvider(new SqliteConnectionStringBuilder(sqliteConnectionString));
});
runtime.UseDefaultRuntime(dr => dr.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)));
runtime.UseExecutionLogRecords(d => d.UseEntityFrameworkCore(ef => ef.UseSqlite()));
runtime.UseExecutionLogRecords(e => e.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)));
runtime.WorkflowStateExporter = sp => sp.GetRequiredService<AsyncWorkflowStateExporter>();
})
Expand Down
6 changes: 5 additions & 1 deletion src/samples/aspnet/Elsa.Samples.WorkflowServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite()));
elsa.UseWorkflowManagement(management =>
{
management.UseDefaultManagement(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()));
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Expose API endpoints.
elsa.UseWorkflowsApi();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
builder.Services.AddElsa(elsa =>
{
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlite()));
elsa.UseWorkflowManagement(management =>
{
management.UseDefaultManagement(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()));
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()));
});

// Expose API endpoints.
elsa.UseWorkflowsApi();
Expand Down