Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wanxms authored Feb 12, 2025
2 parents 2a0b27b + 09cd773 commit a614b7d
Show file tree
Hide file tree
Showing 53 changed files with 1,725 additions and 60 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @danielgerlag @glucaci
10 changes: 9 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -33,6 +34,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -49,6 +51,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -65,6 +68,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -81,6 +85,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -97,6 +102,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -113,6 +119,7 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -129,9 +136,10 @@ jobs:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Elasticsearch Tests
run: dotnet test test/WorkflowCore.Tests.Elasticsearch --no-build --verbosity normal -p:ParallelizeTestCollections=false
run: dotnet test test/WorkflowCore.Tests.Elasticsearch --no-build --verbosity normal -p:ParallelizeTestCollections=false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Workflow Core

[![Build status](https://ci.appveyor.com/api/projects/status/xnby6p5v4ur04u76?svg=true)](https://ci.appveyor.com/project/danielgerlag/workflow-core)
[<img src="https://api.gitsponsors.com/api/badge/img?id=73864802" height="20">](https://api.gitsponsors.com/api/badge/link?p=xj6mObb7nZAJGyuABfd8nD5XWf3SE4oUfw0vmCgSiJeIfNlzJAej0FWX8oFdYm6D7bvZpCf6qANVBNPWid4dRQ==)

Workflow Core is a light weight embeddable workflow engine targeting .NET Standard. Think: long running processes with multiple tasks that need to track state. It supports pluggable persistence and concurrency providers to allow for multi-node clusters.

Expand Down
18 changes: 16 additions & 2 deletions WorkflowCore.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29509.3
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF47161E-E399-451C-BDE8-E92AAD3BD761}"
EndProject
Expand Down Expand Up @@ -154,6 +154,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Sample19", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Persistence.RavenDB", "src\providers\WorkflowCore.Persistence.RavenDB\WorkflowCore.Persistence.RavenDB.csproj", "{AF205715-C8B7-42EF-BF14-AFC9E7F27242}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Persistence.Oracle", "src\providers\WorkflowCore.Persistence.Oracle\WorkflowCore.Persistence.Oracle.csproj", "{635629BC-9D5C-40C6-BBD0-060550ECE290}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Tests.Oracle", "test\WorkflowCore.Tests.Oracle\WorkflowCore.Tests.Oracle.csproj", "{A2837F1C-3740-4375-9069-81AE32C867CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -376,6 +380,14 @@ Global
{AF205715-C8B7-42EF-BF14-AFC9E7F27242}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF205715-C8B7-42EF-BF14-AFC9E7F27242}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF205715-C8B7-42EF-BF14-AFC9E7F27242}.Release|Any CPU.Build.0 = Release|Any CPU
{635629BC-9D5C-40C6-BBD0-060550ECE290}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{635629BC-9D5C-40C6-BBD0-060550ECE290}.Debug|Any CPU.Build.0 = Debug|Any CPU
{635629BC-9D5C-40C6-BBD0-060550ECE290}.Release|Any CPU.ActiveCfg = Release|Any CPU
{635629BC-9D5C-40C6-BBD0-060550ECE290}.Release|Any CPU.Build.0 = Release|Any CPU
{A2837F1C-3740-4375-9069-81AE32C867CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2837F1C-3740-4375-9069-81AE32C867CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2837F1C-3740-4375-9069-81AE32C867CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2837F1C-3740-4375-9069-81AE32C867CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -438,6 +450,8 @@ Global
{54DE20BA-EBA7-4BF0-9BD9-F03766849716} = {E6CEAD8D-F565-471E-A0DC-676F54EAEDEB}
{1223ED47-3E5E-4960-B70D-DFAF550F6666} = {5080DB09-CBE8-4C45-9957-C3BB7651755E}
{AF205715-C8B7-42EF-BF14-AFC9E7F27242} = {2EEE6ABD-EE9B-473F-AF2D-6DABB85D7BA2}
{635629BC-9D5C-40C6-BBD0-060550ECE290} = {2EEE6ABD-EE9B-473F-AF2D-6DABB85D7BA2}
{A2837F1C-3740-4375-9069-81AE32C867CA} = {E6CEAD8D-F565-471E-A0DC-676F54EAEDEB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC0FA8D3-6449-4FDA-BB46-ECF58FAD23B4}
Expand Down
8 changes: 4 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<PackageLicenseUrl>https://github.com/danielgerlag/workflow-core/blob/master/LICENSE.md</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/danielgerlag/workflow-core.git</RepositoryUrl>
<Version>3.10.0</Version>
<AssemblyVersion>3.10.0.0</AssemblyVersion>
<FileVersion>3.10.0.0</FileVersion>
<Version>3.13.0</Version>
<AssemblyVersion>3.13.0.0</AssemblyVersion>
<FileVersion>3.13.0.0</FileVersion>
<PackageIconUrl>https://github.com/danielgerlag/workflow-core/raw/master/src/logo.png</PackageIconUrl>
<PackageVersion>3.10.0</PackageVersion>
<PackageVersion>3.13.0</PackageVersion>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions src/WorkflowCore.DSL/Interface/ITypeResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Linq;

namespace WorkflowCore.Interface
{
public interface ITypeResolver
{
Type FindType(string name);
}
}
1 change: 1 addition & 0 deletions src/WorkflowCore.DSL/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class ServiceCollectionExtensions
{
public static IServiceCollection AddWorkflowDSL(this IServiceCollection services)
{
services.AddTransient<ITypeResolver, TypeResolver>();
services.AddTransient<IDefinitionLoader, DefinitionLoader>();
return services;
}
Expand Down
15 changes: 9 additions & 6 deletions src/WorkflowCore.DSL/Services/DefinitionLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ namespace WorkflowCore.Services.DefinitionStorage
public class DefinitionLoader : IDefinitionLoader
{
private readonly IWorkflowRegistry _registry;
private readonly ITypeResolver _typeResolver;

public DefinitionLoader(IWorkflowRegistry registry)
public DefinitionLoader(IWorkflowRegistry registry, ITypeResolver typeResolver)
{
_registry = registry;
_typeResolver = typeResolver;
}

public WorkflowDefinition LoadDefinition(string source, Func<string, DefinitionSourceV1> deserializer)
Expand Down Expand Up @@ -220,10 +222,11 @@ private void AttachOutputs(StepSourceV1 source, Type dataType, Type stepType, Wo
var dataParameter = Expression.Parameter(dataType, "data");


if(output.Key.Contains(".") || output.Key.Contains("["))
if (output.Key.Contains(".") || output.Key.Contains("["))
{
AttachNestedOutput(output, step, source, sourceExpr, dataParameter);
}else
}
else
{
AttachDirectlyOutput(output, step, dataType, sourceExpr, dataParameter);
}
Expand Down Expand Up @@ -259,11 +262,11 @@ private void AttachDirectlyOutput(KeyValuePair<string, string> output, WorkflowS

}

private void AttachNestedOutput( KeyValuePair<string, string> output, WorkflowStep step, StepSourceV1 source, LambdaExpression sourceExpr, ParameterExpression dataParameter)
private void AttachNestedOutput(KeyValuePair<string, string> output, WorkflowStep step, StepSourceV1 source, LambdaExpression sourceExpr, ParameterExpression dataParameter)
{
PropertyInfo propertyInfo = null;
String[] paths = output.Key.Split('.');

Expression targetProperty = dataParameter;

bool hasAddOutput = false;
Expand Down Expand Up @@ -352,7 +355,7 @@ private void AttachOutcomes(StepSourceV1 source, Type dataType, WorkflowStep ste

private Type FindType(string name)
{
return Type.GetType(name, true, true);
return _typeResolver.FindType(name);
}

private static Action<IStepBody, object, IStepExecutionContext> BuildScalarInputAction(KeyValuePair<string, object> input, ParameterExpression dataParameter, ParameterExpression contextParameter, ParameterExpression environmentVarsParameter, PropertyInfo stepProperty)
Expand Down
15 changes: 15 additions & 0 deletions src/WorkflowCore.DSL/Services/TypeResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using WorkflowCore.Interface;

namespace WorkflowCore.Services.DefinitionStorage
{
public class TypeResolver : ITypeResolver
{
public Type FindType(string name)
{
return Type.GetType(name, true, true);
}
}
}
6 changes: 3 additions & 3 deletions src/WorkflowCore/Models/WorkflowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace WorkflowCore.Models
{
public class WorkflowOptions
{
internal Func<IServiceProvider, IPersistenceProvider> PersistanceFactory;
internal Func<IServiceProvider, IPersistenceProvider> PersistenceFactory;
internal Func<IServiceProvider, IQueueProvider> QueueFactory;
internal Func<IServiceProvider, IDistributedLockProvider> LockFactory;
internal Func<IServiceProvider, ILifeCycleEventHub> EventHubFactory;
Expand All @@ -29,7 +29,7 @@ public WorkflowOptions(IServiceCollection services)

QueueFactory = new Func<IServiceProvider, IQueueProvider>(sp => new SingleNodeQueueProvider());
LockFactory = new Func<IServiceProvider, IDistributedLockProvider>(sp => new SingleNodeLockProvider());
PersistanceFactory = new Func<IServiceProvider, IPersistenceProvider>(sp => new TransientMemoryPersistenceProvider(sp.GetService<ISingletonMemoryProvider>()));
PersistenceFactory = new Func<IServiceProvider, IPersistenceProvider>(sp => new TransientMemoryPersistenceProvider(sp.GetService<ISingletonMemoryProvider>()));
SearchIndexFactory = new Func<IServiceProvider, ISearchIndex>(sp => new NullSearchIndex());
EventHubFactory = new Func<IServiceProvider, ILifeCycleEventHub>(sp => new SingleNodeEventHub(sp.GetService<ILoggerFactory>()));
}
Expand All @@ -42,7 +42,7 @@ public WorkflowOptions(IServiceCollection services)

public void UsePersistence(Func<IServiceProvider, IPersistenceProvider> factory)
{
PersistanceFactory = factory;
PersistenceFactory = factory;
}

public void UseDistributedLockManager(Func<IServiceProvider, IDistributedLockProvider> factory)
Expand Down
8 changes: 4 additions & 4 deletions src/WorkflowCore/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public static IServiceCollection AddWorkflow(this IServiceCollection services, A
var options = new WorkflowOptions(services);
setupAction?.Invoke(options);
services.AddSingleton<ISingletonMemoryProvider, MemoryPersistenceProvider>();
services.AddTransient<IPersistenceProvider>(options.PersistanceFactory);
services.AddTransient<IWorkflowRepository>(options.PersistanceFactory);
services.AddTransient<ISubscriptionRepository>(options.PersistanceFactory);
services.AddTransient<IEventRepository>(options.PersistanceFactory);
services.AddTransient<IPersistenceProvider>(options.PersistenceFactory);
services.AddTransient<IWorkflowRepository>(options.PersistenceFactory);
services.AddTransient<ISubscriptionRepository>(options.PersistenceFactory);
services.AddTransient<IEventRepository>(options.PersistenceFactory);
services.AddSingleton<IQueueProvider>(options.QueueFactory);
services.AddSingleton<IDistributedLockProvider>(options.LockFactory);
services.AddSingleton<ILifeCycleEventHub>(options.EventHubFactory);
Expand Down
27 changes: 18 additions & 9 deletions src/WorkflowCore/Services/WorkflowActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal static void Enrich(WorkflowInstance workflow, string action)
}
}


internal static void Enrich(WorkflowStep workflowStep)
{
var activity = Activity.Current;
Expand All @@ -57,10 +58,18 @@ internal static void Enrich(WorkflowStep workflowStep)
? "inline"
: workflowStep.Name;

activity.DisplayName += $" step {stepName}";
if (string.IsNullOrEmpty(activity.DisplayName))
{
activity.DisplayName = $"step {stepName}";
}
else
{
activity.DisplayName += $" step {stepName}";
}

activity.SetTag("workflow.step.id", workflowStep.Id);
activity.SetTag("workflow.step.name", stepName);
activity.SetTag("workflow.step.type", workflowStep.BodyType.Name);
activity.SetTag("workflow.step.type", workflowStep.BodyType?.Name);
}
}

Expand All @@ -69,10 +78,10 @@ internal static void Enrich(WorkflowExecutorResult result)
var activity = Activity.Current;
if (activity != null)
{
activity.SetTag("workflow.subscriptions.count", result.Subscriptions.Count);
activity.SetTag("workflow.errors.count", result.Errors.Count);
activity.SetTag("workflow.subscriptions.count", result?.Subscriptions?.Count);
activity.SetTag("workflow.errors.count", result?.Errors?.Count);

if (result.Errors.Count > 0)
if (result?.Errors?.Count > 0)
{
activity.SetStatus(Status.Error);
activity.SetStatus(ActivityStatusCode.Error);
Expand All @@ -85,10 +94,10 @@ internal static void Enrich(Event evt)
var activity = Activity.Current;
if (activity != null)
{
activity.DisplayName = $"workflow process {evt.EventName}";
activity.SetTag("workflow.event.id", evt.Id);
activity.SetTag("workflow.event.name", evt.EventName);
activity.SetTag("workflow.event.processed", evt.IsProcessed);
activity.DisplayName = $"workflow process {evt?.EventName}";
activity.SetTag("workflow.event.id", evt?.Id);
activity.SetTag("workflow.event.name", evt?.EventName);
activity.SetTag("workflow.event.processed", evt?.IsProcessed);
}
}

Expand Down
Loading

0 comments on commit a614b7d

Please sign in to comment.