module Procrastinator::Config::DSL
Collection of all of the methods intended for use within Procrastinator.setup
@see Procrastinator
Public Instance Methods
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
@param name [Symbol, String] the identifier to label the queue. Referenced in defer calls @param task_class [Class] the Task
Handler class. @param properties [Hash] Settings options object for this queue @option properties [Object] :store (Procrastinator::TaskStore::SimpleCommaStore
)
Storage strategy for tasks in the queue.
@option properties [Integer] :max_attempts (Procrastinator::Queue::DEFAULT_MAX_ATTEMPTS)
Maximum number of times a task may be attempted before giving up.
@option properties [Integer] :timeout (Procrastinator::Queue::DEFAULT_TIMEOUT)
Maximum number of seconds to wait for a single task to complete.
@option properties [Integer] :update_period (Procrastinator::Queue::DEFAULT_UPDATE_PERIOD)
Time to wait before checking for new tasks.
# File lib/procrastinator/config.rb, line 106 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 @queues << Queue.new(**{name: name, task_class: task_class, store: @default_store}.merge(properties)) end
Sets details of logging behaviour
@param directory [Pathname,String] the directory to save logs within. @param level [Logger::UNKNOWN,Logger::FATAL,Logger::ERROR,Logger::WARN,Logger::INFO,Logger::DEBUG,Integer,Boolean] the Ruby Logger level to use. If falsey, no logging is performed. @param shift_age [Integer] number of old log files to keep (see Ruby Logger for details) @param shift_size [Integer] filesize before log is rotated to a fresh file (see Ruby Logger for details)
# File lib/procrastinator/config.rb, line 121 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
Defines the container to assign to each Task
Handler’s :container attribute.
@param container [Object] the container
# File lib/procrastinator/config.rb, line 86 def provide_container(container) @container = container end
Assigns a task loader
# File lib/procrastinator/config.rb, line 74 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