Skip to content

Cascade terminate/purge support in GrpcDurableTaskClient#262

Merged
jviau merged 12 commits intomicrosoft:mainfrom
shivamkm07:cascade_terminatePurge
Feb 2, 2024
Merged

Cascade terminate/purge support in GrpcDurableTaskClient#262
jviau merged 12 commits intomicrosoft:mainfrom
shivamkm07:cascade_terminatePurge

Conversation

@shivamkm07
Copy link
Copy Markdown
Contributor

@shivamkm07 shivamkm07 commented Jan 24, 2024

This PR adds support to recursively terminate/purge sub-orchestrations in GrpcDurableTaskClient. It also sets the recursive behavior to be false by default.

Closes: #260

Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Copy link
Copy Markdown
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.

As we now have multiple parameters for terminate, I recommend we do the following:

  1. Add TerminateInstanceOptions
  2. Make the current abstract method virtual. Default implementation will call one of the new methods we add.
  3. Add TerminateInstanceOptions accepting virtual methods
  4. Update our clients to override the new options-receiving method.
/// add xmldoc
public record TerminateInstanceOptions
{
    public object? Output { get; init; }

    public bool Recursive { get; init; }
}

new methods:

public virtual Task TerminateInstanceAsync(string instanceId, TerminateInstanceOptions? options, CancellationToken cancellation)
    => throw new NotSupportedException($"{this.GetType()} does not support orchestration termination.");

// this is the formerly abstract method
public virtual Task TerminateInstanceAsync(string instanceId, object? output = null, CancellationToken cancellation = default)
{
    TerminateInstanceOptions? options = output is null ? null : new() { Output = output };
    return this.TerminateInstanceAsync(instanceId, options, cancellation);
}

@shivamkm07
Copy link
Copy Markdown
Contributor Author

shivamkm07 commented Jan 25, 2024

As we now have multiple parameters for terminate, I recommend we do the following:

  1. Add TerminateInstanceOptions
  2. Make the current abstract method virtual. Default implementation will call one of the new methods we add.
  3. Add TerminateInstanceOptions accepting virtual methods
  4. Update our clients to override the new options-receiving method.
/// add xmldoc
public record TerminateInstanceOptions
{
    public object? Output { get; init; }

    public bool Recursive { get; init; }
}

new methods:

public virtual Task TerminateInstanceAsync(string instanceId, TerminateInstanceOptions? options, CancellationToken cancellation)
    => throw new NotSupportedException($"{this.GetType()} does not support orchestration termination.");

// this is the formerly abstract method
public virtual Task TerminateInstanceAsync(string instanceId, object? output = null, CancellationToken cancellation = default)
{
    TerminateInstanceOptions? options = output is null ? null : new() { Output = output };
    return this.TerminateInstanceAsync(instanceId, options, cancellation);
}

I am okay with this change. Just should the new TerminateInstanceOptions method be an abstract method and both GrpcDurableTaskClient and ShimDurableTaskClient implement this method? This is what seems to be followed in other DurableTaskClient methods..

Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
@shivamkm07 shivamkm07 force-pushed the cascade_terminatePurge branch from 70e9c1a to e2f9bc1 Compare January 25, 2024 06:18
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
@shivamkm07 shivamkm07 marked this pull request as ready for review January 25, 2024 07:14
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
@shivamkm07
Copy link
Copy Markdown
Contributor Author

As we now have multiple parameters for terminate, I recommend we do the following:

  1. Add TerminateInstanceOptions
  2. Make the current abstract method virtual. Default implementation will call one of the new methods we add.
  3. Add TerminateInstanceOptions accepting virtual methods
  4. Update our clients to override the new options-receiving method.
/// add xmldoc
public record TerminateInstanceOptions
{
    public object? Output { get; init; }

    public bool Recursive { get; init; }
}

new methods:

public virtual Task TerminateInstanceAsync(string instanceId, TerminateInstanceOptions? options, CancellationToken cancellation)
    => throw new NotSupportedException($"{this.GetType()} does not support orchestration termination.");

// this is the formerly abstract method
public virtual Task TerminateInstanceAsync(string instanceId, object? output = null, CancellationToken cancellation = default)
{
    TerminateInstanceOptions? options = output is null ? null : new() { Output = output };
    return this.TerminateInstanceAsync(instanceId, options, cancellation);
}

@jviau Pushed the suggested changes. Please review.

Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
Copy link
Copy Markdown
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.

Only a few small comments of recursive default behavior.

Signed-off-by: Shivam Kumar <shivamkm07@gmail.com>
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.

Support Cascade Terminate/Purge

3 participants