class InfluxDB::Writer::UDP

Writes data to InfluxDB through UDP

Attributes

host[R]
port[R]
socket[RW]

Public Class Methods

new(client, host: "localhost".freeze, port: 4444) click to toggle source
# File lib/influxdb/writer/udp.rb, line 8
def initialize(client, host: "localhost".freeze, port: 4444)
  @client = client
  @host = host
  @port = port
end

Public Instance Methods

stop!() click to toggle source

No-op for UDP writers

# File lib/influxdb/writer/udp.rb, line 15
def stop!; end
write(payload, _precision = nil, _retention_policy = nil, _database = nil) click to toggle source
# File lib/influxdb/writer/udp.rb, line 17
def write(payload, _precision = nil, _retention_policy = nil, _database = nil)
  with_socket { |sock| sock.send(payload, 0) }
end

Private Instance Methods

with_socket() { |socket| ... } click to toggle source
# File lib/influxdb/writer/udp.rb, line 23
def with_socket
  unless socket
    self.socket = UDPSocket.new
    socket.connect(host, port)
  end

  yield socket
end