-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscribe.go
31 lines (25 loc) · 845 Bytes
/
subscribe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package doorman
import (
"github.com/didiercrunch/doorman/nanomsgsubscriber"
"github.com/didiercrunch/doorman/nsqsubscriber"
"github.com/didiercrunch/doorman/shared"
"github.com/didiercrunch/doorman/subscriber"
)
type Subscriber interface {
Subscribe(doormanId string, update shared.UpdateHandlerFunc) error
}
func (w *Doorman) subscribe(sub Subscriber) error {
return sub.Subscribe(w.Id, w.Update)
}
func (w *Doorman) NSQSubscriber(NSQLookupdURl string) error {
sub := &nsqsubscriber.NSQSubscriber{NSQLookupdURl}
return w.subscribe(sub)
}
func (w *Doorman) NanoMsgSubscriber(NanoMsgUrlLookupdURl string) error {
sub := &nanomsgsubscriber.NanoMsgSubscriber{NanoMsgUrlLookupdURl}
return w.subscribe(sub)
}
func (w *Doorman) Subscriber(serverUrl string) error {
sub := &subscriber.Subscriber{serverUrl}
return w.subscribe(sub)
}