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

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

Overview

Adapter for Unix sockets

Defined Under Namespace

Classes: HTTP

Constant Summary

Constants inherited from Net

Net::DEFAULT_TIMEOUT

Instance Attribute Summary collapse

Attributes inherited from Net

#hostname, #port, #ssl

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Net

#call, #get, #post

Constructor Details

#initialize(uds_path = nil, **options) ⇒ UnixSocket

Deprecated.

Positional parameters are deprecated. Use named parameters instead.

rubocop:disable Lint/MissingSuper



22
23
24
25
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 22

def initialize(uds_path = nil, **options)
  @filepath = uds_path || options.fetch(:uds_path)
  @timeout = options[:timeout] || Datadog::Core::Transport::Ext::UnixSocket::DEFAULT_TIMEOUT_SECONDS
end

Instance Attribute Details

#filepathObject (readonly) Also known as: uds_path

Returns the value of attribute filepath.



14
15
16
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 14

def filepath
  @filepath
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



14
15
16
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 14

def timeout
  @timeout
end

Class Method Details

.build(agent_settings) ⇒ Object

rubocop:enable Lint/MissingSuper



28
29
30
31
32
33
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 28

def self.build(agent_settings)
  new(
    uds_path: agent_settings.uds_path,
    timeout: agent_settings.timeout_seconds,
  )
end

Instance Method Details

#open(&block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 35

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

  connection.start(&block)
end

#urlObject



46
47
48
# File 'lib/datadog/core/transport/http/adapters/unix_socket.rb', line 46

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