Module: Stomper::Extensions::Heartbeat::V1_1
- Defined in:
- lib/stomper/extensions/heartbeat.rb
Overview
Stomp Protocol 1.1 extensions to the heart-beating interface
Instance Method Summary collapse
-
#alive? ⇒ true, false
Stomp 1.1 connections are alive if they are Connection#connected? and are meeting their negotiated heart-beating obligations.
-
#beat ⇒ Object
Send a heartbeat to the broker.
-
#broker_alive? ⇒ true, false
Returns true if the broker is alive.
-
#client_alive? ⇒ true, false
Returns true if the client is alive.
-
#heartbeat_broker_limit ⇒ Fixnum
Maximum number of milliseconds that can pass between frames / heartbeats received before we consider the broker to be dead.
-
#heartbeat_client_limit ⇒ Fixnum
Maximum number of milliseconds that can pass between frame / heartbeat transmissions before we consider the client to be dead.
Instance Method Details
#alive? ⇒ true, false
Stomp 1.1 connections are alive if they are Connection#connected? and are meeting their negotiated heart-beating obligations.
47 48 49 |
# File 'lib/stomper/extensions/heartbeat.rb', line 47 def alive? connected? && client_alive? && broker_alive? end |
#beat ⇒ Object
Send a heartbeat to the broker
39 40 41 |
# File 'lib/stomper/extensions/heartbeat.rb', line 39 def beat transmit ::Stomper::Frame.new end |
#broker_alive? ⇒ true, false
Returns true if the broker is alive. Broker is alive if broker heartbeating is disabled, or the number of milliseconds that have passed since last receiving is less than or equal to broker limit
90 91 92 93 |
# File 'lib/stomper/extensions/heartbeat.rb', line 90 def broker_alive? @connecting || heartbeat_broker_limit == 0 || duration_since_received <= heartbeat_broker_limit end |
#client_alive? ⇒ true, false
Returns true if the client is alive. Client is alive if client heartbeating is disabled, or the number of milliseconds that have passed since last transmission is less than or equal to client limit
77 78 79 80 81 82 |
# File 'lib/stomper/extensions/heartbeat.rb', line 77 def client_alive? # Consider some benchmarking to determine if this is faster than # re-writing the method after its first invocation. @connecting || heartbeat_client_limit == 0 || duration_since_transmitted <= heartbeat_client_limit end |
#heartbeat_broker_limit ⇒ Fixnum
Maximum number of milliseconds that can pass between frames / heartbeats received before we consider the broker to be dead.
64 65 66 67 68 69 |
# File 'lib/stomper/extensions/heartbeat.rb', line 64 def heartbeat_broker_limit unless defined?(@heartbeat_broker_limit) @heartbeat_broker_limit = heartbeating[1] > 0 ? (1.1 * heartbeating[1]) : 0 end @heartbeat_broker_limit end |
#heartbeat_client_limit ⇒ Fixnum
Maximum number of milliseconds that can pass between frame / heartbeat transmissions before we consider the client to be dead.
54 55 56 57 58 59 |
# File 'lib/stomper/extensions/heartbeat.rb', line 54 def heartbeat_client_limit unless defined?(@heartbeat_client_limit) @heartbeat_client_limit = heartbeating[0] > 0 ? (1.1 * heartbeating[0]) : 0 end @heartbeat_client_limit end |