mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-23 08:56:29 +00:00
83577a7d5d
removed amber files. replacing with angular removed queue package in favor or worker package removed channel package in favor of pubsub package
28 lines
529 B
Go
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
|
|
}
|