[Groonga-commit] groonga/fluent-plugin-groonga at cb64d1c [master] out: stop to reuse network connection

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Nov 22 16:54:15 JST 2017


Kouhei Sutou	2017-11-22 16:54:15 +0900 (Wed, 22 Nov 2017)

  New Revision: cb64d1c09182593123cdbd3d88592c9558b21954
  https://github.com/groonga/fluent-plugin-groonga/commit/cb64d1c09182593123cdbd3d88592c9558b21954

  Message:
    out: stop to reuse network connection

  Modified files:
    lib/fluent/plugin/out_groonga.rb

  Modified: lib/fluent/plugin/out_groonga.rb (+21 -23)
===================================================================
--- lib/fluent/plugin/out_groonga.rb    2017-11-22 16:52:36 +0900 (8b4d4a0)
+++ lib/fluent/plugin/out_groonga.rb    2017-11-22 16:54:15 +0900 (c303868)
@@ -628,37 +628,35 @@ module Fluent
         end
 
         def start
-          @client = nil
         end
 
         def shutdown
-          return if****@clien*****?
-          @client.close
         end
 
         def execute(name, arguments={})
           command = build_command(name, arguments)
-          @client ||= Groonga::Client.new(:protocol => @protocol,
-                                          :host     => @host,
-                                          :port     => @port,
-                                          :backend  => :synchronous)
-          response = nil
-          begin
-            response =****@clien*****(command)
-          rescue Groonga::Client::Error
-            @output_plugin.log.error("[output][groonga][error]",
-                                     :protocol => @protocol,
-                                     :host => @host,
-                                     :port => @port,
-                                     :command_name => name)
-            raise
-          end
-          unless response.success?
-            @output_plugin.log.error("[output][groonga][error]",
-                                     :status_code => response.status_code,
-                                     :message => response.message)
+          Groonga::Client.open(:protocol => @protocol,
+                               :host     => @host,
+                               :port     => @port,
+                               :backend  => :synchronous) do |client|
+            response = nil
+            begin
+              response = client.execute(command)
+            rescue Groonga::Client::Error
+              @output_plugin.log.error("[output][groonga][error]",
+                                       :protocol => @protocol,
+                                       :host => @host,
+                                       :port => @port,
+                                       :command_name => name)
+              raise
+            end
+            unless response.success?
+              @output_plugin.log.error("[output][groonga][error]",
+                                       :status_code => response.status_code,
+                                       :message => response.message)
+            end
+            response
           end
-          response
         end
       end
 
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171122/21c495d7/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index