>
> Did you consider using context.Context rather than quit channels?


Applying a context.Context pretty much implies using a quit channel. Done 
is the only way to receive an expiry signal.

I just don't want to lock code into using the context package. The context 
setup is quite viral. For example, there is no simple way to construct a 
context from a quit channel (for some reason).

The mqtt package distinguishes between cancelation before and after 
submission. It is easy to flatten the error back into the context format. 
The explicitness may even help with understanding the consequences more 
clearly.

err := Publish(ctx.Done(), []byte("Hello"), "demo/+")
switch {
…
case errors.Is(err, mqtt.ErrCanceled), errors.Is(err, mqtt.ErrAbandoned):
return ctx.Err()
…
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7c1f13ff-48ef-4796-b1d9-71505fcbc4fbn%40googlegroups.com.

Reply via email to