broker

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

BrokerWrapper is a struct that wrap the broker provider (gcp, rabbitmq, etc) and handle with message encode/decode

func NewBroker

func NewBroker(logger logger.Logger, provider BrokerProvider) *Broker

func (*Broker) GracefulStop

func (b *Broker) GracefulStop(ctx context.Context) error

GracefulStop graceful stop all subscriptions

func (*Broker) Init

func (b *Broker) Init(opts *InitOptions)

func (*Broker) Publish

func (b *Broker) Publish(ctx context.Context, topic string, m interface{}) error

Publish is a call to the broker publish with encoded message

func (*Broker) Subscribe

func (b *Broker) Subscribe(ctx context.Context, topic string, handler interface{})

Publish is a call to the broker publish with encoded message

type BrokerProvider

type BrokerProvider interface {
	Init(opts *InitOptions)
	Publish(ctx context.Context, topic string, msg *Message) error
	Subscribe(ctx context.Context, topic string, handler SubscribeHandler) error
	GracefulStop(ctx context.Context) error
}

type InitOptions

type InitOptions struct {
	Logger logger.Logger
}

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

type SubscribeHandler

type SubscribeHandler func(ctx context.Context, msg *Message)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL