jazz

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MESSAGE_TTL      = "x-message-ttl"
	DEAD_EXCHANGE    = "x-dead-letter-exchange"
	DEAD_ROUTING_KEY = "x-dead-letter-routing-key"
)

Variables

This section is empty.

Functions

func DeadLetterArgs

func DeadLetterArgs(ttl int, exchange, toQueue string) amqp.Table

Types

type Binding

type Binding struct {
	Exchange string `yaml:"exchange"`
	Key      string `yaml:"key"`
	Nowait   bool   `yaml:"nowait"`
}

Binding specifies to which exchange should be an exchange or a queue binded

type Connection

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

Connection is a struct which holds all necessary data for RabbitMQ connection

func Connect

func Connect(dsn string) (*Connection, error)

Connect connects to RabbitMQ by dsn and return Connection object which uses openned connection during function calls issued later in code

func (*Connection) Close

func (c *Connection) Close() error

Close closes connection to RabbitMQ

func (*Connection) CreateScheme

func (c *Connection) CreateScheme(s Settings) error

CreateScheme creates all exchanges, queues and bindinges between them as specified in yaml string

func (*Connection) DeleteScheme

func (c *Connection) DeleteScheme(s Settings) error

DeleteScheme deletes all queues and exchanges (together with bindings) as specified in yaml string

func (*Connection) ProcessQueue

func (c *Connection) ProcessQueue(name string, f func([]byte)) error

ProcessQueue calls handler function on each message delivered to a queue

func (*Connection) SendBlob

func (c *Connection) SendBlob(ex, key string, msg []byte) error

SendBlob publishes byte blob message to an exchange with specific routing key

func (*Connection) SendMessage

func (c *Connection) SendMessage(ex, key, msg string) error

SendMessage publishes plain text message to an exchange with specific routing key

type Exchange

type Exchange struct {
	Durable    bool      `yaml:"durable"`
	Autodelete bool      `yaml:"autodelete"`
	Internal   bool      `yaml:"internal"`
	Nowait     bool      `yaml:"nowait"`
	Type       string    `yaml:"type"`
	Bindings   []Binding `yaml:"bindings"`
}

Exchange is structure with specification of properties of RabbitMQ exchange

type QueueSpec

type QueueSpec struct {
	Durable    bool       `yaml:"durable"`
	Autodelete bool       `yaml:"autodelete"`
	Nowait     bool       `yaml:"nowait"`
	Exclusive  bool       `yaml:"exclusive"`
	Bindings   []Binding  `yaml:"bindings"`
	Args       amqp.Table `yaml:"args"`
}

QueueSpec is a specification of properties of RabbitMQ queue

type Settings

type Settings struct {
	Exchanges map[string]Exchange  `yaml:"exchanges"`
	Queues    map[string]QueueSpec `yaml:"queues"`
}

Settings is a specification of all queues and exchanges together with all bindings.

func DecodeYaml

func DecodeYaml(r io.Reader) (Settings, error)

DecodeYaml reads yaml with specification of all exchanges and queues from io.Reader

Jump to

Keyboard shortcuts

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