Class: RuboCop::Cop::SidekiqPro::ExpiringJobWithoutTTL
- Defined in:
- lib/rubocop/cop/sidekiq_pro/expiring_job_without_ttl.rb
Overview
Checks that expiring jobs have appropriate TTL values.
A TTL that is too short may cause jobs to expire before processing, while a TTL that is too long defeats the purpose of expiring jobs.
Constant Summary collapse
- MSG_TOO_SHORT =
'Expiring job TTL is too short (minimum: %<minimum>s seconds). ' \ 'Jobs may expire before processing.'
- MSG_TOO_LONG =
'Expiring job TTL is too long (maximum: %<maximum>s seconds). ' \ 'Consider a shorter TTL for expiring jobs.'
- MINIMUM_TTL =
300- MAXIMUM_TTL =
604_800
Instance Method Summary collapse
- #expires_in_value(node) ⇒ Object
- #on_send(node) ⇒ Object (also: #on_csend)
Methods inherited from Base
#batch_description_set?, #batch_jobs_block?, #batch_new?, #batch_on_callback?
Methods included from Sidekiq::Language
#active_job_class?, #perform_call?, #sidekiq_include?, #sidekiq_options_call?
Instance Method Details
#expires_in_value(node) ⇒ Object
40 41 42 |
# File 'lib/rubocop/cop/sidekiq_pro/expiring_job_without_ttl.rb', line 40 def_node_matcher :expires_in_value, <<~PATTERN (send nil? :sidekiq_options (hash <(pair (sym :expires_in) $_) ...>)) PATTERN |
#on_send(node) ⇒ Object Also known as: on_csend
44 45 46 47 48 49 50 51 |
# File 'lib/rubocop/cop/sidekiq_pro/expiring_job_without_ttl.rb', line 44 def on_send(node) expires_in_value(node) do |value_node| ttl = extract_seconds(value_node) return unless ttl check_ttl_range(value_node, ttl) end end |