Open echo8 opened 2 weeks ago
I'd rather update the wording on the documentation. The Context
field on the record came much later than the context
parameter in Produce
, and is primarily intended as a kv store, but exists so that people can also use it for other purposes (cancellation).
The region where Produce
itself blocks is small, and only if you've reached the internal max buffered records -- which largely shouldn't happen unless your brokers are down. Canceling the context is meant to cancel the record, not the Produce call.
Understood, thanks for the clarification! I'll make sure to not propagate the request's context in this case then.
I'm using this client's producer in an HTTP service but am running into some unexpected behavior regarding context usage.
Here is a simple example:
When I call this HTTP endpoint
Produce failed. context canceled
is logged. So it seems that the canceling of the request's context is causing the buffered record to also be canceled. This is unexpected to me because the record's context is being set to a totally different (background) context. In this case shouldn't the request's context only be used until the record is buffered?