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 20 21 22 23 24 25 26 |
# File 'lib/fluent/plugin/in_prometheus/async_wrapper.rb', line 6 def do_request(host:, port:, secure:) # Format host for URI - bracket IPv6 addresses if not already bracketed uri_host = if host.include?(':') && !host.start_with?('[') "[#{host}]" else host end endpoint = if secure context = OpenSSL::SSL::SSLContext.new context.verify_mode = OpenSSL::SSL::VERIFY_NONE Async::HTTP::Endpoint.parse("https://#{uri_host}:#{port}", ssl_context: context) else Async::HTTP::Endpoint.parse("http://#{uri_host}:#{port}") end Async::HTTP::Client.open(endpoint) do |client| yield(AsyncHttpWrapper.new(client)) end end |