Subscription is a black box
This commit is contained in:
parent
d913f52efa
commit
76403807db
|
@ -2,20 +2,30 @@ package hub
|
|||
|
||||
type (
|
||||
Subscription struct {
|
||||
Queue string
|
||||
queues []string
|
||||
result chan<- []byte
|
||||
done chan struct{}
|
||||
}
|
||||
)
|
||||
|
||||
func NewSubscription(queue string, result chan<- []byte) *Subscription {
|
||||
func NewSubscription(queues []string, result chan<- []byte) *Subscription {
|
||||
return &Subscription{
|
||||
Queue: queue,
|
||||
queues: queues,
|
||||
result: result,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Subscription) Need(queue string) bool {
|
||||
for _, q := range s.queues {
|
||||
if q == queue {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Subscription) Send(msg []byte) bool {
|
||||
success := make(chan bool)
|
||||
|
||||
|
|
Loading…
Reference in New Issue