Class: Sidekiq::RoleCapsules
- Inherits:
-
Object
- Object
- Sidekiq::RoleCapsules
- Defined in:
- lib/sidekiq/role_capsules.rb
Overview
Registers the dedicated capsules owned by each Sidekiq application role.
Base queue lists and concurrency remain in the role's YAML configuration;
this object owns only queues that need strict, non-borrowable threads.
Defined Under Namespace
Classes: Definition
Constant Summary collapse
- SUPPORTED_ROLES =
%w[latency heavy edi].freeze
- COMMON =
{ 'invoicing' => Definition.new(concurrency: 1, queues: %w[invoicing].freeze), 'online_migrations' => Definition.new(concurrency: 1, queues: %w[online_migrations].freeze), 'mailbox' => Definition.new( concurrency: 1, queues: %w[action_mailbox_routing action_mailbox_incineration].freeze ), 'storage' => Definition.new(concurrency: 1, queues: %w[active_storage_analysis active_storage_purge].freeze) }.freeze
- LATENCY =
{ # Bound background Switchvox traffic to two calls at once. A realtime lane # prevents the 15s presence target from waiting behind 16–60s imports and # reconciliation, while the bulk lane keeps those long jobs serial. One # thread comes from high and one from the base capsule, so the latency # role's total thread and database-connection budgets do not change. 'high' => Definition.new(concurrency: 8, queues: %w[high].freeze), 'pbx' => Definition.new(concurrency: 1, queues: %w[pbx].freeze), 'pbx_bulk' => Definition.new(concurrency: 1, queues: %w[pbx_bulk].freeze) }.freeze
- HEAVY =
{ 'seo_visits' => Definition.new(concurrency: 1, queues: %w[seo_visits].freeze), 'campaign' => Definition.new(concurrency: 10, queues: %w[campaign].freeze) }.freeze
Class Method Summary collapse
Class Method Details
.configure(config, role: ENV.fetch('SIDEKIQ_ROLE', nil), environment: nil) ⇒ void
This method returns an undefined value.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sidekiq/role_capsules.rb', line 39 def configure(config, role: ENV.fetch('SIDEKIQ_ROLE', nil), environment: nil) environment ||= ::Rails.env if defined?(::Rails) role = role.to_s.presence validate_role!(role, environment) if config[:queues].include?('default') register(config, COMMON) register(config, LATENCY) if role == 'latency' end register(config, HEAVY) if role == 'heavy' end |