woodpecker/server/pubsub/subscribe.go
Brad Rydzewski 83577a7d5d removed css files. designers will be providing
removed amber files. replacing with angular
removed queue package in favor or worker package
removed channel package in favor of pubsub package
2014-06-21 14:22:38 -07:00

28 lines
529 B
Go

package pubsub
type Subscription struct {
channel *Channel
closed chan bool
send chan interface{}
}
func NewSubscription(channel *Channel) *Subscription {
return &Subscription{
channel: channel,
closed: make(chan bool),
send: make(chan interface{}),
}
}
func (s *Subscription) Read() <-chan interface{} {
return s.send
}
func (s *Subscription) Close() {
go func() { s.channel.unsubscribe <- s }()
go func() { s.closed <- true }()
}
func (s *Subscription) CloseNotify() <-chan bool {
return s.closed
}