broker: improve option naming, move BatchBroker to Broker interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-07-24 16:16:18 +03:00
parent 9f3957d101
commit 5c9b3dae33
3 changed files with 66 additions and 52 deletions

View File

@@ -18,14 +18,6 @@ var (
ErrDisconnected = errors.New("broker disconnected")
)
type BatchBroker interface {
Broker
// BatchPublish messages to broker with multiple topics
BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error
// BatchSubscribe subscribes to topic messages via handler
BatchSubscribe(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error)
}
// Broker is an interface used for asynchronous messaging.
type Broker interface {
// Name returns broker instance name
@@ -44,6 +36,10 @@ type Broker interface {
Publish(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error
// Subscribe subscribes to topic message via handler
Subscribe(ctx context.Context, topic string, h Handler, opts ...SubscribeOption) (Subscriber, error)
// BatchPublish messages to broker with multiple topics
BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error
// BatchSubscribe subscribes to topic messages via handler
BatchSubscribe(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error)
// String type of broker
String() string
}