From 0395b35ef6b9f49e303cd05b488b366bdcc12c8e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 14 Sep 2014 00:58:04 -0700 Subject: [PATCH] Added timeout method --- CHANGELOG.md | 4 ++++ README.md | 6 ++++++ lib/searchkick.rb | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b165b40..b67064c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.3 [unreleased] + +- Added `timeout` setting + ## 0.8.2 - Added `async` to `callbacks` option diff --git a/README.md b/README.md index 1b7555a..ed34afa 100644 --- a/README.md +++ b/README.md @@ -809,6 +809,12 @@ Product.enable_search_callbacks # or use Searchkick.enable_callbacks for all mod Product.reindex ``` +Change timeout [master] + +```ruby +Searchkick.timeout = 5 # defaults to 10 +``` + Change the search method name in `config/initializers/searchkick.rb` ```ruby diff --git a/lib/searchkick.rb b/lib/searchkick.rb index a1ed648..fde76d1 100644 --- a/lib/searchkick.rb +++ b/lib/searchkick.rb @@ -21,13 +21,19 @@ module Searchkick attr_accessor :callbacks attr_accessor :search_method_name attr_accessor :wordnet_path + attr_accessor :timeout end self.callbacks = true self.search_method_name = :search self.wordnet_path = "/var/lib/wn_s.pl" + self.timeout = 10 def self.client - @client ||= Elasticsearch::Client.new(url: ENV["ELASTICSEARCH_URL"]) + @client ||= + Elasticsearch::Client.new( + url: ENV["ELASTICSEARCH_URL"], + transport_options: {request: {timeout: timeout}} + ) end def self.client=(client) -- libgit2 0.21.0