Class: JobWorkflow::Task
- Inherits:
-
Object
- Object
- JobWorkflow::Task
- Defined in:
- lib/job_workflow/task.rb
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
-
#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
34 35 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 |
# File 'lib/job_workflow/task.rb', line 34 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
6 7 8 |
# File 'lib/job_workflow/task.rb', line 6 def block @block end |
#condition ⇒ Object (readonly)
: ^(Context) -> bool
11 12 13 |
# File 'lib/job_workflow/task.rb', line 11 def condition @condition end |
#dependency_wait ⇒ Object (readonly)
: TaskDependencyWait
15 16 17 |
# File 'lib/job_workflow/task.rb', line 15 def dependency_wait @dependency_wait end |
#depends_on ⇒ Object (readonly)
: Array
10 11 12 |
# File 'lib/job_workflow/task.rb', line 10 def depends_on @depends_on end |
#dry_run_config ⇒ Object (readonly)
: DryRunConfig
16 17 18 |
# File 'lib/job_workflow/task.rb', line 16 def dry_run_config @dry_run_config end |
#each ⇒ Object (readonly)
: ^(Context) -> untyped
7 8 9 |
# File 'lib/job_workflow/task.rb', line 7 def each @each end |
#enqueue ⇒ Object (readonly)
: TaskEnqueue
8 9 10 |
# File 'lib/job_workflow/task.rb', line 8 def enqueue @enqueue end |
#job_name ⇒ Object (readonly)
: String
5 6 7 |
# File 'lib/job_workflow/task.rb', line 5 def job_name @job_name end |
#output ⇒ Object (readonly)
: Array
9 10 11 |
# File 'lib/job_workflow/task.rb', line 9 def output @output end |
#task_retry ⇒ Object (readonly)
: TaskRetry
12 13 14 |
# File 'lib/job_workflow/task.rb', line 12 def task_retry @task_retry end |
#throttle ⇒ Object (readonly)
: TaskThrottle
13 14 15 |
# File 'lib/job_workflow/task.rb', line 13 def throttle @throttle end |
#timeout ⇒ Object (readonly)
: Numeric?
14 15 16 |
# File 'lib/job_workflow/task.rb', line 14 def timeout @timeout end |
Instance Method Details
#task_name ⇒ Object
: () -> Symbol
66 67 68 |
# File 'lib/job_workflow/task.rb', line 66 def task_name name end |
#throttle_prefix_key ⇒ Object
: () -> String
71 72 73 |
# File 'lib/job_workflow/task.rb', line 71 def throttle_prefix_key "#{job_name}:#{task_name}" end |