Class: Sanford::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/sanford/worker.rb

Defined Under Namespace

Classes: ProcessedService, SummaryLine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host_data, connection) ⇒ Worker

Returns a new instance of Worker.



16
17
18
19
20
# File 'lib/sanford/worker.rb', line 16

def initialize(host_data, connection)
  @host_data, @connection = host_data, connection

  @logger = Sanford::Logger.new(@host_data.logger, @host_data.verbose)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



14
15
16
# File 'lib/sanford/worker.rb', line 14

def logger
  @logger
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sanford/worker.rb', line 22

def run
  processed_service = nil
  self.log_received
  benchmark = Benchmark.measure do
    processed_service = self.run!
  end
  processed_service.time_taken = self.round_time(benchmark.real)
  self.log_complete(processed_service)
  self.raise_if_debugging!(processed_service.exception)
  processed_service
end