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

Add AwaitWithStopOnCancellation #83

Merged
merged 3 commits into from
Feb 25, 2021
Merged

Add AwaitWithStopOnCancellation #83

merged 3 commits into from
Feb 25, 2021

Conversation

bartelink
Copy link
Collaborator

The current API does not provide a clear way to have a service cleanly shut down in response to the faulting of one of a set of consumers.

This PR extends the API to provide such a mechanism

@bartelink
Copy link
Collaborator Author

bartelink commented Dec 11, 2020

Will likely merge these changes in, along with #73 as part of the 1.6.0 release (when the associated underlying Confluent.Kafka release happens)

For now, this extension can be approximated via this helper:

[<AutoOpen>]
module ConsumerExt =

    type Consumer with
        member consumer.AwaitWithStopOnCancellation() = async {
            let! ct = Async.CancellationToken
            use _ = ct.Register(fun () -> consumer.Stop())
            return! consumer.AwaitShutdown()
        }

See https://gist.github.com/bartelink/14b7a1474e5376b59e62ddf8caacdb44 for a testbed

@bartelink bartelink marked this pull request as ready for review January 15, 2021 10:45
Base automatically changed from remove-deprecated to master February 25, 2021 22:26
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.

None yet

1 participant