Categorygithub.com/zerosvc/go-zerosvc
repositorypackage
1.1.1
Repository: https://github.com/zerosvc/go-zerosvc.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

go-zeromq

godoc

Go bindings for zerosvc

Event field mapping

MQTTv3 format is whole event serialized into JSON AMQP/MQTTv5 uses headers and puts body as-is

eventMQTTv3MQTTv5 (future)AMQP
Reply tobody jsonUserProperty[reply_to]Header[reply_to]
RedeliveredDUP transport flagDUP transport flagredelivered flag
RetainTillretain flag (NO TTL)retain + Expiryno support
Headersbody JSONUserPropertyHeaders[]
Bodybody JSON['body']BodyBody
  • extra transport control headers:
header keyMQTTv3MQTTv5AMQP
_transport_ttl---ExpiryTTL
node-name---retainedAppId
correlation-id---retainedCorrelationId
user-id---retainedUserId

other:

  • topic of incoming messages is encoded in `RoutingKey

MQTT URL options

  • username/pass - same as basic auth e.g. tcp://mqttuser:[email protected]:1883
  • TLS - just change proto to tls - tls://mqtt.example.com:8883
  • query options
    • CA - tls://mqtt.example.com:8883/?ca=/my/ca/path.crt
    • client cert (key + cert in one file) - tls://mqtt.example.com:8883/?cert=/path/certandkey.pem
    • client cert (key, cert in separate file) - tls://mqtt.example.com:8883/?cert=/path/cert.pem&certkey=/path/certkey.pem

Examples

Create node

tr := zerosvc.NewTransport(zerosvc.TransportMQTT,"tcp://127.0.0.1:1883",zerosvc.TransportMQTTConfig{})
	node := zerosvc.NewNode("unique-node-name")
	tr.Connect()
	node.SetTransport(tr)

prepare and send event. Prepare() takes care of checksums/signatures for the event

	e := zerosvc.Event{
		Headers:    map[string]interface{}{
			"test": "header",
		},
		Body:        []byte("hay"),
	}
	e.Prepare()
	node.SendEvent("dpp/ev",e)

Quirks

  • Due to how MQTT libraries work only first user/password is used for all urls.