rabbitmq

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeliveryModeTransient  = 1
	DeliveryModePersistent = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(config *Config) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Process

func (c *Client) Process(ctx context.Context, cmd Command) error

type Command

type Command func(ctx context.Context, conn *connpool.Conn) error

type Config

type Config struct {
	Address string

	AMQP amqp.Config

	// Maximum number of retries before giving up.
	// Default is 3 retries; -1 (not 0) disables retries.
	MaxRetries int
	// Minimum backoff between each retry.
	// Default is 8 milliseconds; -1 disables backoff.
	MinRetryBackoff time.Duration
	// Maximum backoff between each retry.
	// Default is 512 milliseconds; -1 disables backoff.
	MaxRetryBackoff time.Duration

	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout time.Duration

	// Type of connection pool.
	// true for FIFO pool, false for LIFO pool.
	// Note that fifo has higher overhead compared to lifo.
	PoolFIFO bool
	// Maximum number of socket connections.
	// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
	PoolSize int
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns int
	// Connection age at which client retires (closes) the connection.
	// Default is to not close aged connections.
	MaxConnAge time.Duration
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout time.Duration
	// Amount of time after which client closes idle connections.
	// Should be less than server's timeout.
	// Default is 5 minutes. -1 disables idle timeout check.
	IdleTimeout time.Duration
	// Frequency of idle checks made by idle connections reaper.
	// Default is 1 minute. -1 disables idle connections reaper,
	// but idle connections are still discarded by the client
	// if IdleTimeout is set.
	IdleCheckFrequency time.Duration

	// Limiter interface used to implemented circuit breaker or rate limiter.
	Limiter Limiter
}

type Limiter

type Limiter interface {
	// Allow returns nil if operation is allowed or an error otherwise.
	// If operation is allowed client must ReportResult of the operation
	// whether it is a success or a failure.
	Allow() error
	// ReportResult reports the result of the previously allowed operation.
	// nil indicates a success, non-nil error usually indicates a failure.
	ReportResult(result error)
}

type Receiver

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

func NewReceiver

func NewReceiver(client *Client, opts ...ReceiverOption) *Receiver

func (*Receiver) Receive

func (r *Receiver) Receive(ctx context.Context, processor eventbus.Processor) error

func (*Receiver) Setup

func (r *Receiver) Setup(ctx context.Context, consumerName string, infos ...eventbus.ServiceInfo) error

type ReceiverOption

type ReceiverOption func(o *receiverOptions)

func WithDLX

func WithDLX() ReceiverOption

func WithMessageParser

func WithMessageParser(p message.Parser) ReceiverOption

func WithPrefetchCount

func WithPrefetchCount(c int) ReceiverOption

func WithTopologySetup

func WithTopologySetup() ReceiverOption

func WithWorkerNum

func WithWorkerNum(c int) ReceiverOption

type Sender

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

func NewSender

func NewSender(client *Client, opts ...SenderOption) *Sender

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, meta *event.Metadata, data []byte) error

func (*Sender) Setup

func (s *Sender) Setup(ctx context.Context, desc *eventbus.ServiceDesc) error

type SenderOption

type SenderOption func(opts *senderOptions)

func WithMessageFormatter

func WithMessageFormatter(f message.Formatter) SenderOption

func WithTransientDeliveryMode

func WithTransientDeliveryMode() SenderOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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