Class: SidekiqJobController::Controller
- Inherits:
-
Object
- Object
- SidekiqJobController::Controller
- Defined in:
- lib/sidekiq_job_controller/controller.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #fetch_execution_action ⇒ Object
-
#initialize(class_name:, job: nil, payload: nil) ⇒ Controller
constructor
A new instance of Controller.
- #requeue_job!(seconds) ⇒ Object
- #resume_job! ⇒ Object
- #skip_job! ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(class_name:, job: nil, payload: nil) ⇒ Controller
Returns a new instance of Controller.
5 6 7 8 9 |
# File 'lib/sidekiq_job_controller/controller.rb', line 5 def initialize(class_name:, job: nil, payload: nil) @class_name = class_name @job = job @payload = payload end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
3 4 5 |
# File 'lib/sidekiq_job_controller/controller.rb', line 3 def class_name @class_name end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
3 4 5 |
# File 'lib/sidekiq_job_controller/controller.rb', line 3 def job @job end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
3 4 5 |
# File 'lib/sidekiq_job_controller/controller.rb', line 3 def payload @payload end |
Instance Method Details
#fetch_execution_action ⇒ Object
36 37 38 39 40 |
# File 'lib/sidekiq_job_controller/controller.rb', line 36 def fetch_execution_action Sidekiq.redis do |conn| conn.hgetall(job_controller_key) end end |
#requeue_job!(seconds) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sidekiq_job_controller/controller.rb', line 25 def requeue_job!(seconds) Sidekiq.redis do |conn| conn.mapped_hmset(job_controller_key, { action: :requeue, in: seconds.to_i }) end status end |
#resume_job! ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sidekiq_job_controller/controller.rb', line 11 def resume_job! Sidekiq.redis do |conn| conn.del(job_controller_key) end status end |
#skip_job! ⇒ Object
18 19 20 21 22 23 |
# File 'lib/sidekiq_job_controller/controller.rb', line 18 def skip_job! Sidekiq.redis do |conn| conn.mapped_hmset(job_controller_key, { action: :skip }) end status end |
#status ⇒ Object
32 33 34 |
# File 'lib/sidekiq_job_controller/controller.rb', line 32 def status "#{class_name} jobs are #{current_state}" end |