summaryrefslogtreecommitdiff
path: root/pkg/pubsub/interface.go
blob: 18c1a80cd99b55e3b2c7bdedac2b7e6957ef1fb3 (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
33
34
package pubsub

import "github.com/spiral/roadrunner/v2/pkg/pubsub/message"

// 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.Message, error)
}