1
0
Fork 0

Subscription is a black box

This commit is contained in:
Gregory Eremin 2014-09-10 17:34:39 +04:00
parent d913f52efa
commit 76403807db
1 changed files with 13 additions and 3 deletions

View File

@ -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)