Class: Searchkick::Middleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Searchkick::Middleware
- Defined in:
- lib/searchkick/middleware.rb
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/searchkick/middleware.rb', line 5 def call(env) path = env[:url].path.to_s if path.end_with?("/_search") env[:request][:timeout] = Searchkick.search_timeout elsif path.end_with?("/_msearch") # assume no concurrent searches for timeout for now searches = env[:request_body].count("\n") / 2 # do not allow timeout to exceed Searchkick.timeout timeout = [Searchkick.search_timeout * searches, Searchkick.timeout].min env[:request][:timeout] = timeout end @app.call(env) end |