Documentation
¶
Overview ¶
Package broker reserves jobs from beanstalkd, spawns worker processes, and manages the interaction between the two.
Index ¶
Constants ¶
View Source
const ( // TimeoutTries is the number of timeouts a job must reach before it is // buried. Zero means never execute. TimeoutTries = 1 // ReleaseTries is the number of releases a job must reach before it is // buried. Zero means never execute. ReleaseTries = 10 )
View Source
const ( // ListTubeDelay is the time between sending list-tube to beanstalkd // to discover and watch newly created tubes. ListTubeDelay = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// Address of the beanstalkd server.
Address string
// The shell command to execute for each job.
Cmd string
// Tube name this broker will service.
Tube string
// contains filtered or unexported fields
}
type BrokerDispatcher ¶
type BrokerDispatcher struct {
// contains filtered or unexported fields
}
BrokerDispatcher manages the running of Broker instances for tubes. It can be manually told tubes to start, or it can poll for tubes as they are created. The `perTube` option determines how many brokers are started for each tube.
func NewBrokerDispatcher ¶
func NewBrokerDispatcher(address, cmd string, perTube uint64) *BrokerDispatcher
func (*BrokerDispatcher) RunAllTubes ¶
func (bd *BrokerDispatcher) RunAllTubes() (err error)
RunAllTubes polls beanstalkd, running broker as new tubes are created.
func (*BrokerDispatcher) RunTube ¶
func (bd *BrokerDispatcher) RunTube(tube string)
RunTube runs broker(s) for the specified tube. The number of brokers started is determined by the perTube argument to NewBrokerDispatcher.
func (*BrokerDispatcher) RunTubes ¶
func (bd *BrokerDispatcher) RunTubes(tubes []string)
RunTube runs brokers for the specified tubes.
type JobResult ¶
type JobResult struct {
// Buried is true if the job was buried.
Buried bool
// Executed is true if the job command was executed (or attempted).
Executed bool
// ExitStatus of the command; 0 for success.
ExitStatus int
// JobId from beanstalkd.
JobId uint64
// Stdout of the command.
Stdout []byte
// TimedOut indicates the worker exceeded TTR for the job.
// Note this is tracked by a timer, separately to beanstalkd.
TimedOut bool
// Error raised while attempting to handle the job.
Error error
}
Click to show internal directories.
Click to hide internal directories.