Class: Promenade::Pitchfork::WorkerPidProvider
- Inherits:
-
Object
- Object
- Promenade::Pitchfork::WorkerPidProvider
- Defined in:
- lib/promenade/pitchfork/worker_pid_provider.rb
Class Method Summary collapse
Class Method Details
.fetch ⇒ Object
4 5 6 |
# File 'lib/promenade/pitchfork/worker_pid_provider.rb', line 4 def self.fetch worker_id || "process_id_#{Process.pid}" end |
.object_based_worker_id ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/promenade/pitchfork/worker_pid_provider.rb', line 8 def self.object_based_worker_id return unless defined?(::Pitchfork::Worker) workers = ObjectSpace.each_object(::Pitchfork::Worker) return if workers.nil? workers_first = workers.first workers_first&.nr end |
.program_name ⇒ Object
18 19 20 |
# File 'lib/promenade/pitchfork/worker_pid_provider.rb', line 18 def self.program_name $PROGRAM_NAME end |
.worker_id ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/promenade/pitchfork/worker_pid_provider.rb', line 22 def self.worker_id if matchdata = program_name.match(/pitchfork.*worker\[(.+)\]/) # rubocop:disable Lint/AssignmentInCondition "pitchfork_#{matchdata[1]}" elsif object_worker_id = object_based_worker_id # rubocop:disable Lint/AssignmentInCondition "pitchfork_#{object_worker_id}" end end |