Class: Sidekiq::Cron::Configuration
- Inherits:
-
Object
- Object
- Sidekiq::Cron::Configuration
- Defined in:
- lib/sidekiq/cron.rb
Instance Attribute Summary collapse
-
#available_namespaces ⇒ Object
List of available namespaces.
-
#cron_history_size ⇒ Object
The maximum number of recent cron job execution histories to retain.
-
#cron_poll_interval ⇒ Object
The interval, in seconds, at which to poll for scheduled cron jobs.
-
#cron_poll_process_count ⇒ Object
The number of polling processes for Sidekiq Cron.
-
#cron_schedule_file ⇒ Object
The path to a YAML file containing multiple cron job schedules.
-
#default_namespace ⇒ Object
The default namespace is used when no namespace is specified.
-
#enabled ⇒ Object
Whether Sidekiq-Cron is enabled.
-
#natural_cron_parsing_mode ⇒ Object
The parsing mode when using the natural language cron syntax from the ‘fugit` gem.
-
#reschedule_grace_period ⇒ Object
The poller will not enqueue jobs that are late by more than this amount of seconds.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sidekiq/cron.rb', line 69 def initialize @enabled = true @cron_poll_interval = 30 @cron_schedule_file = 'config/schedule.yml' @cron_history_size = 10 @default_namespace = 'default' @available_namespaces = [@default_namespace] @natural_cron_parsing_mode = :single @reschedule_grace_period = 60 end |
Instance Attribute Details
#available_namespaces ⇒ Object
List of available namespaces
If not set, Sidekiq Cron will dynamically fetch available namespaces by retrieving existing jobs from Redis.
This dynamic fetching can negatively impact performance in certain cases. To mitigate this, you can provide the list of namespaces explicitly. If a job specifies a namespace that is not included in the provided list, a warning will be logged, and the job will be assigned to the default namespace.
53 54 55 |
# File 'lib/sidekiq/cron.rb', line 53 def available_namespaces @available_namespaces end |
#cron_history_size ⇒ Object
The maximum number of recent cron job execution histories to retain. This value controls how many past job executions are stored.
30 31 32 |
# File 'lib/sidekiq/cron.rb', line 30 def cron_history_size @cron_history_size end |
#cron_poll_interval ⇒ Object
The interval, in seconds, at which to poll for scheduled cron jobs. This determines how frequently the scheduler checks for jobs to enqueue.
23 24 25 |
# File 'lib/sidekiq/cron.rb', line 23 def cron_poll_interval @cron_poll_interval end |
#cron_poll_process_count ⇒ Object
The process count is used internally to determine the random poll interval.
The number of polling processes for Sidekiq Cron.
It is configurable to handle the case where only a subset of Sidekiq process are used for Sidekiq Cron polling where the default would be to poll from all processes.
39 40 41 |
# File 'lib/sidekiq/cron.rb', line 39 def cron_poll_process_count @cron_poll_process_count end |
#cron_schedule_file ⇒ Object
The path to a YAML file containing multiple cron job schedules.
26 27 28 |
# File 'lib/sidekiq/cron.rb', line 26 def cron_schedule_file @cron_schedule_file end |
#default_namespace ⇒ Object
The default namespace is used when no namespace is specified.
42 43 44 |
# File 'lib/sidekiq/cron.rb', line 42 def default_namespace @default_namespace end |
#enabled ⇒ Object
Whether Sidekiq-Cron is enabled. When set to false, the schedule file will not be loaded on startup. Defaults to true.
19 20 21 |
# File 'lib/sidekiq/cron.rb', line 19 def enabled @enabled end |
#natural_cron_parsing_mode ⇒ Object
The parsing mode when using the natural language cron syntax from the ‘fugit` gem.
:single – use the first parsed cron line and ignore the rest (default) :strict – raise an error if multiple cron lines are parsed from one string
59 60 61 |
# File 'lib/sidekiq/cron.rb', line 59 def natural_cron_parsing_mode @natural_cron_parsing_mode end |
#reschedule_grace_period ⇒ Object
The poller will not enqueue jobs that are late by more than this amount of seconds. Defaults to 60 seconds.
This is useful when Sidekiq (and Sidekiq-Cron) is not used in zero downtime deployments and when the deployment is done and Sidekiq-Cron starts to catch up, it will consider older jobs that missed their schedules during the deployment. E.g., jobs that run once a day.
67 68 69 |
# File 'lib/sidekiq/cron.rb', line 67 def reschedule_grace_period @reschedule_grace_period end |