Class: Sidekiq::Work
- Inherits:
-
Object
- Object
- Sidekiq::Work
- Defined in:
- lib/sidekiq/api.rb
Overview
Sidekiq::Work represents a job which is currently executing.
Instance Attribute Summary collapse
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
Instance Method Summary collapse
-
#[](key) ⇒ Object
deprecated.
-
#initialize(pid, tid, hsh) ⇒ Work
constructor
A new instance of Work.
- #job ⇒ Object
- #method_missing(*all) ⇒ Object
- #payload ⇒ Object
- #queue ⇒ Object
-
#raw(name) ⇒ Object
private
:nodoc:.
- #respond_to_missing?(name, *args) ⇒ Boolean
- #run_at ⇒ Object
Constructor Details
#initialize(pid, tid, hsh) ⇒ Work
Returns a new instance of Work.
1160 1161 1162 1163 1164 1165 |
# File 'lib/sidekiq/api.rb', line 1160 def initialize(pid, tid, hsh) @process_id = pid @thread_id = tid @hsh = hsh @job = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*all) ⇒ Object
1198 1199 1200 |
# File 'lib/sidekiq/api.rb', line 1198 def method_missing(*all) @hsh.send(*all) end |
Instance Attribute Details
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
1157 1158 1159 |
# File 'lib/sidekiq/api.rb', line 1157 def process_id @process_id end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
1158 1159 1160 |
# File 'lib/sidekiq/api.rb', line 1158 def thread_id @thread_id end |
Instance Method Details
#[](key) ⇒ Object
deprecated
1184 1185 1186 1187 1188 1189 1190 |
# File 'lib/sidekiq/api.rb', line 1184 def [](key) kwargs = {uplevel: 1} kwargs[:category] = :deprecated if RUBY_VERSION > "3.0" # TODO warn("Direct access to `Sidekiq::Work` attributes is deprecated, please use `#payload`, `#queue`, `#run_at` or `#job` instead", **kwargs) @hsh[key] end |
#job ⇒ Object
1175 1176 1177 |
# File 'lib/sidekiq/api.rb', line 1175 def job @job ||= Sidekiq::JobRecord.new(@hsh["payload"]) end |
#payload ⇒ Object
1179 1180 1181 |
# File 'lib/sidekiq/api.rb', line 1179 def payload @hsh["payload"] end |
#queue ⇒ Object
1167 1168 1169 |
# File 'lib/sidekiq/api.rb', line 1167 def queue @hsh["queue"] end |
#raw(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:nodoc:
1194 1195 1196 |
# File 'lib/sidekiq/api.rb', line 1194 def raw(name) @hsh[name] end |
#respond_to_missing?(name, *args) ⇒ Boolean
1202 1203 1204 |
# File 'lib/sidekiq/api.rb', line 1202 def respond_to_missing?(name, *args) @hsh.respond_to?(name) end |
#run_at ⇒ Object
1171 1172 1173 |
# File 'lib/sidekiq/api.rb', line 1171 def run_at Time.at(@hsh["run_at"]) end |