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

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

Overview

Re-implements Net:HTTP with underlying Unix socket

Constant Summary collapse

DEFAULT_TIMEOUT =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HTTP.



56
57
58
59
60
61
62
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 56

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.



50
51
52
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 50

def filepath
  @filepath
end

#unix_socketObject (readonly)

Returns the value of attribute unix_socket.



50
51
52
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 50

def unix_socket
  @unix_socket
end

Instance Method Details

#connectObject



64
65
66
67
68
69
70
71
72
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 64

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