Subscription is a black box
This commit is contained in:
parent
d913f52efa
commit
76403807db
@ -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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user