nats: use new improved default namer to avoid API conflicts
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
254068c14d
commit
3e52fb38f8
|
@ -1,6 +1,9 @@
|
|||
package nats
|
||||
|
||||
import "github.com/nats-io/nats"
|
||||
import (
|
||||
"github.com/nats-io/nats"
|
||||
"gobot.io/x/gobot"
|
||||
)
|
||||
|
||||
// Adaptor is a configuration struct for interacting with a NATS server.
|
||||
// Name is a logical name for the adaptor/nats server connection.
|
||||
|
@ -19,7 +22,7 @@ type Adaptor struct {
|
|||
// NewAdaptor populates a new NATS Adaptor.
|
||||
func NewAdaptor(host string, clientID int) *Adaptor {
|
||||
return &Adaptor{
|
||||
name: "NATS",
|
||||
name: gobot.DefaultName("NATS"),
|
||||
Host: host,
|
||||
clientID: clientID,
|
||||
connect: func() (*nats.Conn, error) {
|
||||
|
|
|
@ -22,7 +22,7 @@ type Driver struct {
|
|||
// NewDriver returns a new Gobot NATS Driver
|
||||
func NewDriver(a *Adaptor, topic string) *Driver {
|
||||
m := &Driver{
|
||||
name: "NATS",
|
||||
name: gobot.DefaultName("NATS"),
|
||||
topic: topic,
|
||||
connection: a,
|
||||
Eventer: gobot.NewEventer(),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package nats
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gobot.io/x/gobot"
|
||||
|
@ -12,8 +13,8 @@ var _ gobot.Driver = (*Driver)(nil)
|
|||
func TestNatsDriver(t *testing.T) {
|
||||
d := NewDriver(initTestNatsAdaptor(), "/test/topic")
|
||||
|
||||
gobottest.Assert(t, d.Name(), "NATS")
|
||||
gobottest.Assert(t, d.Connection().Name(), "NATS")
|
||||
gobottest.Assert(t, strings.HasPrefix(d.Name(), "NATS"), true)
|
||||
gobottest.Assert(t, strings.HasPrefix(d.Connection().Name(), "NATS"), true)
|
||||
|
||||
gobottest.Assert(t, d.Start(), nil)
|
||||
gobottest.Assert(t, d.Halt(), nil)
|
||||
|
|
Loading…
Reference in New Issue