Module: SwitchmanInstJobs::Delayed::Worker::HealthCheck::ClassMethods
- Defined in:
- lib/switchman_inst_jobs/delayed/worker/health_check.rb
Instance Method Summary collapse
Instance Method Details
#munge_service_name(shard) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/switchman_inst_jobs/delayed/worker/health_check.rb', line 10 def munge_service_name(shard) # munge the name to add the current shard original_service_name = ::Delayed::Settings.worker_health_check_config['service_name'] consul_service_name = ::Delayed::Worker::ConsulHealthCheck::DEFAULT_SERVICE_NAME ::Delayed::Settings.worker_health_check_config['service_name'] = "#{original_service_name || consul_service_name}/#{shard.id}" yield ensure ::Delayed::Settings.worker_health_check_config['service_name'] = original_service_name end |
#reschedule_abandoned_jobs ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/switchman_inst_jobs/delayed/worker/health_check.rb', line 21 def reschedule_abandoned_jobs shard_ids = ::SwitchmanInstJobs::Delayed::Settings.configured_shard_ids shards = shard_ids.map { |shard_id| ::Delayed::Worker.shard(shard_id) } ::Switchman::Shard.with_each_shard(shards, [::ActiveRecord::Base, ::Delayed::Backend::ActiveRecord::AbstractJob]) do munge_service_name(::Switchman::Shard.current) do # because this rescheduling process is running on every host, we need # to make sure that it's functioning for each shard the current # host is programmed to interact with, but ONLY for those shards. # reading the config lets us iterate over any shards this host should # work with and lets us pick the correct service name to identify which # hosts are currently alive and valid via the health checks super() end end end |