class Pallets::Configuration

Attributes

backend[RW]

Backend to use for handling workflows

backend_args[RW]

Arguments used to initialize the backend

blocking_timeout[RW]

Number of seconds to block while waiting for jobs

concurrency[RW]

Number of workers to process jobs

failed_job_lifespan[RW]

Minimum number of seconds a failed job stays in the given up set. After this period, jobs will be permanently deleted

failed_job_max_count[RW]

Maximum number of failed jobs that can be in the given up set. When this number is reached, the oldest jobs will be permanently deleted

job_timeout[RW]

Number of seconds allowed for a job to be processed. If a job exceeds this period, it is considered failed, and scheduled to be processed again

max_failures[RW]

Maximum number of failures allowed per job. Can also be configured on a per task basis

middleware[R]

Middleware used to wrap job execution with custom logic. Acts like a stack and accepts callable objects (lambdas, procs, objects that respond to call) that take three arguments: the worker handling the job, the job hash and the context

A minimal example of a middleware is:

->(worker, job, context, &b) { puts 'Hello World!'; b.call }
pool_size[W]

Number of connections to the backend

scheduler_polling_interval[RW]

Number of seconds at which the scheduler checks whether there are jobs due to be (re)processed. Note that this interval is per process; it might require tweaking in case of running multiple Pallets instances, so that the backend is not polled too often

serializer[RW]

Serializer used for jobs

Public Class Methods

new() click to toggle source
# File lib/pallets/configuration.rb, line 52
def initialize
  @backend = :redis
  @backend_args = {}
  @blocking_timeout = 5
  @concurrency = 2
  @failed_job_lifespan = 7_776_000 # 3 months
  @failed_job_max_count = 1_000
  @job_timeout = 1_800 # 30 minutes
  @max_failures = 3
  @scheduler_polling_interval = 10
  @serializer = :json
  @middleware = default_middleware
end

Public Instance Methods

default_middleware() click to toggle source
# File lib/pallets/configuration.rb, line 70
def default_middleware
  Middleware::Stack[
    Middleware::JobLogger
  ]
end
pool_size() click to toggle source
# File lib/pallets/configuration.rb, line 66
def pool_size
  @pool_size || @concurrency + 1
end