Sha256: d381f8291d551ecaac34178cc1fe164512e309bd66f438b5c4ee5c2b2797d19d

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative '../../../ddtrace/transport/request'
require_relative '../../../ddtrace/transport/parcel'

module Datadog
  module Core
    module Transport
      module Config
        # Data transfer object for encoded traces
        class EncodedParcel
          include Datadog::Transport::Parcel

          def count
            data.length
          end
        end

        # Config request
        class Request < Datadog::Transport::Request
        end

        # Config response
        module Response
          attr_reader :roots, :targets, :target_files, :client_configs

          def empty?
            @empty
          end
        end

        # Config transport
        class Transport
          attr_reader :client, :apis, :default_api, :current_api_id

          def initialize(apis, default_api)
            @apis = apis

            @client = HTTP::Client.new(current_api)
          end

          ##### there is only one transport! it's negotiation!
          def send_config(payload)
            json = JSON.dump(payload)
            parcel = EncodedParcel.new(json)
            request = Request.new(parcel)

            @client.send_config_payload(request)
          end

          def current_api
            @apis[HTTP::API::V7]
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ddtrace-1.14.0 lib/datadog/core/transport/config.rb
ddtrace-1.13.1 lib/datadog/core/transport/config.rb
ddtrace-1.13.0 lib/datadog/core/transport/config.rb
ddtrace-1.12.1 lib/datadog/core/transport/config.rb
ddtrace-1.12.0 lib/datadog/core/transport/config.rb
ddtrace-1.11.1 lib/datadog/core/transport/config.rb
ddtrace-1.11.0 lib/datadog/core/transport/config.rb
ddtrace-1.11.0.beta1 lib/datadog/core/transport/config.rb