Class: Pallets::Configuration
- Inherits:
-
Object
- Object
- Pallets::Configuration
- Defined in:
- lib/pallets/configuration.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
Backend to use for handling workflows.
-
#backend_args ⇒ Object
Arguments used to initialize the backend.
-
#blocking_timeout ⇒ Object
Number of seconds to block while waiting for jobs.
-
#concurrency ⇒ Object
Number of workers to process jobs.
-
#failed_job_lifespan ⇒ Object
Minimum number of seconds a failed job stays in the given up set.
-
#job_timeout ⇒ Object
Number of seconds allowed for a job to be processed.
-
#max_failures ⇒ Object
Maximum number of failures allowed per job.
-
#middleware ⇒ Object
readonly
Middleware used to wrap job execution with custom logic.
- #pool_size ⇒ Object
-
#serializer ⇒ Object
Serializer used for jobs.
Instance Method Summary collapse
- #default_middleware ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pallets/configuration.rb', line 42 def initialize @backend = :redis @backend_args = {} @blocking_timeout = 5 @concurrency = 2 @failed_job_lifespan = 7_776_000 # 3 months @job_timeout = 1_800 # 30 minutes @max_failures = 3 @serializer = :json @middleware = default_middleware end |
Instance Attribute Details
#backend ⇒ Object
Backend to use for handling workflows
4 5 6 |
# File 'lib/pallets/configuration.rb', line 4 def backend @backend end |
#backend_args ⇒ Object
Arguments used to initialize the backend
7 8 9 |
# File 'lib/pallets/configuration.rb', line 7 def backend_args @backend_args end |
#blocking_timeout ⇒ Object
Number of seconds to block while waiting for jobs
10 11 12 |
# File 'lib/pallets/configuration.rb', line 10 def blocking_timeout @blocking_timeout end |
#concurrency ⇒ Object
Number of workers to process jobs
13 14 15 |
# File 'lib/pallets/configuration.rb', line 13 def concurrency @concurrency end |
#failed_job_lifespan ⇒ Object
Minimum number of seconds a failed job stays in the given up set. After this period, jobs will be permanently deleted
17 18 19 |
# File 'lib/pallets/configuration.rb', line 17 def failed_job_lifespan @failed_job_lifespan end |
#job_timeout ⇒ Object
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
21 22 23 |
# File 'lib/pallets/configuration.rb', line 21 def job_timeout @job_timeout end |
#max_failures ⇒ Object
Maximum number of failures allowed per job. Can also be configured on a per task basis
25 26 27 |
# File 'lib/pallets/configuration.rb', line 25 def max_failures @max_failures end |
#middleware ⇒ Object (readonly)
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 }
40 41 42 |
# File 'lib/pallets/configuration.rb', line 40 def middleware @middleware end |
#pool_size ⇒ Object
54 55 56 |
# File 'lib/pallets/configuration.rb', line 54 def pool_size @pool_size || @concurrency + 1 end |
#serializer ⇒ Object
Serializer used for jobs
31 32 33 |
# File 'lib/pallets/configuration.rb', line 31 def serializer @serializer end |
Instance Method Details
#default_middleware ⇒ Object
58 59 60 61 62 |
# File 'lib/pallets/configuration.rb', line 58 def default_middleware Middleware::Stack[ Middleware::JobLogger ] end |