Re: [go-nuts] [ANN] MQTT🤖

2021-03-14 Thread 'Dan Kortschak' via golang-nuts
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.


Re: [go-nuts] [ANN] MQTT🤖

2021-03-14 Thread Pascal de Kloe

>
> 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.


Re: [go-nuts] [ANN] MQTT🤖

2021-03-14 Thread 'Dan Kortschak' via golang-nuts
On Sun, 2021-03-14 at 10:41 -0700, Pascal de Kloe wrote:
> New MQTT client library + command line tool available.
>
> https://github.com/pascaldekloe/mqtt
>
> Comments are welcome.

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



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