Class: Fluent::Plugin::PrometheusInput::AsyncWrapper::AsyncHttpWrapper
- Inherits:
-
Object
- Object
- Fluent::Plugin::PrometheusInput::AsyncWrapper::AsyncHttpWrapper
- Defined in:
- lib/fluent/plugin/in_prometheus/async_wrapper.rb
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(http) ⇒ AsyncHttpWrapper
constructor
A new instance of AsyncHttpWrapper.
Constructor Details
#initialize(http) ⇒ AsyncHttpWrapper
Returns a new instance of AsyncHttpWrapper.
24 25 26 |
# File 'lib/fluent/plugin/in_prometheus/async_wrapper.rb', line 24 def initialize(http) @http = http end |
Instance Method Details
#get(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/in_prometheus/async_wrapper.rb', line 28 def get(path) error = nil response = Async::Task.current.async { begin @http.get(path) rescue => e # Async::Reactor rescue all error. handle it by itself error = e end }.wait if error raise error end Response.new(response.status.to_s, response.read || '', response.headers) end |