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

Instance Method Summary collapse

Methods inherited from Net

#call, #post

Constructor Details

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

Returns a new instance of UnixSocket.



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

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

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



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

def filepath
  @filepath
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Instance Method Details

#openObject



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

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

  connection.start do |http|
    yield(http)
  end
end