Class: Datadog::Core::Remote::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/remote/client.rb,
lib/datadog/core/remote/client/capabilities.rb

Overview

Client communicates with the agent and sync remote configuration

Defined Under Namespace

Classes: Capabilities, SyncError, TransportError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport, capabilities, repository: Configuration::Repository.new) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
# File 'lib/datadog/core/remote/client.rb', line 18

def initialize(transport, capabilities, repository: Configuration::Repository.new)
  @transport = transport

  @repository = repository
  @id = SecureRandom.uuid
  @capabilities = capabilities
  @dispatcher = Dispatcher.new(@capabilities.receivers)
end

Instance Attribute Details

#dispatcherObject (readonly)

Returns the value of attribute dispatcher.



16
17
18
# File 'lib/datadog/core/remote/client.rb', line 16

def dispatcher
  @dispatcher
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/datadog/core/remote/client.rb', line 16

def id
  @id
end

#repositoryObject (readonly)

Returns the value of attribute repository.



16
17
18
# File 'lib/datadog/core/remote/client.rb', line 16

def repository
  @repository
end

#transportObject (readonly)

Returns the value of attribute transport.



16
17
18
# File 'lib/datadog/core/remote/client.rb', line 16

def transport
  @transport
end

Instance Method Details

#syncObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/datadog/core/remote/client.rb', line 27

def sync
  # TODO: Skip sync if no capabilities are registered
  response = transport.send_config(payload)

  if response.ok?
    process_response(response)
  elsif response.internal_error?
    raise TransportError, response.to_s
  end
end