Class: JobWorkflow::Task
- Inherits:
-
Object
- Object
- JobWorkflow::Task
- Defined in:
- lib/job_workflow/task.rb
Constant Summary collapse
- DEFAULT_EACH =
->(_ctx) { [nil] }
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
: ^(untyped) -> void.
-
#condition ⇒ Object
readonly
: ^(Context) -> bool.
-
#dependency_wait ⇒ Object
readonly
: TaskDependencyWait.
-
#depends_on ⇒ Object
readonly
: Array.
-
#dry_run_config ⇒ Object
readonly
: DryRunConfig.
-
#each ⇒ Object
readonly
: ^(Context) -> untyped.
-
#enqueue ⇒ Object
readonly
: TaskEnqueue.
-
#job_name ⇒ Object
readonly
: String.
-
#output ⇒ Object
readonly
: Array.
-
#task_retry ⇒ Object
readonly
: TaskRetry.
-
#throttle ⇒ Object
readonly
: TaskThrottle.
-
#timeout ⇒ Object
readonly
: Numeric?.
Instance Method Summary collapse
-
#each? ⇒ Boolean
: () -> bool.
-
#initialize(job_name:, name:, block:, each: nil, enqueue: nil, output: {}, depends_on: [], condition: ->(_ctx) { true }, task_retry: 0, throttle: {}, timeout: nil, dependency_wait: {}, dry_run: false) ⇒ Task
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength : ( job_name: String, name: Symbol, block: ^(untyped) -> void, ?each: ^(Context) -> untyped, ?enqueue: true | false | ^(Context) -> bool | Hash[Symbol, untyped], ?output: Hash[Symbol, String], ?depends_on: Array, condition: ^(Context) -> bool, ?task_retry: Integer | Hash[Symbol, untyped], ?throttle: Integer | Hash[Symbol, untyped], ?timeout: Numeric?, ?dependency_wait: Hash[Symbol, untyped], ?dry_run: bool | ^(Context) -> bool ) -> void.
-
#task_name ⇒ Object
: () -> Symbol.
-
#throttle_prefix_key ⇒ Object
: () -> String.
Constructor Details
#initialize(job_name:, name:, block:, each: nil, enqueue: nil, output: {}, depends_on: [], condition: ->(_ctx) { true }, task_retry: 0, throttle: {}, timeout: nil, dependency_wait: {}, dry_run: false) ⇒ Task
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength : (
job_name: String,
name: Symbol,
block: ^(untyped) -> void,
?each: ^(Context) -> untyped,
?enqueue: true | false | ^(Context) -> bool | Hash[Symbol, untyped],
?output: Hash[Symbol, String],
?depends_on: Array[Symbol],
condition: ^(Context) -> bool,
?task_retry: Integer | Hash[Symbol, untyped],
?throttle: Integer | Hash[Symbol, untyped],
?timeout: Numeric?,
?dependency_wait: Hash[Symbol, untyped],
?dry_run: bool | ^(Context) -> bool
) -> void
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/job_workflow/task.rb', line 36 def initialize( job_name:, name:, block:, each: nil, enqueue: nil, output: {}, depends_on: [], condition: ->(_ctx) { true }, task_retry: 0, throttle: {}, timeout: nil, dependency_wait: {}, dry_run: false ) @job_name = job_name @name = name @block = block @each = each @enqueue = TaskEnqueue.from_primitive_value(enqueue) @output = output.map { |name, type| OutputDef.new(name:, type:) } @depends_on = depends_on @condition = condition @task_retry = TaskRetry.from_primitive_value(task_retry) @throttle = TaskThrottle.from_primitive_value_with_task(value: throttle, task: self) @timeout = timeout @dependency_wait = TaskDependencyWait.from_primitive_value(dependency_wait) @dry_run_config = DryRunConfig.from_primitive_value(dry_run) end |
Instance Attribute Details
#block ⇒ Object (readonly)
: ^(untyped) -> void
8 9 10 |
# File 'lib/job_workflow/task.rb', line 8 def block @block end |
#condition ⇒ Object (readonly)
: ^(Context) -> bool
13 14 15 |
# File 'lib/job_workflow/task.rb', line 13 def condition @condition end |
#dependency_wait ⇒ Object (readonly)
: TaskDependencyWait
17 18 19 |
# File 'lib/job_workflow/task.rb', line 17 def dependency_wait @dependency_wait end |
#depends_on ⇒ Object (readonly)
: Array
12 13 14 |
# File 'lib/job_workflow/task.rb', line 12 def depends_on @depends_on end |
#dry_run_config ⇒ Object (readonly)
: DryRunConfig
18 19 20 |
# File 'lib/job_workflow/task.rb', line 18 def dry_run_config @dry_run_config end |
#each ⇒ Object (readonly)
: ^(Context) -> untyped
9 10 11 |
# File 'lib/job_workflow/task.rb', line 9 def each @each end |
#enqueue ⇒ Object (readonly)
: TaskEnqueue
10 11 12 |
# File 'lib/job_workflow/task.rb', line 10 def enqueue @enqueue end |
#job_name ⇒ Object (readonly)
: String
7 8 9 |
# File 'lib/job_workflow/task.rb', line 7 def job_name @job_name end |
#output ⇒ Object (readonly)
: Array
11 12 13 |
# File 'lib/job_workflow/task.rb', line 11 def output @output end |
#task_retry ⇒ Object (readonly)
: TaskRetry
14 15 16 |
# File 'lib/job_workflow/task.rb', line 14 def task_retry @task_retry end |
#throttle ⇒ Object (readonly)
: TaskThrottle
15 16 17 |
# File 'lib/job_workflow/task.rb', line 15 def throttle @throttle end |
#timeout ⇒ Object (readonly)
: Numeric?
16 17 18 |
# File 'lib/job_workflow/task.rb', line 16 def timeout @timeout end |
Instance Method Details
#each? ⇒ Boolean
: () -> bool
78 79 80 |
# File 'lib/job_workflow/task.rb', line 78 def each? !each.nil? && !each.equal?(DEFAULT_EACH) end |
#task_name ⇒ Object
: () -> Symbol
68 69 70 |
# File 'lib/job_workflow/task.rb', line 68 def task_name name end |
#throttle_prefix_key ⇒ Object
: () -> String
73 74 75 |
# File 'lib/job_workflow/task.rb', line 73 def throttle_prefix_key "#{job_name}:#{task_name}" end |