Class: Riemann::Client::UDP
- Inherits:
-
Riemann::Client
- Object
- Riemann::Client
- Riemann::Client::UDP
- Defined in:
- lib/riemann/client/udp.rb
Constant Summary collapse
- MAX_SIZE =
16384
Constants inherited from Riemann::Client
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#max_size ⇒ Object
Returns the value of attribute max_size.
-
#port ⇒ Object
Returns the value of attribute port.
Attributes inherited from Riemann::Client
Instance Method Summary collapse
- #close ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(opts = {}) ⇒ UDP
constructor
A new instance of UDP.
-
#read_message(s) ⇒ Object
Read a message from a stream.
- #send_maybe_recv(message) ⇒ Object
- #send_recv(*a) ⇒ Object
- #socket ⇒ Object
Methods inherited from Riemann::Client
#<<, #[], #connect, #query, #timeout
Constructor Details
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/riemann/client/udp.rb', line 6 def host @host end |
#max_size ⇒ Object
Returns the value of attribute max_size.
6 7 8 |
# File 'lib/riemann/client/udp.rb', line 6 def max_size @max_size end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/riemann/client/udp.rb', line 6 def port @port end |
Instance Method Details
#close ⇒ Object
19 20 21 22 |
# File 'lib/riemann/client/udp.rb', line 19 def close @socket.close if connected? @socket = nil end |
#connected? ⇒ Boolean
24 25 26 |
# File 'lib/riemann/client/udp.rb', line 24 def connected? @socket && !@socket.closed? end |
#read_message(s) ⇒ Object
Read a message from a stream
29 30 31 |
# File 'lib/riemann/client/udp.rb', line 29 def (s) raise Unsupported end |
#send_maybe_recv(message) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/riemann/client/udp.rb', line 37 def send_maybe_recv() encoded_string = .encode.to_s raise TooBig unless encoded_string.length < @max_size socket.send(encoded_string, 0, @host, @port) nil end |
#send_recv(*a) ⇒ Object
33 34 35 |
# File 'lib/riemann/client/udp.rb', line 33 def send_recv(*a) raise Unsupported end |
#socket ⇒ Object
14 15 16 17 |
# File 'lib/riemann/client/udp.rb', line 14 def socket return @socket if connected? @socket = UDPSocket.new end |