Module: Libis::Workflow::Base::Run

Includes:
WorkItem
Included in:
Run
Defined in:
lib/libis/workflow/base/run.rb

Overview

Base module for all workflow runs. It is created by an associated workflow when the workflow is executed.

This module lacks the implementation for the data attributes. It functions as an interface that describes the common functionality regardless of the storage implementation. These attributes require some implementation:

  • start_date: [Time] the timestamp of the execution of the run

  • job: [Object] a reference to the Job this Run belongs to

  • id: [String] (Optional) a unique run number

Note that ::Libis::Workflow::Base::WorkItem is a parent module and therefore requires implementation of the attributes of that module too.

A simple in-memory implementation can be found in ::Libis::Workflow::Run

Constant Summary

Constants included from Status

Status::STATUS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WorkItem

#add_item, #each, #get_items, #get_parent, #get_root, #get_run, #save, #save!, #size, #to_filename, #to_s

Methods included from Logging

#<=, #add_log, #log_message

Methods included from Status

#check_status, #compare_status, #status, #status=, #status_label

Instance Attribute Details

#actionObject

Returns the value of attribute action.



27
28
29
# File 'lib/libis/workflow/base/run.rb', line 27

def action
  @action
end

#tasksObject

Returns the value of attribute tasks.



27
28
29
# File 'lib/libis/workflow/base/run.rb', line 27

def tasks
  @tasks
end

Instance Method Details

#loggerObject



52
53
54
# File 'lib/libis/workflow/base/run.rb', line 52

def logger
  self.properties[:logger] || self.job.logger rescue ::Libis::Workflow::Config.logger
end

#nameObject



36
37
38
# File 'lib/libis/workflow/base/run.rb', line 36

def name
  self.job.run_name(self.start_date)
end

#namepathObject



44
45
46
# File 'lib/libis/workflow/base/run.rb', line 44

def namepath
  self.name
end

#namesObject



40
41
42
# File 'lib/libis/workflow/base/run.rb', line 40

def names
  Array.new
end

#run(action = :run) ⇒ Object

Execute the workflow.

The action parameter defines how the execution of the tasks will behave:

- With the default :run action each task will be executed regardsless how the task performed on the item
  previously.
- When using the :retry action a task will not perform on an item if it was successful the last time. This
  allows you to retry a run when an temporary error (e.g. asynchronous wait or halt) occured.

Parameters:

  • action (Symbol) (defaults to: :run)

    the type of action to take during this run. :run or :retry



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/libis/workflow/base/run.rb', line 65

def run(action = :run)
  self.action = action

  self.start_date = Time.now unless action == :retry

  self.options = workflow.prepare_input(self.options)

  self.tasks = workflow.tasks
  configure_tasks self.options

  self.tasks.each do |task|
    task.run self
  end

end

#work_dirObject



29
30
31
32
33
34
# File 'lib/libis/workflow/base/run.rb', line 29

def work_dir
  # noinspection RubyResolve
  dir = File.join(Config.workdir, self.name)
  FileUtils.mkpath dir unless Dir.exist?(dir)
  dir
end

#workflowObject



48
49
50
# File 'lib/libis/workflow/base/run.rb', line 48

def workflow
  self.job.workflow
end