Documentation ¶
Overview ¶
Package nats provides Gobot adaptor for the nats message service. Installing:
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to nats README: https://github.com/hybridgroup/gobot/blob/master/platforms/nats/README.md
Index ¶
- Constants
- type Adaptor
- 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) 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 ¶
type Driver struct { gobot.Eventer gobot.Commander // contains filtered or unexported fields }
Driver for NATS
func (*Driver) Connection ¶
func (m *Driver) Connection() gobot.Connection
Connection returns Connections used by the Driver
func (*Driver) On ¶
On subscribes to data updates for the current device topic, and then calls the message handler function when data is received