1
0
Fork 0

Rename result into message

This commit is contained in:
Gregory Eremin 2014-09-24 16:52:31 +04:00
parent 424dacae5b
commit d74792a591
2 changed files with 8 additions and 8 deletions

View File

@ -35,7 +35,7 @@ func (h *Hub) Pub(queue string, msg []byte) bool {
default:
}
if ok := s.Send(Result{queue, msg}); ok {
if ok := s.Send(Message{queue, msg}); ok {
return true
}
}
@ -49,7 +49,7 @@ func (h *Hub) Pub(queue string, msg []byte) bool {
func (h *Hub) Sub(s *Subscription) {
for _, q := range s.Queues {
if msg, ok := h.storage.Get(q); ok {
s.Send(Result{q, msg})
s.Send(Message{q, msg})
return
}
}

View File

@ -3,10 +3,10 @@ package hub
type (
Subscription struct {
Queues []string
result chan Result
result chan Message
done chan struct{}
}
Result struct {
Message struct {
Queue string
Message []byte
}
@ -15,7 +15,7 @@ type (
func NewSubscription(queues []string) *Subscription {
return &Subscription{
Queues: queues,
result: make(chan Result),
result: make(chan Message),
done: make(chan struct{}),
}
}
@ -30,7 +30,7 @@ func (s *Subscription) Need(queue string) bool {
return false
}
func (s *Subscription) Send(res Result) bool {
func (s *Subscription) Send(msg Message) bool {
success := make(chan bool)
go func() {
@ -40,14 +40,14 @@ func (s *Subscription) Send(res Result) bool {
}
}()
s.result <- res
s.result <- msg
success <- true
}()
return <-success
}
func (s *Subscription) Result() <-chan Result {
func (s *Subscription) Result() <-chan Message {
return s.result
}