mq_commons

package
v0.3.71 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name    = "MQ"
	Version = "0.1.0"

	ProtocolAmqp     = "amqp"
	ProtocolMQTT     = "mqtt"
	ProtocolMQTT_AWS = "mqtt-aws" // use AWS client
)

Variables

View Source
var (
	ErrorNilInstance          = errors.New("nil_instance_error")
	ErrorUnsupportedProtocol  = errors.New("unsupported_protocol_error")
	ErrorMissingConfiguration = errors.New("missing_configuration_error")
	ErrorMissingConnection    = errors.New("missing_connection_error")
	ErrorConnectionIsClosed   = errors.New("closed_connection_error")
)

Functions

This section is empty.

Types

type DriverConfig

type DriverConfig struct {
	Protocol string `json:"protocol"` // amqp, ...
	Secret   string `json:"secret"`
}

type IDriver

type IDriver interface {
	Close() error
	Ping() (bool, error) // test connection
	Info() string        // printable properties

	QueueDeclare(settings interface{}) (interface{}, error)    // queue declare
	QueueDelete(name string, args ...interface{}) (int, error) // queue delete
	QueueInspect(name string) (interface{}, error)             // queue inspect
	QueuePurge(name string, args ...interface{}) (int, error)  // queue clean
	QueueBind(settings interface{}) error
	QueueUnbind(settings interface{}) error

	ExchangeDeclare(settings interface{}) error
	ExchangeDelete(name string, args ...interface{}) error
	ExchangeBind(settings interface{}) error
	ExchangeUnbind(settings interface{}) error

	RpcCommand(rpcChannel string, emitterSettings, listenerSettings interface{}, rawMessage interface{}, callback ListenerHandler, timeout time.Duration) error

	NewEmitter(settings interface{}) (IEmitter, error)   // send messages
	NewListener(settings interface{}) (IListener, error) // consume messages

	NotifyDisconnection(connectionCloseCallback func())
}

IDriver connection

type IEmitter

type IEmitter interface {
	Close() error
	Emit(rawSignal interface{}) error
}

IEmitter send/publish messages

type IListener

type IListener interface {
	Close() error
	Listen(ListenerHandler) error
	Join()
	JoinTimeout(d time.Duration)
}

IListener listen/consume messages

type ListenerHandler

type ListenerHandler func(message map[string]interface{})

Jump to

Keyboard shortcuts

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