Class: Textus::Action::Jobs

Inherits:
Base
  • Object
show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/jobs.rb

Constant Summary collapse

BURN =
:sync

Instance Method Summary collapse

Methods included from Contract::DSL

arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view

Methods inherited from Base

#args, inherited

Constructor Details

#initialize(state: "ready", action: nil, job_id: nil) ⇒ Jobs

Returns a new instance of Jobs.



18
19
20
21
22
23
# File 'lib/textus/action/jobs.rb', line 18

def initialize(state: "ready", action: nil, job_id: nil)
  super()
  @state = state
  @action = action
  @job_id = job_id
end

Instance Method Details

#call(container:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/textus/action/jobs.rb', line 25

def call(container:, **)
  queue = Textus::Ports::Queue.new(root: container.root)
  case @action
  when "retry"
    queue.retry_failed(@job_id)
  when "purge"
    queue.purge(@state)
  end

  { "protocol" => Textus::PROTOCOL, "ok" => true, "state" => @state, "jobs" => queue.list(@state) }
end