Module: Fluent::Plugin::PrometheusInput::AsyncWrapper

Defined in:
lib/fluent/plugin/in_prometheus/async_wrapper.rb

Defined Under Namespace

Classes: AsyncHttpWrapper, Response

Instance Method Summary collapse

Instance Method Details

#do_request(host:, port:, secure:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fluent/plugin/in_prometheus/async_wrapper.rb', line 6

def do_request(host:, port:, secure:)
  endpoint =
    if secure
      context = OpenSSL::SSL::SSLContext.new
      context.verify_mode = OpenSSL::SSL::VERIFY_NONE
      Async::HTTP::Endpoint.parse("https://#{host}:#{port}", ssl_context: context)
    else
      Async::HTTP::Endpoint.parse("http://#{host}:#{port}")
    end

  Async::HTTP::Client.open(endpoint) do |client|
    yield(AsyncHttpWrapper.new(client))
  end
end