func (n *ntport) Dial(addr string, opts ...transport.DialOption) (transport.Client, error) { cAddr := nats.DefaultURL if len(n.addrs) > 0 && strings.HasPrefix(n.addrs[0], "nats://") { cAddr = n.addrs[0] } c, err := nats.Connect(cAddr) if err != nil { return nil, err } id := nats.NewInbox() sub, err := c.SubscribeSync(id) if err != nil { return nil, err } return &ntportClient{ conn: c, addr: addr, id: id, sub: sub, }, nil }
func (n *ntport) Listen(addr string) (transport.Listener, error) { cAddr := nats.DefaultURL if len(n.addrs) > 0 && strings.HasPrefix(n.addrs[0], "nats://") { cAddr = n.addrs[0] } c, err := nats.Connect(cAddr) if err != nil { return nil, err } return &ntportListener{ addr: nats.NewInbox(), conn: c, exit: make(chan bool, 1), }, nil }