Skip to content

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
@bartelink bartelink requested a review from wantastic84 January 15, 2021 10:46
Base automatically changed from remove-deprecated to master February 25, 2021 22:26
@bartelink bartelink merged commit 47e62de into master Feb 25, 2021
@bartelink bartelink deleted the await-with-stop branch February 25, 2021 22:43
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.

1 participant