Class: Bellbro::SidekiqUtils::Worker
- Inherits:
-
Object
- Object
- Bellbro::SidekiqUtils::Worker
show all
- Defined in:
- lib/bellbro/sidekiq_utils.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source) ⇒ Worker
Returns a new instance of Worker.
60
61
62
|
# File 'lib/bellbro/sidekiq_utils.rb', line 60
def initialize(source)
@source = source
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
64
65
66
|
# File 'lib/bellbro/sidekiq_utils.rb', line 64
def method_missing(method_name, *args, &block)
args.first.try(:[],method_name.to_s)
end
|
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
58
59
60
|
# File 'lib/bellbro/sidekiq_utils.rb', line 58
def source
@source
end
|
Class Method Details
.all ⇒ Object
92
93
94
95
96
|
# File 'lib/bellbro/sidekiq_utils.rb', line 92
def self.all
Sidekiq::Workers.new.map do |process_id, thread_id, worker|
worker
end
end
|
.all_for_class(klass_name) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/bellbro/sidekiq_utils.rb', line 98
def self.all_for_class(klass_name)
Retryable.retryable(on: Redis::TimeoutError) do
all.select do |worker|
worker.klass == klass_name
end
end
end
|
Instance Method Details
#args ⇒ Object
72
73
74
|
# File 'lib/bellbro/sidekiq_utils.rb', line 72
def args
payload["args"] || []
end
|
#jid ⇒ Object
76
77
78
|
# File 'lib/bellbro/sidekiq_utils.rb', line 76
def jid
payload["jid"]
end
|
#klass ⇒ Object
84
85
86
|
# File 'lib/bellbro/sidekiq_utils.rb', line 84
def klass
payload["class"]
end
|
#payload ⇒ Object
68
69
70
|
# File 'lib/bellbro/sidekiq_utils.rb', line 68
def payload
source["payload"] || {}
end
|
#queue ⇒ Object
88
89
90
|
# File 'lib/bellbro/sidekiq_utils.rb', line 88
def queue
source["queue"]
end
|
#time ⇒ Object
80
81
82
|
# File 'lib/bellbro/sidekiq_utils.rb', line 80
def time
source["run_at"]
end
|