Class: Goliath::Plugin::Latency

Inherits:
Object
  • Object
show all
Defined in:
lib/goliath/plugins/latency.rb

Overview

Report latency information about the EventMachine reactor to the log file.

Examples:

plugin Goliath::Plugin::Latency

Instance Method Summary collapse

Constructor Details

#initialize(port, config, status, logger) ⇒ Goliath::Plugin::Latency

Called by the framework to initialize the plugin

Parameters:

  • port (Integer)

    Unused

  • config (Hash)

    The server configuration data

  • status (Hash)

    A status hash

  • logger (Log4R::Logger)

    The logger



16
17
18
19
20
21
22
# File 'lib/goliath/plugins/latency.rb', line 16

def initialize(port, config, status, logger)
  @status = status
  @config = config
  @logger = logger

  @last = Time.now.to_f
end

Instance Method Details

#runObject

Called automatically to start the plugin



25
26
27
28
29
30
# File 'lib/goliath/plugins/latency.rb', line 25

def run
  EM.add_periodic_timer(1) do
    @logger.info "LATENCY: #{Time.now.to_f - @last}"
    @last = Time.now.to_f
  end
end