Class: Goliath::Plugin::Latency
- Inherits:
-
Object
- Object
- Goliath::Plugin::Latency
- Defined in:
- lib/goliath/plugins/latency.rb
Overview
Report latency information about the EventMachine reactor to the log file.
Constant Summary collapse
- LATENCY_TIMING =
Number of seconds to wait before logging latency
1
- @@recent_latency =
0
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(port, config, status, logger) ⇒ Goliath::Plugin::Latency
constructor
Called by the framework to initialize the plugin.
-
#run ⇒ Object
Called automatically to start the plugin.
Constructor Details
#initialize(port, config, status, logger) ⇒ Goliath::Plugin::Latency
Called by the framework to initialize the plugin
20 21 22 23 24 25 26 |
# File 'lib/goliath/plugins/latency.rb', line 20 def initialize(port, config, status, logger) @status = status @config = config @logger = logger @last = Time.now.to_f end |
Class Method Details
.recent_latency ⇒ Object
29 30 31 |
# File 'lib/goliath/plugins/latency.rb', line 29 def self.recent_latency @@recent_latency end |
Instance Method Details
#run ⇒ Object
Called automatically to start the plugin
34 35 36 37 38 39 40 |
# File 'lib/goliath/plugins/latency.rb', line 34 def run EM.add_periodic_timer(LATENCY_TIMING) do @@recent_latency = ((Time.now.to_f - @last) - LATENCY_TIMING) @logger.info "LATENCY: #{(@@recent_latency * 1000)} ms" @last = Time.now.to_f end end |