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

Cascade terminate/purge support in GrpcDurableTaskClient #262

Merged
merged 12 commits into from
Feb 2, 2024

Conversation

shivamkm07
Copy link
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
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
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
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
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>
@jviau jviau merged commit dd8a756 into microsoft:main Feb 2, 2024
2 checks passed
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