sarama
sarama copied to clipboard
feature: basic support for context
👋 I'm just messing around here to try and find a way to have contexts supported by code that I work with that uses sarama. Is this something that would be of interest? If so, I can look at writing tests and iterating and so on.
The idea being that you can set Context
on a message and it will be best-effort supported by the producers. In the sync producer case, this makes a lot of mostly obvious sense: "I'm willing to wait this long to send a message, otherwise give up".
In the async producer case, the use case is a bit less obvious, since the assumption is that a message will be sent sometime in the future. Yet, since the ProducerMessage.Context
is a field and not a method argument, and therefor opt-in, messages that don't set a context wouldn't see any difference. A user of the async producer would have to set the field to signify that they want to have the message sort-of respect the ctx.Done()
lifetime. Why would someone do this? Perhaps they're willing to send a message async for up to 5s, after which the message would be untimely and its usefulness gone.
I need this!
Thank you for your contribution! However, this pull request has not had any activity in the past 90 days and will be closed in 30 days if no updates occur. If you believe the changes are still valid then please verify your branch has no conflicts with main and rebase if needed. If you are awaiting a (re-)review then please let us know.