Subscription is a black box

This commit is contained in:
Gregory Eremin 2014-09-10 17:34:39 +04:00
parent d913f52efa
commit 76403807db

View File

@ -2,20 +2,30 @@ package hub
type ( type (
Subscription struct { Subscription struct {
Queue string queues []string
result chan<- []byte result chan<- []byte
done chan struct{} done chan struct{}
} }
) )
func NewSubscription(queue string, result chan<- []byte) *Subscription { func NewSubscription(queues []string, result chan<- []byte) *Subscription {
return &Subscription{ return &Subscription{
Queue: queue, queues: queues,
result: result, result: result,
done: make(chan struct{}), 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 { func (s *Subscription) Send(msg []byte) bool {
success := make(chan bool) success := make(chan bool)