rabbitmq

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

func Consume

func Consume() (<-chan amqp.Delivery, error)

func Push

func Push(ctx context.Context, data []byte) error

func ReadMsgs

func ReadMsgs(ctx context.Context, maxAmount int, wait time.Duration, callback ReadMsgCallback)

func UnsafePush

func UnsafePush(ctx context.Context, data []byte) error

Types

type Client

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

func (*Client) Check

func (c *Client) Check(ctx context.Context) error

func (*Client) Close

func (client *Client) Close() error

func (*Client) Consume

func (client *Client) Consume() (<-chan amqp.Delivery, error)

func (*Client) Push

func (client *Client) Push(ctx context.Context, data []byte) error

func (*Client) ReadMsgs

func (client *Client) ReadMsgs(ctx context.Context, maxAmount int, wait time.Duration, callback ReadMsgCallback)

func (*Client) UnsafePush

func (client *Client) UnsafePush(ctx context.Context, data []byte) error

type Credentials

type Credentials struct {
	Host     string `mapstructure:"host"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

func (*Credentials) SourceString

func (r *Credentials) SourceString() string

type RabbitDelivery

type RabbitDelivery interface {
	// Ack acknowledges processing of a Delivery.
	Ack(multiple bool) error
	// Nack negatively acknowledges a Delivery.
	Nack(multiple bool, requeue bool) error
	// Reject rejects a delivery.
	Reject(requeue bool) error

	// Body returns the message body.
	Body() []byte

	// Acknowledger provides acknowledgement information.
	Acknowledger() amqp.Acknowledger
	// Header returns the message header.
	Header() amqp.Table
	// ContentType returns the message content type.
	ContentType() string
	// ContentEncoding returns the message content encoding.
	ContentEncoding() string
	// DeliveryMode returns the delivery mode.
	DeliveryMode() uint8
	// Priority returns the message priority.
	Priority() uint8
	// CorelationId returns the correlation id.
	CorelationId() string
	// ReplyTo returns the reply to value.
	ReplyTo() string
	// Expiration returns the message expiration.
	Expiration() string
	// MessageId returns the message id.
	MessageId() string
	// Timestamp returns the message timestamp.
	Timestamp() time.Time
	// Type returns the message type.
	Type() string
	// UserId returns the creating user id.
	UserId() string
	// AppId returns the creating application id.
	AppId() string
	// ConsumerTag returns the consumer tag.
	ConsumerTag() string
	// MessageCount returns the number of messages pending acknowledgement.
	MessageCount() uint32
	// DeliveryTag returns the delivery tag.
	DeliveryTag() uint64
	// Redelivered returns true if this message is being redelivered.
	Redelivered() bool
	// Exchange returns the exchange this message was published to.
	Exchange() string
	// RoutingKey returns the routing key used when publishing this message.
	RoutingKey() string
}

func NewDelivery

func NewDelivery(d amqp.Delivery) RabbitDelivery

type RabbitMQClient

type RabbitMQClient interface {
	Check(ctx context.Context) error
	ReadMsgs(ctx context.Context, maxAmount int, wait time.Duration, callback ReadMsgCallback)
	Push(ctx context.Context, data []byte) error
	UnsafePush(ctx context.Context, data []byte) error
	Consume() (<-chan amqp.Delivery, error)
	Close() error
}

func Init

func Init(ctx context.Context, queueName string, log logger.Logger, creds *Credentials) RabbitMQClient

type ReadMsgCallback

type ReadMsgCallback func(ctx context.Context, d RabbitDelivery) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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