Kouhei Sutou
null+****@clear*****
Fri Oct 27 16:19:21 JST 2017
Kouhei Sutou 2017-10-27 16:19:21 +0900 (Fri, 27 Oct 2017) New Revision: fee23f2cc635a9bb55a6534e23323e1e4d9ac76d https://github.com/ranguba/groonga-client/commit/fee23f2cc635a9bb55a6534e23323e1e4d9ac76d Message: Disable auto retry by net/http Because GET isn't idempotent in Groonga such as delete command. Modified files: bin/groonga-client bin/groonga-client-index-recreate lib/groonga/client/protocol/http/synchronous.rb Modified: bin/groonga-client (+0 -6) =================================================================== --- bin/groonga-client 2017-10-27 15:42:44 +0900 (e99dc75) +++ bin/groonga-client 2017-10-27 16:19:21 +0900 (686bb36) @@ -17,12 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "net/http" - -if Net::HTTP.const_defined?(:IDEMPOTENT_METHODS_) - Net::HTTP::IDEMPOTENT_METHODS_.clear -end - require "groonga/client/command-line/groonga-client" command_line = Groonga::Client::CommandLine::GroongaClient.new Modified: bin/groonga-client-index-recreate (+0 -6) =================================================================== --- bin/groonga-client-index-recreate 2017-10-27 15:42:44 +0900 (aad43f3) +++ bin/groonga-client-index-recreate 2017-10-27 16:19:21 +0900 (4e591fd) @@ -17,12 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "net/http" - -if Net::HTTP.const_defined?(:IDEMPOTENT_METHODS_) - Net::HTTP::IDEMPOTENT_METHODS_.clear -end - require "groonga/client/command-line/groonga-client-index-recreate" command_line = Groonga::Client::CommandLine::GroongaClientIndexRecreate.new Modified: lib/groonga/client/protocol/http/synchronous.rb (+22 -1) =================================================================== --- lib/groonga/client/protocol/http/synchronous.rb 2017-10-27 15:42:44 +0900 (34a4d54) +++ lib/groonga/client/protocol/http/synchronous.rb 2017-10-27 16:19:21 +0900 (e01bac0) @@ -27,6 +27,27 @@ module Groonga module Protocol class HTTP class Synchronous + # TODO: Workaround to disable retry in net/http. + class HTTPClient < Net::HTTP + class ReadTimeout < StandardError + end + + module ReadTimeoutConvertable + def rbuf_fill + begin + super + rescue Net::ReadTimeout => error + raise ReadTimeout, error.message, error.backtrace + end + end + end + + private + def on_connect + @socket.extend(ReadTimeoutConvertable) + end + end + include PathResolvable def initialize(url, options={}) @@ -36,7 +57,7 @@ module Groonga def send(command) begin - Net::HTTP.start(@url.host, @url.port, start_options) do |http| + HTTPClient.start(@url.host, @url.port, start_options) do |http| http.read_timeout = read_timeout response = send_request(http, command) case response -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171027/83756f14/attachment-0001.htm