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

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

Overview

Adapter for Unix sockets

Defined Under Namespace

Classes: HTTP

Constant Summary collapse

DEFAULT_TIMEOUT =
1

Instance Attribute Summary collapse

Attributes inherited from Net

#hostname, #port, #ssl

Instance Method Summary collapse

Methods inherited from Net

#call, #post

Constructor Details

#initialize(filepath, options = {}) ⇒ UnixSocket

Returns a new instance of UnixSocket.



17
18
19
20
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 17

def initialize(filepath, options = {})
  @filepath = filepath
  @timeout = options.fetch(:timeout, DEFAULT_TIMEOUT)
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



13
14
15
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 13

def filepath
  @filepath
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



13
14
15
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 13

def timeout
  @timeout
end

Instance Method Details

#open(&block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 22

def open(&block)
  # Open connection
  connection = HTTP.new(
    filepath,
    read_timeout: timeout,
    continue_timeout: timeout
  )

  connection.start(&block)
end

#urlObject



33
34
35
# File 'lib/ddtrace/transport/http/adapters/unix_socket.rb', line 33

def url
  "http+unix://#{filepath}?timeout=#{timeout}"
end