Documentation ¶
Index ¶
- Constants
- type Pool
- func NewPool(addr, user, host, vhost, tag, exchange, queue, key string, ...) (*Pool, error)
- func NewPoolWithConfig(config *rabbitmq.Config, ...) (*Pool, error)
- func NewPoolWithDefault(addr, user, host, vhost, tag, exchange, queue, key string) (*Pool, error)
- func NewPoolWithPoolConfig(config *rabbitmq.PoolConfig) (*Pool, error)
- type PoolProducer
- type Producer
- func (p *Producer) BuildMessage(contentType, message string) amqp.Publishing
- func (p *Producer) BuildMessageWithExpiration(contentType, message string, expiration int) amqp.Publishing
- func (p *Producer) Channel() (*amqp.Channel, error)
- func (p *Producer) Close() error
- func (p *Producer) Disconnect() error
- func (p *Producer) ExchangeDeclare(kind string) error
- func (p *Producer) Publish(msg amqp.Publishing) error
- func (p *Producer) PublishJSON(message string) error
- func (p *Producer) PublishWithContext(ctx context.Context, msg amqp.Publishing) error
- func (p *Producer) QueueBind() error
- func (p *Producer) QueueDeclare() error
Constants ¶
const ( DefaultMaxConnections = 20 DefaultInitConnections = 5 DefaultMaxIdleConnections = 10 DefaultMaxIdleTime = 1800 // seconds DefaultMaxWaitTime = 1 // seconds DefaultMaxRetryCount = -1 DefaultKeepAliveInterval = 300 // seconds DefaultKeepAliveChunkSize = 5 DefaultSleepTime = 1 // seconds DefaultFreeChanLengthTimes = 2 DefaultUnlimitedWaitTime = -1 // seconds DefaultUnlimitedRetryCount = -1 DefaultDelayTime = 5 // milliseconds )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct { sync.Mutex *rabbitmq.PoolConfig // contains filtered or unexported fields }
func NewPool ¶
func NewPool(addr, user, host, vhost, tag, exchange, queue, key string, maxConnections, initConnections, maxIdleConnections, maxIdleTime, maxWaitTime, maxRetryCount, keepAliveInterval int) (*Pool, error)
NewPool returns a new *Pool
func NewPoolWithConfig ¶
func NewPoolWithConfig(config *rabbitmq.Config, maxConnections, initConnections, maxIdleConnections, maxIdleTime, maxWaitTime, maxRetryCount, keepAliveInterval int) (*Pool, error)
NewPoolWithConfig returns a new *Pool with a Config object
func NewPoolWithDefault ¶
NewPoolWithDefault returns a new *Pool with default configuration
func NewPoolWithPoolConfig ¶
func NewPoolWithPoolConfig(config *rabbitmq.PoolConfig) (*Pool, error)
NewPoolWithPoolConfig returns a new *Pool with a PoolConfig object
func (*Pool) Get ¶
func (p *Pool) Get() (*PoolProducer, error)
Get is an exported alias of get() function with routine safe
func (*Pool) GetFullTag ¶ added in v0.3.19
GetFullTag gets the full tag
func (*Pool) UsedConnections ¶
UsedConnections returns used connection number
type PoolProducer ¶
func NewPoolProducer ¶
func NewPoolProducer(pool *Pool) (*PoolProducer, error)
NewPoolProducer returns a new *PoolProducer
func (*PoolProducer) Close ¶
func (pp *PoolProducer) Close() error
Close closes the channel and returns the producer back to the pool
func (*PoolProducer) Disconnect ¶
func (pp *PoolProducer) Disconnect() error
Disconnect disconnects from rabbitmq, normally when using connection pool, there is no need to disconnect manually, consider to use Close() instead.
func (*PoolProducer) GetTag ¶ added in v0.3.19
func (pp *PoolProducer) GetTag() string
GetTag returns the tag of the pool producer, should use this method to get the tag instead of using the tag property of the pool config, because the tag of the pool config is the prefix of the tag of the pool producer
func (*PoolProducer) IsValid ¶
func (pp *PoolProducer) IsValid() bool
IsValid validates if connection is valid
type Producer ¶
func NewProducer ¶
NewProducer returns a new *Producer
func NewProducerWithConfig ¶
NewProducerWithConfig returns a new *Producer with given config
func (*Producer) BuildMessage ¶
func (p *Producer) BuildMessage(contentType, message string) amqp.Publishing
BuildMessage builds an amqp.Publishing with given content type and message
func (*Producer) BuildMessageWithExpiration ¶
func (p *Producer) BuildMessageWithExpiration(contentType, message string, expiration int) amqp.Publishing
BuildMessageWithExpiration builds an amqp.Publishing with given content type and message and expiration
func (*Producer) Channel ¶
Channel returns the channel, it the channel of the producer is nil or had been closed, a new channel will be opened
func (*Producer) Disconnect ¶
Disconnect disconnects the rabbitmq server
func (*Producer) ExchangeDeclare ¶
ExchangeDeclare declares an exchange
func (*Producer) Publish ¶
func (p *Producer) Publish(msg amqp.Publishing) error
Publish publishes a message to an exchange
func (*Producer) PublishJSON ¶
PublishMessage publishes a json message to an exchange
func (*Producer) PublishWithContext ¶
PublishWithContext publishes a message to an exchange with context
func (*Producer) QueueDeclare ¶
QueueDeclare declares a queue