Documentation
¶
Index ¶
Constants ¶
const BrokersConfig = "Brokers"
BrokersConfig defines config section related to Brokers configuration.
const (
// ID defines Listen service public alias.
ID = "jobs"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Broker ¶ added in v0.2.0
type Broker interface {
// Listen configures broker with list of pipelines to listen and handler function.
Listen(pipelines []*Pipeline, pool chan Handler, err ErrorHandler) error
// Serve broker must listen for all associated pipelines and consume given jobs.
Serve() error
// Stop must stop broker.
Stop()
// Push new job to the broker. Must return job id or error.
Push(p *Pipeline, j *Job) (id string, err error)
}
Broker represents single broker abstraction.
type Config ¶
type Config struct {
// Workers configures roadrunner server and worker busy.
Workers *roadrunner.ServerConfig
// Pipelines defines mapping between PHP job pipeline and associated job broker.
Pipelines []*Pipeline
}
Config defines settings for job broker, workers and routing PipelineOptions.
type ErrorHandler ¶ added in v0.2.0
Listen handles job execution.
type Job ¶ added in v0.2.0
type Job struct {
// Job contains name of job broker (usually PHP class).
Job string `json:"job"`
// Attempt is number of job attempt if case of error.
Attempt int `json:"attempt"`
// Payload is string data (usually JSON) passed to Job broker.
Payload string `json:"payload"`
// Options contains set of PipelineOptions specific to job execution. Can be empty.
Options Options `json:"options,omitempty"`
}
Job carries information about single job.
type Options ¶ added in v0.2.0
type Options struct {
// Delay defines time duration to delay execution for. Defaults to none.
Delay int `json:"delay,omitempty"`
// RetryDelay defines for how long job should be waiting until next retry. Defaults to none.
RetryDelay int `json:"retryDelay,omitempty"`
// Reserve defines for how broker should wait until treating job are failed. Defaults to 30 min.
Timeout int `json:"timeout,omitempty"`
// Maximum job retries. Defaults to none.
MaxAttempts int `json:"maxAttempts,omitempty"`
}
Options carry information about how to handle given job.
func (*Options) DelayDuration ¶ added in v0.2.0
DelayDuration returns delay duration in a form of time.Duration.
func (*Options) RetryDuration ¶ added in v0.2.0
RetryDuration returns retry delay duration in a form of time.Duration.
func (*Options) TimeoutDuration ¶ added in v0.2.0
DelayDuration returns timeout duration in a form of time.Duration.
type Pipeline ¶ added in v0.2.0
type Pipeline struct {
// Broker defines name of associated broker.
Broker string
// Listen define job matching pattern (i.e. - "app.jobs.email")
Handle []string
// Retry defined number of job retries in case of error. Default none.
Retry int
// RetryDelay defines for how long wait till job retry.
RetryDelay int
// Listen tells the service that this pipeline must be consumed by the service.
Listen bool
// Options are broker specific PipelineOptions.
Options PipelineOptions
}
Pipeline describes broker specific pipeline.
type PipelineOptions ¶ added in v0.2.0
type PipelineOptions map[string]interface{}
func (PipelineOptions) Bool ¶ added in v0.2.0
func (o PipelineOptions) Bool(name string, d bool) bool
Bool must return option value as string or return default value.
func (PipelineOptions) Duration ¶ added in v0.2.0
Duration must return option value as time.Duration (seconds) or return default value.
type Service ¶
type Service struct {
// Brokers define list of available brokers.
Brokers map[string]Broker
// contains filtered or unexported fields
}
Service manages job execution and connection to multiple job pipelines.
func (*Service) Init ¶
func (s *Service) Init(c service.Config, l *logrus.Logger, r *rpc.Service, e env.Environment) (ok bool, err error)
Init configures job service.