Class: Oxidized::Job

Inherits:
Thread
  • Object
show all
Includes:
SemanticLogger::Loggable
Defined in:
lib/oxidized/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Job

Returns a new instance of Job.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/oxidized/job.rb', line 7

def initialize(node)
  @node = node
  @start = Time.now.utc
  self.name = "Job '#{@node.name}'"
  super do
    logger.debug "Starting fetching process for #{@node.name}"
    begin
      Timeout.timeout(Oxidized.config.timelimit) do
        @status, @config = @node.run
      end
      logger.debug "Config fetched for #{@node.name}"
    rescue Timeout::Error
      logger.warn "Job timelimit reached for #{@node.name}"
      @status = :timelimit
    ensure
      @end  = Time.now.utc
      @time = @end - @start
    end
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def config
  @config
end

#endObject (readonly)

Returns the value of attribute end.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def end
  @end
end

#nodeObject (readonly)

Returns the value of attribute node.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def node
  @node
end

#startObject (readonly)

Returns the value of attribute start.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def start
  @start
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/oxidized/job.rb', line 5

def time
  @time
end