Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrPointer = errors.New("method receiver was a pointer when it shouldn't be") ErrStdNotInitialized = errors.New("default broker hasn't been initialized") ErrInvalidQueue = errors.New("invalid queue name") ErrNoDefaultQueue = errors.New("no default queue name provided") ErrNoRedis = errors.New("can't establish a connection to redis") ErrInvalidJob = errors.New("invalid job") )
generic goku errors
Functions ¶
func Configure ¶
func Configure(cfg BrokerConfig) error
Configure configures the default broker for package level use
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker objects schedule jobs to be processed
type BrokerConfig ¶
type BrokerConfig struct { Hostport string Password string Timeout time.Duration DefaultQueue string }
BrokerConfig is the information needed to set up a new broker
type FailureFunc ¶
FailureFunc is a function that gets executed when a job fails. It will get run when a job returns an error or panics.
type Job ¶
Job is any type that implements Execute and Name. In order for a job to be valid, all fields used within its Execute method must be exported.
type JobOption ¶
type JobOption struct {
// contains filtered or unexported fields
}
JobOption specifies an option for a job.
type WorkerConfig ¶
type WorkerConfig struct { NumWorkers int // number of workers that belong to the pool Queues []string // what queues to pull jobs from Hostport string // redis hostport Password string // redis auth password (optional) Timeout time.Duration // redis timeout // If a worker doesn't know how to handle a job it will be requeued. // sometimes requeuing can fail. This field is max number of retries before // losing the job. RequeRetries int }
WorkerConfig describes the configuration needed for setting up a new worker pool.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool is what will pull jobs from redis and distribute them to workers within the pool.
func NewWorkerPool ¶
func NewWorkerPool(cfg WorkerConfig, opts WorkerPoolOptions) (*WorkerPool, error)
NewWorkerPool returns a new WorkerPool. It fails when a connection to redis cannot be established.
func (*WorkerPool) Start ¶
func (wp *WorkerPool) Start()
Start tells the worker pool to start pulling things off the queue to be processed.
func (*WorkerPool) Stop ¶
func (wp *WorkerPool) Stop()
Stop waits for all jobs to finish executing, and then returns.
type WorkerPoolOptions ¶
type WorkerPoolOptions struct { Failure FailureFunc Jobs []Job }
WorkerPoolOptions exists for defining things that wouldn't be possible within a yaml configuration file. Failure is optional, but jobs are required if you want the workers to do anything.