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

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

# Packages

No description provided by the author

# Functions

GetFQDN tries to get fqdn from os (via hostname) and fails back on system resolver.
No description provided by the author
NewSignerEd25519 returns new signer; if key is not specified the new random one will be generated.
ID will be mangled to fit 23 characters if it is longer or replaced with client cert ID willPath points to path where the retain=true empty message will be sent on disconnect to be used with heartbeats to auto-clear presence informatio.
No description provided by the author
No description provided by the author

# Constants

raw 25519 public key.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
verifier is subset of signer that only does message verify.

# Type aliases

Time defines a flexible timestamp that is serialized as float but deserialized from int/float/text.