Add support for naming workflow instances during execution

This update introduces a `Name` property to workflow execution requests, allowing workflows to be named when started. The changes ensure the `Name` is propagated through the relevant services and endpoints, improving tracking and identification of workflow instances.
This commit is contained in:
Sipke Schoorstra 2025-03-02 11:28:56 +01:00
parent 27fe72d123
commit 0ceeb801e7
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
4 changed files with 14 additions and 4 deletions

View file

@ -43,6 +43,7 @@ internal abstract class EndpointBase<T>(
{
Workflow = workflowGraph.Workflow,
CorrelationId = request.CorrelationId,
Name = request.Name,
Input = request.GetInputAsDictionary(),
TriggerActivityId = request.TriggerActivityId,
ActivityHandle = request.ActivityHandle

View file

@ -13,6 +13,7 @@ public interface IExecutionRequest
{
string DefinitionId { get; }
string? CorrelationId { get; }
string? Name { get; }
string? TriggerActivityId { get; }
ActivityHandle? ActivityHandle { get; }
VersionOptions? VersionOptions { get; }
@ -22,8 +23,9 @@ public interface IExecutionRequest
public class PostRequest : IExecutionRequest
{
public string DefinitionId { get; set; } = default!;
public string DefinitionId { get; set; } = null!;
public string? CorrelationId { get; set; }
public string? Name { get; set; }
public string? TriggerActivityId { get; set; }
public ActivityHandle? ActivityHandle { get; set; }
public VersionOptions? VersionOptions { get; set; }
@ -36,8 +38,9 @@ public class PostRequest : IExecutionRequest
public class GetRequest : IExecutionRequest
{
public string DefinitionId { get; set; } = default!;
public string DefinitionId { get; set; } = null!;
public string? CorrelationId { get; set; }
public string? Name { get; set; }
public string? TriggerActivityId { get; set; }
public ActivityHandle? ActivityHandle { get; set; }
public VersionOptions? VersionOptions { get; set; }
@ -45,9 +48,9 @@ public class GetRequest : IExecutionRequest
public IDictionary<string, object>? GetInputAsDictionary()
{
var result = Input?.TryConvertTo<ExpandoObject>(new ObjectConverterOptions
var result = Input?.TryConvertTo<ExpandoObject>(new()
{
SerializerOptions = new JsonSerializerOptions
SerializerOptions = new()
{
Converters = { new ExpandoObjectConverter() }
}

View file

@ -22,6 +22,11 @@ public class StartWorkflowRequest
/// </summary>
public string? CorrelationId { get; set; }
/// <summary>
/// The name to use when starting a new workflow instance.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// The input to the workflow instance, if any.
/// </summary>

View file

@ -29,6 +29,7 @@ public class DefaultWorkflowStarter(IWorkflowDefinitionService workflowDefinitio
{
WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(workflow.Identity.Id),
CorrelationId = request.CorrelationId,
Name = request.Name,
Input = request.Input,
TriggerActivityId = request.TriggerActivityId,
ActivityHandle = request.ActivityHandle,