Class: Datadog::OpenFeature::Transport::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/open_feature/transport.rb

Defined Under Namespace

Classes: Spec

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apis, default_api, logger:) ⇒ HTTP

Returns a new instance of HTTP.



49
50
51
52
# File 'lib/datadog/open_feature/transport.rb', line 49

def initialize(apis, default_api, logger:)
  @api = apis[default_api]
  @logger = logger
end

Class Method Details

.build(agent_settings:, logger:) ⇒ Object



42
43
44
45
46
47
# File 'lib/datadog/open_feature/transport.rb', line 42

def self.build(agent_settings:, logger:)
  Core::Transport::HTTP.build(
    agent_settings: agent_settings,
    logger: logger
  ) { |t| t.api('exposures', HTTP::Spec.new) }.to_transport(self)
end

Instance Method Details

#send_exposures(payload) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/datadog/open_feature/transport.rb', line 54

def send_exposures(payload)
  request = Core::Transport::Request.new(EncodedParcel.new(payload))

  @api.endpoint.call(Core::Transport::HTTP::Env.new(request)) do |env|
    @api.call(env)
  end
rescue => e
  message = "Internal error during request. Cause: #{e.class.name} #{e.message} " \
            "Location: #{Array(e.backtrace).first}"
  @logger.debug(message)

  Core::Transport::InternalErrorResponse.new(e)
end