Class: LocalJob

Inherits:
Job
  • Object
show all
Defined in:
lib/local_job.rb

Overview

This class represents a job that will be run locally.

Instance Attribute Summary

Attributes inherited from Job

#description, #host_group, #job_group, #meta_information, #result_transformer

Instance Method Summary collapse

Methods inherited from Job

#run_meta, #run_on_host, #to_s

Constructor Details

#initialize(description, job_group, code, result_transformer = nil) ⇒ LocalJob

Creates a new local job.

Parameters:

  • description (String)

    Textual description of the job. This is used for logging and debugging purposes.

  • job_group (String)

    Job group of the job. For an explanation see the Documentation of the JobManager class.

  • code (Proc)

    A proc containing the code to be executed in this job.

  • result_transformer (Proc) (defaults to: nil)

    Function that will be applied to the result.


10
11
12
13
# File 'lib/local_job.rb', line 10

def initialize(description, job_group, code, result_transformer = nil)
  super description, job_group, :local, result_transformer
  @code = code
end

Instance Method Details

#run_local(job_result) ⇒ Object


16
17
18
19
20
21
# File 'lib/local_job.rb', line 16

def run_local(job_result)
  thread = Thread.new {
    job_result.complete! @code[]
  }
  job_result
end