Documentation ¶
Overview ¶
Package nats provides Gobot adaptor for the nats message service. Installing:
go get gobot.io/x/gobot/platforms/nats
For further information refer to mqtt README: https://github.com/hybridgroup/gobot/blob/master/platforms/nats/README.md
Index ¶
- Constants
- type Adaptor
- func (a *Adaptor) Connect() (err error)
- func (a *Adaptor) Disconnect() (err error)
- func (a *Adaptor) Finalize() (err error)
- func (a *Adaptor) Name() string
- func (a *Adaptor) On(event string, f func(msg Message)) bool
- func (a *Adaptor) Publish(topic string, message []byte) bool
- func (a *Adaptor) SetName(n string)
- type Driver
- func (m *Driver) Connection() gobot.Connection
- func (m *Driver) Halt() error
- func (m *Driver) Name() string
- func (m *Driver) On(n string, f func(msg Message)) error
- func (m *Driver) Publish(data interface{}) bool
- func (m *Driver) SetName(name string)
- func (m *Driver) SetTopic(topic string)
- func (m *Driver) Start() error
- func (m *Driver) Topic() string
- type Message
Constants ¶
const ( // Data event when data is available for Driver Data = "data" // Error event when error occurs in Driver Error = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adaptor ¶
type Adaptor struct { Host string // contains filtered or unexported fields }
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.
func NewAdaptor ¶
NewAdaptor populates a new NATS Adaptor.
func NewAdaptorWithAuth ¶
func NewAdaptorWithAuth(host string, clientID int, username string, password string, options ...nats.Option) *Adaptor
NewAdaptorWithAuth populates a NATS Adaptor including username and password.
func (*Adaptor) Disconnect ¶
Disconnect from the nats server.
func (*Adaptor) On ¶
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.
type Driver ¶ added in v1.2.0
Driver for NATS
func (*Driver) Connection ¶ added in v1.2.0
func (m *Driver) Connection() gobot.Connection
Connection returns Connections used by the Driver
func (*Driver) On ¶ added in v1.2.0
On subscribes to data updates for the current device topic, and then calls the message handler function when data is received