Class: GELF::Transport::UDP

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addressesObject

Returns the value of attribute addresses.



4
5
6
# File 'lib/gelf/transport/udp.rb', line 4

def addresses
  @addresses
end

Instance Method Details

#closeObject



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