Module: SidekiqWorkflows

Defined in:
lib/sidekiq_workflows.rb,
lib/sidekiq_workflows/node.rb,
lib/sidekiq_workflows/worker.rb,
lib/sidekiq_workflows/builder.rb,
lib/sidekiq_workflows/root_node.rb,
lib/sidekiq_workflows/worker_node.rb

Defined Under Namespace

Modules: Node Classes: Builder, RootNode, Worker, WorkerNode

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.callback_queueObject

Returns the value of attribute callback_queue.



7
8
9
# File 'lib/sidekiq_workflows.rb', line 7

def callback_queue
  @callback_queue
end

.worker_queueObject

Returns the value of attribute worker_queue.



6
7
8
# File 'lib/sidekiq_workflows.rb', line 6

def worker_queue
  @worker_queue
end

Class Method Details

.build(workflow_uuid: nil, on_partial_complete: nil, except: [], &block) ⇒ Object



29
30
31
32
33
# File 'lib/sidekiq_workflows.rb', line 29

def self.build(workflow_uuid: nil, on_partial_complete: nil, except: [], &block)
  root = RootNode.new(workflow_uuid: workflow_uuid, on_partial_complete: on_partial_complete)
  Builder.new(root, except).then(&block)
  root
end

.deserialize(string) ⇒ Object



16
17
18
# File 'lib/sidekiq_workflows.rb', line 16

def self.deserialize(string)
  from_h(JSON.parse(string, symbolize_names: true))
end

.from_h(hash, parent = nil) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/sidekiq_workflows.rb', line 20

def self.from_h(hash, parent = nil)
  parent ||= hash.key?(:workers) ? WorkerNode.new(workflow_uuid: hash[:workflow_uuid], on_partial_complete: hash[:on_partial_complete], workers: hash[:workers]) : RootNode.new(workflow_uuid: hash[:workflow_uuid], on_partial_complete: hash[:on_partial_complete])
  hash[:children].each do |h|
    child = parent.add_group(h[:workers])
    from_h(h, child)
  end
  parent
end