-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubsub.go
52 lines (42 loc) · 1.12 KB
/
pubsub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package templates
import (
"errors"
"time"
"github.com/qp/go"
"github.com/stretchr/pat/stop"
)
// PubSub represents a qp.PubSubTransport.
type PubSub struct {
stopChan chan stop.Signal
}
// ensure the interface is satisfied
var _ qp.PubSubTransport = (*PubSub)(nil)
// NewPubSub makes a new PubSub.
func NewPubSub() *PubSub {
p := &PubSub{
stopChan: stop.Make(),
}
return p
}
// Publish publishes data on the specified channel.
func (p *PubSub) Publish(channel string, data []byte) error {
return errors.New("not implemented")
}
// Subscribe binds the handler to the specified channel.
func (p *PubSub) Subscribe(channel string, handler qp.Handler) error {
return errors.New("not implemented")
}
// Start starts the transport.
func (p *PubSub) Start() error {
return errors.New("not implemented")
}
// Stop stops the transport and closes StopChan() when finished.
func (p *PubSub) Stop(grace time.Duration) {
// do work to stop
close(p.stopChan)
}
// StopChan gets the stop channel which will be closed when
// this transport has successfully stopped.
func (p *PubSub) StopChan() <-chan stop.Signal {
return p.stopChan
}