Sha256: c40d6e714b1d8300cf49308952033986e06d47efe1a93bd04d4c5f7b3497f6de
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require_relative 'connection' module Datadog class Statsd class UDSConnection < Connection class BadSocketError < StandardError; end # DogStatsd unix socket path attr_reader :socket_path def initialize(socket_path, **kwargs) super(**kwargs) @socket_path = socket_path end private def connect socket = Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM) socket.connect(Socket.pack_sockaddr_un(@socket_path)) socket end def send_message(message) socket.sendmsg_nonblock(message) rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ENOENT => e @socket = nil # TODO: FIXME: This error should be considered as a retryable error in the # Connection class. An even better solution would be to make BadSocketError inherit # from a specific retryable error class in the Connection class. raise BadSocketError, "#{e.class}: #{e}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems