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

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

Called by the framework to initialize the plugin

Parameters:

  • (Integer) port

    Unused

  • (Hash) config

    The server configuration data

  • (Hash) status

    A status hash

  • (Log4R::Logger) 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

- (Object) run

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