Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/proto
7 changes: 7 additions & 0 deletions src/Abstractions/Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.16.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/Grpc/Grpc.csproj" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project should not reference gRPC. It is meant to be implementation agnostic.

</ItemGroup>

<ItemGroup>
<SharedSection Include="Core" />
<SharedSection Include="DependencyInjection" />
<SharedSection Include="Grpc" />
</ItemGroup>

<ItemGroup>
Expand Down
87 changes: 87 additions & 0 deletions src/Abstractions/OrchestrationOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.DurableTask;

/// <summary>
/// Orchestration status options.
/// </summary>
///
public sealed class OrchestrationOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="OrchestrationOptions"/> class.
/// </summary>
public OrchestrationOptions()
{
}

/// <summary>
/// Enum describing the return value when attempting to reuse a previously used instance ID.
/// </summary>
public enum InstanceIdReuseAction
{
/// <summary>
/// An error will be returned when attempting to reuse a previously used instance ID.
/// </summary>
ERROR,

/// <summary>
/// The request to reuse the previously used instanceID will be ignored.
/// </summary>
IGNORE,

/// <summary>
/// The currently running orchestration will be terminated and a new instance will be started.
/// </summary>
TERMINATE,
}

/// <summary>
/// Enum describing the runtime status of the orchestration.
/// </summary>
public enum OrchestrationRuntimeStatus
{
/// <summary>
/// The orchestration started running.
/// </summary>
Running,

/// <summary>
/// The orchestration completed normally.
/// </summary>
Completed,

/// <summary>
/// The orchestration is transitioning into a new instance.
/// </summary>
[Obsolete("The ContinuedAsNew status is obsolete and exists only for compatibility reasons.")]
ContinuedAsNew,

/// <summary>
/// The orchestration completed with an unhandled exception.
/// </summary>
Failed,

/// <summary>
/// The orchestration canceled gracefully.
/// </summary>
[Obsolete("The Canceled status is not currently used and exists only for compatibility reasons.")]
Canceled,

/// <summary>
/// The orchestration was abruptly terminated via a management API call.
/// </summary>
Terminated,

/// <summary>
/// The orchestration was scheduled but hasn't started running.
/// </summary>
Pending,

/// <summary>
/// The orchestration has been suspended.
/// </summary>
Suspended,
}
}
10 changes: 8 additions & 2 deletions src/Abstractions/TaskOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public record SubOrchestrationOptions : TaskOptions
/// </summary>
/// <param name="retry">The task retry options.</param>
/// <param name="instanceId">The orchestration instance ID.</param>
public SubOrchestrationOptions(TaskRetryOptions? retry = null, string? instanceId = null)
/// <param name="orchestrationIdReusePolicy">The orchestration reuse policy. This allows for the reuse of an
/// instance ID as well as the options for it.</param>
public SubOrchestrationOptions(TaskRetryOptions? retry = null, string? instanceId = null, Dictionary<OrchestrationOptions.OrchestrationRuntimeStatus, OrchestrationOptions.InstanceIdReuseAction>?
orchestrationIdReusePolicy = null)
: base(retry)
{
this.InstanceId = instanceId;
Expand Down Expand Up @@ -100,4 +103,7 @@ public SubOrchestrationOptions(TaskOptions options, string? instanceId = null)
/// The time when the orchestration instance should start executing. If not specified or if a date-time in the past
/// is specified, the orchestration instance will be scheduled immediately.
/// </param>
public record StartOrchestrationOptions(string? InstanceId = null, DateTimeOffset? StartAt = null);
/// <param name="OrchestrationIdReusePolicy">The orchestration reuse policy. This allows for the reuse of an instance ID
/// as well as the options for it.</param>
public record StartOrchestrationOptions(string? InstanceId = null, DateTimeOffset? StartAt = null,
Dictionary<List<OrchestrationOptions.OrchestrationRuntimeStatus>, OrchestrationOptions.InstanceIdReuseAction>? OrchestrationIdReusePolicy = null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you are trying to solve here: making it more granular on what the behavior is based on the state of the orchestration. Which I do think is worth considering.

I see the following problems with this approach:

  1. This information does not align with the protobuf spec
  2. It is a bit unwieldy for customers to need to specify this dictionary.

Instead, here is what I recommend:

  1. Lets first evaluate if this is needed? Or can we decide and document what the behavior of the 3 individual policies are based on the orchestration state? For example, we may consider applying conflict resolution for non-terminal orchestrations only.
  2. If not, then we can expand the protobuf and our enum to have more states that better clarify what happens. IE: ErrorAlways, ErrorIfRunning eg.

The end result should be customers need to only provide a single enum to this options object.

1 change: 1 addition & 0 deletions src/Client/Grpc/GrpcDurableTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
Version = orchestratorName.Version,
InstanceId = options?.InstanceId ?? Guid.NewGuid().ToString("N"),
Input = this.DataConverter.Serialize(input),
OrchestrationIdReusePolicy = { },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to map this from options correct?

};

DateTimeOffset? startAt = options?.StartAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ The client is responsible for interacting with orchestrations from outside the w
<EnableStyleCop>true</EnableStyleCop>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these packages needed for?

<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>

<PropertyGroup>
<!-- We are still working on this package for entities preview. -->
<VersionPrefix>1.0.5</VersionPrefix>
Expand All @@ -17,11 +22,13 @@ The client is responsible for interacting with orchestrations from outside the w

<ItemGroup>
<ProjectReference Include="../Core/Client.csproj" />
<ProjectReference Include="../../Grpc/Grpc.csproj" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be depending on gRPC

</ItemGroup>

<ItemGroup>
<SharedSection Include="Core" />
<SharedSection Include="DependencyInjection" />
<SharedSection Include="Grpc" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Core = DurableTask.Core;
using CoreOrchestrationQuery = DurableTask.Core.Query.OrchestrationQuery;

using P = Microsoft.DurableTask.Protobuf;

namespace Microsoft.DurableTask.Client.OrchestrationServiceClientShim;

/// <summary>
Expand Down Expand Up @@ -134,6 +136,7 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
{
cancellation.ThrowIfCancellationRequested();
string instanceId = options?.InstanceId ?? Guid.NewGuid().ToString("N");
Dictionary<List<OrchestrationOptions.OrchestrationRuntimeStatus>, OrchestrationOptions.InstanceIdReuseAction> idReusePolicy = options?.OrchestrationIdReusePolicy ?? new Dictionary<List<OrchestrationOptions.OrchestrationRuntimeStatus>, OrchestrationOptions.InstanceIdReuseAction>();
OrchestrationInstance instance = new()
{
InstanceId = instanceId,
Expand Down