Class: GELF::RubyUdpSender

Inherits:
Object
  • Object
show all
Defined in:
lib/gelf/ruby_sender.rb

Overview

Plain Ruby UDP sender.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (RubyUdpSender) initialize(addresses)



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