rabbit

package
v0.0.0-...-6701837 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close closes all RabbitMQ connections

func Initialize

func Initialize(ctx context.Context)

func Publish

func Publish(in Job, cnt string) error

func RegisterConsumer

func RegisterConsumer(consumer Consumer, cnt string) error

func RegisterRabbit

func RegisterRabbit(cnt, host, user, password, vHost string, port int)

func RegisterRabbitMq

func RegisterRabbitMq(name, host string, port int, user, password, vhost string)

RegisterRabbitMq is an alias for RegisterRabbit

Types

type Channel

type Channel interface {
	Confirm(noWait bool) error
	NotifyPublish(confirm chan amqp.Confirmation) chan amqp.Confirmation
	Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error
	Close() error
}

type Connection

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

Connection wraps RabbitMQ operations

func GetConnection

func GetConnection(name string) (*Connection, error)

GetConnection returns RabbitMQ connection wrapper

func (*Connection) Consume

func (c *Connection) Consume(ctx context.Context, queue string, handler func([]byte) error) error

Consume consumes messages from queue

func (*Connection) Publish

func (c *Connection) Publish(ctx context.Context, queue string, body []byte) error

Publish publishes a message to queue

func (*Connection) PublishJSON

func (c *Connection) PublishJSON(ctx context.Context, queue string, data interface{}) error

PublishJSON publishes JSON message

type Consumer

type Consumer interface {
	// Topic return the topic that this worker want to listen to it
	Topic() string
	// Queue is the queue that this want to listen to
	Queue() string
	// Consume return a channel to put jobs into
	Consume(context.Context) chan<- Delivery
}

Consumer is the side the workers on it

type Delivery

type Delivery interface {
	Decode(v interface{}) error
	// Ack delegates an acknowledgement through the Acknowledger interface that the client or server has finished work on a delivery.
	Ack(multiple bool) error
	// Nack negatively acknowledge the delivery of message(s) identified by the delivery tag from either the client or server.
	Nack(multiple, requeue bool) error
	// Reject delegates a negatively acknowledgement through the Acknowledger interface.
	Reject(requeue bool) error
}

Delivery is the job to consumer

type Job

type Job interface {
	Encode() ([]byte, error)
	Length() int
	Topic() string
}

Jump to

Keyboard shortcuts

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