Use DialMode/ListenMode

This commit is contained in:
Asim Aslam
2019-10-15 16:08:38 +01:00
parent ca934951ad
commit be5093798b
4 changed files with 11 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ func (t *tunBroker) Disconnect() error {
func (t *tunBroker) Publish(topic string, m *broker.Message, opts ...broker.PublishOption) error {
// TODO: this is probably inefficient, we might want to just maintain an open connection
// it may be easier to add broadcast to the tunnel
c, err := t.tunnel.Dial(topic, tunnel.DialMulticast())
c, err := t.tunnel.Dial(topic, tunnel.DialMode(tunnel.Multicast))
if err != nil {
return err
}
@@ -71,7 +71,7 @@ func (t *tunBroker) Publish(topic string, m *broker.Message, opts ...broker.Publ
}
func (t *tunBroker) Subscribe(topic string, h broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
l, err := t.tunnel.Listen(topic, tunnel.ListenMulticast())
l, err := t.tunnel.Listen(topic, tunnel.ListenMode(tunnel.Multicast))
if err != nil {
return nil, err
}

View File

@@ -95,18 +95,18 @@ func DefaultOptions() Options {
}
// Listen options
func ListenMulticast() ListenOption {
func ListenMode(m Mode) ListenOption {
return func(o *ListenOptions) {
o.Mode = Multicast
o.Mode = m
}
}
// Dial options
// Dial multicast sets the multicast option to send only to those mapped
func DialMulticast() DialOption {
func DialMode(m Mode) DialOption {
return func(o *DialOptions) {
o.Mode = Multicast
o.Mode = m
}
}

View File

@@ -13,7 +13,7 @@ const (
Unicast Mode = iota
// send to all channel listeners
Multicast
// send to all listeners
// send to all links
Broadcast
)