Module: Procrastinator::Config::DSL
- Included in:
- Procrastinator::Config
- Defined in:
- lib/procrastinator/config.rb
Overview
Collection of all of the methods intended for use within Procrastinator.setup
Instance Method Summary collapse
-
#adjust_priority(new_priority) ⇒ Object
(also: #adjust_nice)
Sets the desired process ‘nice’ priority value adjustment.
-
#define_queue(name, task_class, properties = {}) ⇒ Object
Defines a queue in the Procrastinator Scheduler.
-
#log_with(directory: @log_dir, level: @log_level, shift_age: @log_shift_age, shift_size: @log_shift_size) ⇒ Object
Sets details of logging behaviour.
-
#provide_container(container) ⇒ Object
Defines the container to assign to each Task Handler’s :container attribute.
-
#with_store(store) ⇒ Object
Assigns a task loader.
Instance Method Details
#adjust_priority(new_priority) ⇒ Object Also known as: adjust_nice
Sets the desired process ‘nice’ priority value adjustment. This value is added to whatever runtime priority Procrastinator starts with.
Higher numbers are more nice to other processes (lower priority); think of it as the position in line. You can be more nice, but never less nice.
143 144 145 |
# File 'lib/procrastinator/config.rb', line 143 def adjust_priority(new_priority) @priority = new_priority end |
#define_queue(name, task_class, properties = {}) ⇒ Object
Defines a queue in the Procrastinator Scheduler.
The Task Handler will be initialized for each task and assigned each of these attributes:
:container, :logger, :scheduler
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/procrastinator/config.rb', line 112 def define_queue(name, task_class, properties = {}) raise ArgumentError, 'queue name cannot be nil' if name.nil? raise ArgumentError, 'queue task class cannot be nil' if task_class.nil? properties[:store] = interpret_store(properties[:store]) if properties.key? :store args = {name: name, task_class: task_class, store: @default_store}.merge(properties) @queues << Queue.new(**args) end |
#log_with(directory: @log_dir, level: @log_level, shift_age: @log_shift_age, shift_size: @log_shift_size) ⇒ Object
Sets details of logging behaviour
129 130 131 132 133 134 |
# File 'lib/procrastinator/config.rb', line 129 def log_with(directory: @log_dir, level: @log_level, shift_age: @log_shift_age, shift_size: @log_shift_size) @log_dir = directory ? Pathname.new(directory) : directory @log_level = level @log_shift_age = shift_age @log_shift_size = shift_size end |
#provide_container(container) ⇒ Object
Defines the container to assign to each Task Handler’s :container attribute.
92 93 94 |
# File 'lib/procrastinator/config.rb', line 92 def provide_container(container) @container = container end |
#with_store(store) ⇒ Object
Assigns a task loader
80 81 82 83 84 85 86 87 |
# File 'lib/procrastinator/config.rb', line 80 def with_store(store) raise(ArgumentError, 'with_store must be provided a block') unless block_given? old_store = @default_store @default_store = interpret_store(store) yield @default_store = old_store end |