Class: Smith::Workflow::Parallel
- Inherits:
-
Object
- Object
- Smith::Workflow::Parallel
show all
- Defined in:
- lib/smith/workflow/parallel.rb,
lib/smith/workflow/parallel/cancellation.rb,
lib/smith/workflow/parallel/root_execution.rb,
lib/smith/workflow/parallel/nested_execution.rb,
lib/smith/workflow/parallel/execution_context.rb,
lib/smith/workflow/parallel/cancellation_signal.rb
Defined Under Namespace
Classes: Cancellation, CancellationSignal, ExecutionContext, NestedExecution, RootExecution
Class Method Summary
collapse
Class Method Details
.execute(branches:) ⇒ Object
.preferred_error(reasons) ⇒ Object
37
38
39
40
|
# File 'lib/smith/workflow/parallel.rb', line 37
def self.preferred_error(reasons)
errors = Array(reasons).compact
errors.find { |error| !error.is_a?(Cancellation) } || errors.first
end
|
.resolve_branch_count(transition, context) ⇒ Object
12
13
14
15
16
|
# File 'lib/smith/workflow/parallel.rb', line 12
def self.resolve_branch_count(transition, context)
count = transition.agent_opts[:count]
resolved = count.respond_to?(:call) ? count.call(context) : (count || 1)
validate_branch_count!(resolved)
end
|
.validate_branch_count!(count) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/smith/workflow/parallel.rb', line 18
def self.validate_branch_count!(count)
unless count.is_a?(Integer) && count.positive?
raise WorkflowError, "parallel branch count must be a positive integer"
end
limit = Smith.config.parallel_branch_limit
raise WorkflowError, "parallel branch count exceeds configured limit #{limit}" if count > limit
count
end
|