Class: StatsD::Instrument::UdsConnection

Inherits:
Object
  • Object
show all
Includes:
ConnectionBehavior
Defined in:
lib/statsd/instrument/uds_connection.rb

Constant Summary collapse

DEFAULT_MAX_PACKET_SIZE =
8_192

Instance Method Summary collapse

Methods included from ConnectionBehavior

#close, #send_buffer_size

Constructor Details

#initialize(socket_path, max_packet_size: DEFAULT_MAX_PACKET_SIZE) ⇒ UdsConnection

Returns a new instance of UdsConnection.



10
11
12
13
14
15
16
17
18
19
# File 'lib/statsd/instrument/uds_connection.rb', line 10

def initialize(socket_path, max_packet_size: DEFAULT_MAX_PACKET_SIZE)
  if max_packet_size <= 0
    StatsD.logger.warn do
      "[StatsD::Instrument::UdsConnection] max_packet_size must be greater than 0, " \
        "using default: #{DEFAULT_MAX_PACKET_SIZE}"
    end
  end
  @socket_path = socket_path
  @max_packet_size = max_packet_size
end

Instance Method Details

#hostObject



25
26
27
# File 'lib/statsd/instrument/uds_connection.rb', line 25

def host
  nil
end

#portObject



29
30
31
# File 'lib/statsd/instrument/uds_connection.rb', line 29

def port
  nil
end

#send_datagram(message) ⇒ Object



21
22
23
# File 'lib/statsd/instrument/uds_connection.rb', line 21

def send_datagram(message)
  socket&.sendmsg(message, 0)
end

#typeObject



33
34
35
# File 'lib/statsd/instrument/uds_connection.rb', line 33

def type
  :uds
end