summaryrefslogtreecommitdiff
path: root/pkg/pubsub/interface.go
blob: 63a12b34e11800062cd1e1ced0bc8fe9bbdf9320 (plain)
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
package pubsub

// PubSub ...
type PubSub interface {
	Publisher
	Subscriber
	Reader
}

// Subscriber defines the ability to operate as message passing broker.
type Subscriber interface {
	// Subscribe broker to one or multiple topics.
	Subscribe(topics ...string) error

	// Unsubscribe from one or multiply topics
	Unsubscribe(topics ...string) error
}

// Publisher publish one or more messages
type Publisher interface {
	// Publish one or multiple Channel.
	Publish(messages []byte) error

	// PublishAsync publish message and return immediately
	// If error occurred it will be printed into the logger
	PublishAsync(messages []byte)
}

// Reader interface should return next message
type Reader interface {
	Next() (*Message, error)
}