infrarabbit

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PriorityProperty = "x-max-priority" // deprecated, use QueueArgs
)

Variables

View Source
var (
	ErrBinderIsClosed              = errors.New("binder is closed")
	ErrUnableToCloseConnection     = errors.New("unable to close connection")
	ErrUnableToDeclareExchange     = errors.New("unable to declare exchange")
	ErrUnableToDeclareQueue        = errors.New("unable to declare queue")
	ErrUnableToBindQueueToExchange = errors.New("unable to bind queue to exchange")
)
View Source
var (
	ErrConfigIsRequired = errors.New("config is required")
	ErrConfigNotFound   = errors.New("config is not found")
)
View Source
var (
	ErrMessageIsNil             = errors.New("message is nil")
	ErrProducerClosed           = errors.New("producer is closed")
	ErrClosingProducer          = errors.New("error while closing producer")
	ErrUnableToBind             = errors.New("unable to perform binding")
	ErrUnableToCreateChannel    = errors.New("unable to get channel in connection to RabbitMQ")
	ErrUnableToCreateConnection = errors.New("unable to connect to RabbitMQ")
)
View Source
var (
	ErrAddressIsRequired = errors.New("address is mandatory")
)

Functions

This section is empty.

Types

type BindConfig

type BindConfig struct {
	Exchange   string // required
	RoutingKey string // required
	Queue      string // required

	// optional
	ExchangeKind       Kind
	ExchangeDurable    bool
	ExchangeAutoDelete bool
	ExchangeInternal   bool
	ExchangeNoWait     bool
	ExchangeArgs       map[string]interface{}
	QueueDurable       bool
	QueueAutoDelete    bool
	QueueExclusive     bool
	QueueNoWait        bool
	QueueArgs          map[string]interface{}
	BindNoWait         bool
	BindArgs           map[string]interface{}
}

type Binder added in v1.7.1

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

func NewBinder

func NewBinder(config *ConnectionConfig) (*Binder, error)

func (*Binder) Bind added in v1.7.1

func (b *Binder) Bind(config *BindConfig) error

func (*Binder) Close added in v1.7.1

func (b *Binder) Close() error

type ConnectionConfig

type ConnectionConfig struct {
	Address  string `mapstructure:"address"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Vhost    string `mapstructure:"vhost"`
}

func (*ConnectionConfig) Validate

func (c *ConnectionConfig) Validate() error

type ConnectionsConfig

type ConnectionsConfig map[string]*ConnectionConfig

func (*ConnectionsConfig) Validate

func (c *ConnectionsConfig) Validate() error

type Consumer

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

func (*Consumer) Close

func (c *Consumer) Close() error

func (*Consumer) Consume

func (c *Consumer) Consume() chan *Message

type ConsumerConfig

type ConsumerConfig struct {
	ConnectionName string
	Queue          string
	QueueDurable   bool                   // optional
	QueuePriority  uint8                  // deprecated
	QueueArgs      map[string]interface{} // optional
	PrefetchCount  int                    // optional
	Tag            string                 // optional
	Metrics        *ConsumerMetrics       // optional
}

type ConsumerMetrics added in v1.6.6

type ConsumerMetrics struct {
	CheckInterval time.Duration                         // optional
	QueueLength   func(host, queue string, value int64) // optional
	QueueDelay    func(host, queue string, value int64) // optional
}

type Container

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

Container is a simple container for holding named rabbit connections.

func NewContainer

func NewContainer() *Container

func (*Container) AddConnection

func (cont *Container) AddConnection(name string, cfg *ConnectionConfig) error

AddConnection adds a named connection to a container. It's possible to create consumer or producer on created connection later using CreateProducer ot CreateConsumer.

func (*Container) CreateConsumer

func (cont *Container) CreateConsumer(consumerCfg *ConsumerConfig) (*Consumer, error)

CreateConsumer creates a new rabbit consumer by a connection name and subscribes it to a given queue

func (*Container) CreateProducer

func (cont *Container) CreateProducer(producerCfg *ProducerConfig) (*Producer, error)

type Kind

type Kind string
const KindDirect Kind = "direct"
const KindFanOut Kind = "fanout"
const KindHeaders Kind = "headers"
const KindTopic Kind = "topic"

type Message

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

func (*Message) Ack

func (m *Message) Ack() error

func (*Message) Body

func (m *Message) Body() []byte

func (*Message) IsRedelivered

func (m *Message) IsRedelivered() bool

func (*Message) Nack

func (m *Message) Nack() error

type Producer

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

func (*Producer) Close

func (p *Producer) Close() error

func (*Producer) Produce

func (p *Producer) Produce(pCtx context.Context, msg *ProducerMessage) error

type ProducerConfig

type ProducerConfig struct {
	ConnectionName string
	Tag            string // optional
	Bindings       []*BindConfig
}

type ProducerMessage added in v1.5.0

type ProducerMessage struct {
	Body       []byte
	Exchange   string
	RoutingKey string
	Priority   uint8
}

Directories

Path Synopsis
examples
consumer command
producer command

Jump to

Keyboard shortcuts

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