import "gobot.io/x/gobot/platforms/nats"
Package nats provides Gobot adaptor for the nats message service. Installing:
go get gobot.io/x/gobot/platforms/nats
For further information refer to nats README: https://github.com/hybridgroup/gobot/blob/master/platforms/nats/README.md
doc.go nats_adaptor.go nats_driver.go
const ( // Data event when data is available for Driver Data = "data" // Error event when error occurs in Driver Error = "error" )
Adaptor is a configuration struct for interacting with a NATS server. Name is a logical name for the adaptor/nats server connection. Host is in the form "localhost:4222" which is the hostname/ip and port of the nats server. ClientID is a unique identifier integer that specifies the identity of the client.
NewAdaptor populates a new NATS Adaptor.
func NewAdaptorWithAuth(host string, clientID int, username string, password string, options ...nats.Option) *Adaptor
NewAdaptorWithAuth populates a NATS Adaptor including username and password.
Connect makes a connection to the Nats server.
Disconnect from the nats server.
Finalize is simply a helper method for the disconnect.
Name returns the logical client name.
On is an event-handler style subscriber to a particular topic (named event). Supply a handler function to use the bytes returned by the server.
Publish sends a message with the particular topic to the nats server.
SetName sets the logical client name.
Driver for NATS
NewDriver returns a new Gobot NATS Driver
func (m *Driver) Connection() gobot.Connection
Connection returns Connections used by the Driver
Halt halts the Driver
Name returns name for the Driver
On subscribes to data updates for the current device topic, and then calls the message handler function when data is received
Publish a message to the current device topic
SetName sets name for the Driver
SetTopic sets the current topic for the Driver
Start starts the Driver
Topic returns the current topic for the Driver
Message is a message received from the server.
Package nats imports 4 packages (graph) and is imported by 1 packages. Updated 2019-10-16. Refresh now. Tools for package owners.