[ANN] MQTT🤖

85 views
Skip to first unread message

Pascal de Kloe

unread,
Mar 14, 2021, 1:41:25 PM3/14/21
to golang-nuts
New MQTT client library + command line tool available.

https://github.com/pascaldekloe/mqtt

Comments are welcome.

Dan Kortschak

unread,
Mar 14, 2021, 5:07:26 PM3/14/21
to golan...@googlegroups.com
Did you consider using context.Context rather than quit channels?



Pascal de Kloe

unread,
Mar 14, 2021, 6:08:44 PM3/14/21
to golang-nuts
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()

}

Dan Kortschak

unread,
Mar 14, 2021, 6:34:16 PM3/14/21
to golan...@googlegroups.com
Thanks. That's a yes.

Dan


Reply all
Reply to author
Forward
0 new messages