Documentation ¶
Overview ¶
NewRabbitMQ returns a new initialized connection struct. It will manage the active connection in the background. Connection should be closed in order to shut it down gracefully.
func example() { user := "guest" pass := "guest" host := "localhost" port := "5672" consumer := "user-service" // Unique name for each consumer used to sign messages. // You can specify your own config or use DefaultConfig() instead. config := Config{ QueueSize: 100, MaxWorkers: 50, ReconnectInterval: time.Second * 2, MaxRequests: 5, ClearInterval: time.Second * 5, ClosedTimeout: time.Second * 5, } // Logger and tracer are optional. rabbit := rabbitmq.NewRabbitMQ(consumer, user, pass, host, port, config, WithLogger(customLogger)) defer rabbit.Close() }
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFullQueue = errors.New("publish queue is full")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { QueueSize int // Max number of messages internally queued for publishing. MaxWorkers int // Max number of concurrent workers per operation type. ReconnectInterval time.Duration // Time between reconnect attempts. // Settings for the internal circuit breaker. MaxRequests uint32 // Number of requests allowed to half-open state. ClearInterval time.Duration // Time after which failed calls count is cleared. ClosedTimeout time.Duration // Time after which closed state becomes half-open. }
func DefaultConfig ¶
func DefaultConfig() Config
type ContentType ¶
type ContentType string
const ( ContentTypeJson ContentType = "application/json" ContentTypeText ContentType = "text/plain" )
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithLogger ¶
func WithTracer ¶
type RabbitMQ ¶
type RabbitMQ struct {
// contains filtered or unexported fields
}
func NewRabbitMQ ¶
NewRabbitMQ returns a new initialized connection struct. It will manage the active connection in the background. Connection should be closed in order to shut it down gracefully.
func example() { user := "guest" pass := "guest" host := "localhost" port := "5672" consumer := "user-service" // Unique name for each consumer used to sign messages. var customLogger Logger // You can specify your own config or use rabbitmq.DefaultConfig() instead. config := Config{ QueueSize: 100, MaxWorkers: 50, ReconnectInterval: time.Second * 2, MaxRequests: 5, ClearInterval: time.Second * 5, ClosedTimeout: time.Second * 5, } // Logger and tracer are optional. rabbit := rabbitmq.NewRabbitMQ(consumer, user, pass, host, port, config, WithLogger(customLogger)) defer rabbit.Close() }
Click to show internal directories.
Click to hide internal directories.