Class: GELF::Transport::TCP

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

Direct Known Subclasses

TCPTLS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addresses) ⇒ TCP

`addresses` Array of [host, port] pairs


7
8
9
10
# File 'lib/gelf/transport/tcp.rb', line 7

def initialize(addresses)
  @sockets = []
  self.addresses = addresses
end

Instance Attribute Details

#addressesObject

Returns the value of attribute addresses


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

def addresses
  @addresses
end

Instance Method Details

#send(message) ⇒ Object


19
20
21
22
23
24
25
26
# File 'lib/gelf/transport/tcp.rb', line 19

def send(message)
  return if @addresses.empty?
  loop do
    connected = @sockets.reject(&:closed?)
    reconnect_all if connected.empty?
    break if write_any(connected, message)
  end
end