Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Faraday Timeout in Ruby ElasticSearch Client

Is it possible to set the timeout property of a Faraday transport when creating a Ruby Elasticsearch::Client? There is the scope to pass a block when initializing an Elasticsearch::Transport::Transport::Faraday instance, but when trying the below we only ever get an empty set of connections back from __build_connections:

transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new do |connection|
  # connection.timeout = 1 # ???
end

Any suggestions as to how we should implement this block to set the timeout?

like image 952
EngineerBetter_DJ Avatar asked Dec 08 '22 09:12

EngineerBetter_DJ


1 Answers

you can run this.

Elasticsearch::Client.new transport_options: {
  request: { timeout: 1 }
}
like image 80
Joy Hu Avatar answered Dec 31 '22 17:12

Joy Hu