On Sun, 2021-03-14 at 15:08 -0700, Pascal de Kloe wrote:
> > 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()
> …
> }

Thanks. That's a yes.

Dan


-- 
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/e6677061f0e8e834fc55f913d4347ec6b54a66c7.camel%40kortschak.io.

Reply via email to