Class: StatsD::Instrument::UdsConnection

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

Constant Summary collapse

DEFAULT_MAX_PACKET_SIZE =
8_192

Instance Method Summary collapse

Constructor Details

#initialize(socket_path, max_packet_size: DEFAULT_MAX_PACKET_SIZE) ⇒ UdsConnection

Returns a new instance of UdsConnection.



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

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

#closeObject



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

def close
  @socket&.close
  @socket = nil
end

#hostObject



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

def host
  nil
end

#portObject



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

def port
  nil
end

#send_datagram(message) ⇒ Object



19
20
21
# File 'lib/statsd/instrument/uds_connection.rb', line 19

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

#typeObject



36
37
38
# File 'lib/statsd/instrument/uds_connection.rb', line 36

def type
  :uds
end