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.
-
#failed_job_max_count ⇒ Object
Maximum number of failed jobs that can be 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
-
#scheduler_polling_interval ⇒ Object
Number of seconds at which the scheduler checks whether there are jobs due to be (re)processed.
-
#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.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# 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 |
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 |
#failed_job_max_count ⇒ Object
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
21 22 23 |
# File 'lib/pallets/configuration.rb', line 21 def failed_job_max_count @failed_job_max_count 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
25 26 27 |
# File 'lib/pallets/configuration.rb', line 25 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
29 30 31 |
# File 'lib/pallets/configuration.rb', line 29 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 }
50 51 52 |
# File 'lib/pallets/configuration.rb', line 50 def middleware @middleware end |
#pool_size ⇒ Object
66 67 68 |
# File 'lib/pallets/configuration.rb', line 66 def pool_size @pool_size || @concurrency + 1 end |
#scheduler_polling_interval ⇒ Object
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
38 39 40 |
# File 'lib/pallets/configuration.rb', line 38 def scheduler_polling_interval @scheduler_polling_interval end |
#serializer ⇒ Object
Serializer used for jobs
41 42 43 |
# File 'lib/pallets/configuration.rb', line 41 def serializer @serializer end |
Instance Method Details
#default_middleware ⇒ Object
70 71 72 73 74 |
# File 'lib/pallets/configuration.rb', line 70 def default_middleware Middleware::Stack[ Middleware::JobLogger ] end |