Class: GELF::Transport::UDP
- Inherits:
-
Object
- Object
- GELF::Transport::UDP
- Defined in:
- lib/gelf/transport/udp.rb
Instance Attribute Summary collapse
-
#addresses ⇒ Object
Returns the value of attribute addresses.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(addresses) ⇒ UDP
constructor
A new instance of UDP.
- #send_datagrams(datagrams) ⇒ Object
Constructor Details
#initialize(addresses) ⇒ UDP
Returns a new instance of UDP.
6 7 8 |
# File 'lib/gelf/transport/udp.rb', line 6 def initialize(addresses) @addresses = addresses end |
Instance Attribute Details
#addresses ⇒ Object
Returns the value of attribute addresses.
4 5 6 |
# File 'lib/gelf/transport/udp.rb', line 4 def addresses @addresses end |
Instance Method Details
#close ⇒ Object
21 22 23 24 |
# File 'lib/gelf/transport/udp.rb', line 21 def close socket = get_socket socket.close if socket end |
#send_datagrams(datagrams) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gelf/transport/udp.rb', line 10 def send_datagrams(datagrams) socket = get_socket idx = get_address_index host, port = @addresses[idx] set_address_index((idx + 1) % @addresses.length) datagrams.each do |datagram| socket.send(datagram, 0, host, port) end end |