Class: BatchKit::Task::Run

Inherits:
Runnable show all
Defined in:
lib/batch-kit/framework/task_run.rb

Overview

Captures details of an execution of a task.

Instance Attribute Summary collapse

Attributes inherited from Runnable

#definition, #end_time, #exception, #exit_code, #instance, #lock_name, #lock_timeout, #lock_wait_timeout, #object, #start_time, #status

Instance Method Summary collapse

Methods inherited from Runnable

#abort, add_delegated_properties, #around_execute, #elapsed, #event_name, #failure, #label, #post_execute, #pre_execute, #success

Methods included from Lockable

#lock, #unlock, #with_lock

Constructor Details

#initialize(task_def, job_object, job_run, *run_args) ⇒ Run

Create a new task run.

Parameters:

  • task_def (Task::Definition)

    The Task::Definition to which this run relates.

  • job_object (Object)

    The job object instance from which the task is being executed.

  • job_run (Job::Run)

    The job run to which this task run belongs.

  • run_args (Array<Object>)

    An array of the argument values passed to the task method.

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/batch-kit/framework/task_run.rb', line 27

def initialize(task_def, job_object, job_run, *run_args)
    raise ArgumentError, "task_def not a Task::Definition" unless task_def.is_a?(Task::Definition)
    raise ArgumentError, "job_run not a Job::Run" unless job_run.is_a?(Job::Run)
    @job_run = job_run
    @job_run << self
    super(task_def, job_object, run_args)
end

Instance Attribute Details

#job_runJob::Run (readonly)

Returns The job run that this task is running under.

Returns:

  • (Job::Run)

    The job run that this task is running under.



9
10
11
# File 'lib/batch-kit/framework/task_run.rb', line 9

def job_run
  @job_run
end

#task_run_idFixnum

Returns An integer identifier that uniquely identifies this task run.

Returns:

  • (Fixnum)

    An integer identifier that uniquely identifies this task run.



12
13
14
# File 'lib/batch-kit/framework/task_run.rb', line 12

def task_run_id
  @task_run_id
end

Instance Method Details

#persist?Boolean

Returns True if this task run should be persisted in any persistence layer.

Returns:

  • (Boolean)

    True if this task run should be persisted in any persistence layer.



38
39
40
# File 'lib/batch-kit/framework/task_run.rb', line 38

def persist?
    !definition.job.do_not_track
end

#to_sString

Returns A short representation of this Task::Run.

Returns:

  • (String)

    A short representation of this Task::Run.



44
45
46
# File 'lib/batch-kit/framework/task_run.rb', line 44

def to_s
    "<BatchKit::Task::Run label='#{label}'>"
end