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

Initial push for adding orchestration reuse ID #258

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RyanLettieri
Copy link
Member

Related Issue: #255

Copy link
Member

@jviau jviau left a comment

Choose a reason for hiding this comment

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

I think you may have already updating the protobuf submodule, but was there merge issues in that repo? Looks like all the entity work is gone.

@@ -40,5 +41,6 @@ public interface IOrchestrationSubmitter
TaskName orchestratorName,
object? input = null,
StartOrchestrationOptions? options = null,
HashSet<string>? 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.

Please add this to StartOrchestrationOptions instead of its own parameter. All non-essential parameters for affecting orchestration start should go there.

Copy link
Member

Choose a reason for hiding this comment

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

Also, should this be an enum with the available behaviors as values in it?

@@ -40,5 +41,6 @@ public interface IOrchestrationSubmitter
TaskName orchestratorName,
object? input = null,
StartOrchestrationOptions? options = null,
HashSet<string>? orchestrationIdReusePolicy = null,
Copy link
Member

@jviau jviau Jan 5, 2024

Choose a reason for hiding this comment

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

"ReusePolicy" isn't that clear to me. Was the name InstanceIdConflictBehavior considered?

@jviau
Copy link
Member

jviau commented Jan 9, 2024

This will also address #183

Copy link
Member

@jviau jviau left a comment

Choose a reason for hiding this comment

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

I suggest the following approach:

  1. Create a new enum in Abstractions.csproj to represent the possible states for this feature. This is the type the customer will interact with.
  2. Add this as an optional value to StartOrchestrationOptions and SubOrchestrationOptions (actually only worry about Start options in this PR, we can tackle sub-orchestration options later)
  3. Add a configurable default value to DurableTaskClientOptions and DurableTaskWorkerOptions. This default value will be used when a customer does not explicitly provide it on the options from point 2.
  4. Update clients and workers to consume this as appropriate. The gRPC client/worker implementation would convert the public facing enum to the gRPC enum internally.

<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.

/// <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.

src/Abstractions/OrchestrationOptions.cs Outdated Show resolved Hide resolved
Signed-off-by: Ryan Lettieri <[email protected]>
/// <summary>
/// Enum describing the runtime status of the orchestration.
/// </summary>
public enum OrchestrationRuntimeStatus
Copy link
Member

Choose a reason for hiding this comment

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

I think we will need to have type-forwarding from this type in the client package.

/// <param name="OrchestrationIdReusePolicy">The orchestration reuse policy. This allows for the reuse of an instance ID
/// if the instance ID referenced is in any of the states supplied in this parameter.</param>
public record StartOrchestrationOptions(string? InstanceId = null, DateTimeOffset? StartAt = null,
OrchestrationRuntimeStatus[]? 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.

Can we wrap this in a type: OrchestrationIdReuse, so we can have helpers:

OrchestrationIdReuse.IfTerminal; // has all terminal statuses included.
OrchestrationIdReuse.Always; // has all statuses included.
OrchestrationIdReuse.IfStatus(params OrchestrationRuntimeStatus[] statuses);
OrchestrationIdReuse.IfStatus(IEnumerable<OrchestrationRuntimeStatus> statuses);
OrchestrationIdReuse.Never; // equal to default.

@@ -83,6 +83,7 @@ public override ValueTask DisposeAsync()
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?

@@ -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

@@ -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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants