Class: SidekiqJobController::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_job_controller/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

#jobObject (readonly)

Returns the value of attribute job.



3
4
5
# File 'lib/sidekiq_job_controller/controller.rb', line 3

def job
  @job
end

#payloadObject (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_actionObject



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

#statusObject



32
33
34
# File 'lib/sidekiq_job_controller/controller.rb', line 32

def status
  "#{class_name} jobs are #{current_state}"
end