-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
36 lines (31 loc) · 1.04 KB
/
interface.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
package pubsub
import (
"time"
"github.com/golang/protobuf/proto"
)
// Publisher is our generic publishing interface.
type Publisher interface {
// Publish will publish a protobuf message.
Publish(string, proto.Message) error
// PublishRaw will publish a raw byte array as a message.
PublishRaw(string, []byte) error
// Stop will initiate a graceful shutdown of the publisher connection and
// flush any remaining messages to be sent
Stop() error
}
// Subscriber is our generic subscriber interface.
type Subscriber interface {
// Start will return a channel of raw messages.
Start() <-chan SubscriberMessage
// Err will contain any errors returned from the consumer connection.
Err() error
// Stop will initiate a graceful shutdown of the subscriber connection.
Stop() error
}
// SubscriberMessage is a struct to encapsulate subscriber messages and provide
// a mechanism for acknowledging messages _after_ they've been processed.
type SubscriberMessage interface {
Message() []byte
ExtendDoneDeadline(time.Duration) error
Done() error
}