Documentation ¶
Overview ¶
Package nats provides Gobot adaptor for the nats message service. Installing:
go get github.com/hybridgroup/gobot/platforms/nats
For further information refer to mqtt README: https://github.com/hybridgroup/gobot/blob/master/platforms/nats/README.md
Index ¶
- type NatsAdaptor
- func (a *NatsAdaptor) Connect() (errs []error)
- func (a *NatsAdaptor) Disconnect() (err error)
- func (a *NatsAdaptor) Finalize() (errs []error)
- func (a *NatsAdaptor) Name() string
- func (a *NatsAdaptor) On(event string, f func(s []byte)) bool
- func (a *NatsAdaptor) Publish(topic string, message []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NatsAdaptor ¶
type NatsAdaptor struct { Host string // contains filtered or unexported fields }
NatsAdaptor 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 NewNatsAdaptor ¶
func NewNatsAdaptor(name string, host string, clientID int) *NatsAdaptor
NewNatsAdaptor populates a new NatsAdaptor.
func NewNatsAdaptorWithAuth ¶
func NewNatsAdaptorWithAuth(name string, host string, clientID int, username string, password string) *NatsAdaptor
NewNatsAdaptorWithAuth populates a NatsAdaptor including username and password.
func (*NatsAdaptor) Connect ¶
func (a *NatsAdaptor) Connect() (errs []error)
Connect makes a connection to the Nats server.
func (*NatsAdaptor) Disconnect ¶
func (a *NatsAdaptor) Disconnect() (err error)
Disconnect from the nats server. Returns an error if the client doesn't exist.
func (*NatsAdaptor) Finalize ¶
func (a *NatsAdaptor) Finalize() (errs []error)
Finalize is simply a helper method for the disconnect.
func (*NatsAdaptor) Name ¶
func (a *NatsAdaptor) Name() string
Name returns the logical client name.