module Libis::Workflow::Base::Run

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:

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

Attributes

action[RW]
tasks[RW]

Public Instance Methods

logger() click to toggle source
# File lib/libis/workflow/base/run.rb, line 50
def logger
  self.properties['logger'] || self.job.logger rescue ::Libis::Workflow::Config.logger
end
name() click to toggle source
# File lib/libis/workflow/base/run.rb, line 34
def name
  self.job.run_name(self.start_date)
end
namepath() click to toggle source
# File lib/libis/workflow/base/run.rb, line 42
def namepath
  self.name
end
names() click to toggle source
# File lib/libis/workflow/base/run.rb, line 38
def names
  Array.new
end
run(action = :run) click to toggle source

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.

@param [Symbol] action the type of action to take during this run. :run or :retry

# File lib/libis/workflow/base/run.rb, line 63
def run(action = :run)
  self.action = action

  unless action == :retry
    self.start_date = Time.now
    self.options = workflow.prepare_input(self.options)
  end


  self.tasks = workflow.tasks
  configure_tasks self.options

  self.save!

  runner = Libis::Workflow::TaskRunner.new nil

  self.tasks.each do |task|
    runner << task
  end

  runner.run self

end
work_dir() click to toggle source
# File lib/libis/workflow/base/run.rb, line 27
def work_dir
  # noinspection RubyResolve
  dir = File.join(Libis::Workflow::Config.workdir, self.name)
  FileUtils.mkpath dir unless Dir.exist?(dir)
  dir
end
workflow() click to toggle source
# File lib/libis/workflow/base/run.rb, line 46
def workflow
  self.job.workflow
end

Protected Instance Methods

configure_tasks(opts) click to toggle source
# File lib/libis/workflow/base/run.rb, line 89
def configure_tasks(opts)
  self.tasks.each { |task| task.apply_options opts }
end