Class: Datadog::Core::Transport::HTTP::Adapters::UnixSocket::HTTP

Inherits:
Net::HTTP
  • Object
show all
Defined in:
lib/datadog/core/transport/http/adapters/unix_socket.rb

Overview

Re-implements Net:HTTP with underlying Unix socket

Constant Summary collapse

DEFAULT_TIMEOUT =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uds_path, options = {}) ⇒ HTTP

Returns a new instance of HTTP.



60
61
62
63
64
65
66
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 60

def initialize(uds_path, options = {})
  super('localhost', 80)
  @filepath = uds_path
  @read_timeout = options.fetch(:read_timeout, DEFAULT_TIMEOUT)
  @continue_timeout = options.fetch(:continue_timeout, DEFAULT_TIMEOUT)
  @debug_output = options[:debug_output] if options.key?(:debug_output)
end

Instance Attribute Details

#filepathObject (readonly) Also known as: uds_path

Returns the value of attribute filepath.



54
55
56
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 54

def filepath
  @filepath
end

#unix_socketObject (readonly)

Returns the value of attribute unix_socket.



54
55
56
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 54

def unix_socket
  @unix_socket
end

Instance Method Details

#connectObject



68
69
70
71
72
73
74
75
76
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 68

def connect
  @unix_socket = UNIXSocket.open(uds_path)
  @socket = ::Net::BufferedIO.new(@unix_socket).tap do |socket|
    socket.read_timeout = @read_timeout
    socket.continue_timeout = @continue_timeout
    socket.debug_output = @debug_output
  end
  on_connect
end