Documentation ¶
Overview ¶
Package redis implements a Celery broker using Redis and github.com/gomodule/redigo.
Index ¶
Constants ¶
const DefaultReceiveTimeout = 5
DefaultReceiveTimeout defines how many seconds the broker's Receive command should block waiting for results from Redis.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is a Redis broker that sends/receives messages from specified queues.
func NewBroker ¶
func NewBroker(options ...BrokerOption) *Broker
NewBroker creates a broker backed by Redis. By default it connects to localhost.
func (*Broker) Receive ¶
Receive fetches a Celery task message from a tail of one of the queues in Redis. After a timeout it returns nil, nil.
Celery relies on BRPOP command to process messages fairly, see https://github.com/celery/kombu/issues/166. Redis BRPOP is a blocking list pop primitive. It blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the tail of the first list that is non-empty, with the given keys being checked in the order that they are given, see https://redis.io/commands/brpop/.
type BrokerOption ¶
type BrokerOption func(*Broker)
BrokerOption sets up a Broker.
func WithReceiveTimeout ¶
func WithReceiveTimeout(timeout time.Duration) BrokerOption
WithReceiveTimeout sets a timeout of how long the broker's Receive command should block waiting for results from Redis. Larger the timeout, longer the client will have to wait for Celery app to exit. Smaller the timeout, more BRPOP commands would have to be sent to Redis.
Note, the read timeout you specified with redis.DialReadTimeout() method should be bigger than the receive timeout. Otherwise redigo would return i/o timeout error.