bus

package
v0.0.0-...-3f93e99 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidState      = errors.New("bus: invalid state")
	ErrInvalidConnection = errors.New("bus: invalid connection")
	ErrInvalidTransport  = errors.New("bus: invalid transport")
	ErrConnectionFailed  = errors.New("bus: connection failed")
)

Errors

Functions

func ConnectAndServe

func ConnectAndServe(ctx context.Context, conn Connection, tran Transport) error

ConnectAndServe starts bus

func Disconnect

func Disconnect()

Disconnect bus

func Logger

func Logger(l logger.Logger)

Logger set logger for default bus

func Publish

func Publish(topic string, message []byte) error

Publish message

Types

type Connection

type Connection interface {
	// Connect to broker
	Connect() error
	// Disconnect from broker
	Disconnect()
	// IsConnected status
	IsConnected() bool
	// Status of connection
	Status() <-chan struct{}
}

Connection interface

type HandleFunc

type HandleFunc func([]byte)

HandleFunc message func

func (HandleFunc) Handle

func (f HandleFunc) Handle(m []byte)

Handle message

type MessageHandler

type MessageHandler interface {
	// Handle message
	Handle([]byte)
}

MessageHandler interface

type Subscription

type Subscription interface {
	// Unsubscribe subscription
	Unsubscribe() error
}

Subscription unsubscribe existing subscription

func Subscribe

func Subscribe(topic string, handler MessageHandler) Subscription

Subscribe for messages

func SubscribeQueue

func SubscribeQueue(topic string, queue string, handler MessageHandler) Subscription

SubscribeQueue for messages

type Transport

type Transport interface {
	// Publish message
	Publish(topic string, message []byte) error
	// Subscribe for messages
	Subscribe(topic string, queue string, handler MessageHandler) (interface{}, error)
	// Unsubscribe subscription
	Unsubscribe(handle interface{}) error
}

Transport interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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