Class: GELF::RubyUdpSender
- Inherits:
-
Object
- Object
- GELF::RubyUdpSender
- Defined in:
- lib/gelf/ruby_sender.rb
Overview
Plain Ruby UDP sender.
Instance Attribute Summary (collapse)
-
- (Object) addresses
Returns the value of attribute addresses.
Instance Method Summary (collapse)
-
- (RubyUdpSender) initialize(addresses)
constructor
A new instance of RubyUdpSender.
- - (Object) send_datagrams(datagrams)
Constructor Details
- (RubyUdpSender) initialize(addresses)
A new instance of RubyUdpSender
6 7 8 9 10 |
# File 'lib/gelf/ruby_sender.rb', line 6 def initialize(addresses) @addresses = addresses @i = 0 @socket = UDPSocket.open end |
Instance Attribute Details
- (Object) addresses
Returns the value of attribute addresses
4 5 6 |
# File 'lib/gelf/ruby_sender.rb', line 4 def addresses @addresses end |
Instance Method Details
- (Object) send_datagrams(datagrams)
12 13 14 15 16 17 18 |
# File 'lib/gelf/ruby_sender.rb', line 12 def send_datagrams(datagrams) host, port = @addresses[@i] @i = (@i + 1) % @addresses.length datagrams.each do |datagram| @socket.send(datagram, 0, host, port) end end |