Class: Sidekiq::Cron::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/cron.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



56
57
58
59
60
61
62
63
64
# File 'lib/sidekiq/cron.rb', line 56

def initialize
  @cron_poll_interval = 30
  @cron_schedule_file = 'config/schedule.yml'
  @cron_history_size = 10
  @default_namespace = 'default'
  @natural_cron_parsing_mode = :single
  @reschedule_grace_period = 60
  @available_namespaces = nil
end

Instance Attribute Details

#available_namespacesObject

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.



54
55
56
# File 'lib/sidekiq/cron.rb', line 54

def available_namespaces
  @available_namespaces
end

#cron_history_sizeObject

The maximum number of recent cron job execution histories to retain. This value controls how many past job executions are stored.



26
27
28
# File 'lib/sidekiq/cron.rb', line 26

def cron_history_size
  @cron_history_size
end

#cron_poll_intervalObject

The interval, in seconds, at which to poll for scheduled cron jobs. This determines how frequently the scheduler checks for jobs to enqueue.



19
20
21
# File 'lib/sidekiq/cron.rb', line 19

def cron_poll_interval
  @cron_poll_interval
end

#cron_schedule_fileObject

The path to a YAML file containing multiple cron job schedules.



22
23
24
# File 'lib/sidekiq/cron.rb', line 22

def cron_schedule_file
  @cron_schedule_file
end

#default_namespaceObject

The default namespace is used when no namespace is specified.



29
30
31
# File 'lib/sidekiq/cron.rb', line 29

def default_namespace
  @default_namespace
end

#natural_cron_parsing_modeObject

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



35
36
37
# File 'lib/sidekiq/cron.rb', line 35

def natural_cron_parsing_mode
  @natural_cron_parsing_mode
end

#reschedule_grace_periodObject

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.



43
44
45
# File 'lib/sidekiq/cron.rb', line 43

def reschedule_grace_period
  @reschedule_grace_period
end