[Groonga-commit] groonga/fluent-plugin-kotoumi [master] Use new reply protocol

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 30 17:10:44 JST 2013


Kouhei Sutou	2013-01-30 17:10:44 +0900 (Wed, 30 Jan 2013)

  New Revision: 71706dc898a77a15160f96f5a455d9110cb4f87b
  https://github.com/groonga/fluent-plugin-kotoumi/commit/71706dc898a77a15160f96f5a455d9110cb4f87b

  Log:
    Use new reply protocol
    
    New protocol: raw TCP socket and MessagePack
    Old protocol: SocketIO (it uses JSON)

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

  Modified: lib/fluent/plugin/out_kotoumi.rb (+8 -9)
===================================================================
--- lib/fluent/plugin/out_kotoumi.rb    2013-01-30 16:47:31 +0900 (b450fc6)
+++ lib/fluent/plugin/out_kotoumi.rb    2013-01-30 17:10:44 +0900 (663ef27)
@@ -15,7 +15,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-require 'SocketIO'
+require "socket"
+require "msgpack"
 require 'kotoumi/worker'
 
 module Fluent
@@ -35,7 +36,7 @@ module Fluent
     def shutdown
       super
       @outputs.each do |dest, socket|
-        socket.disconnect
+        socket.close
       end
     end
 
@@ -64,16 +65,14 @@ module Fluent
     end
 
     def post(dest, tag, result)
-      post_socket_io(dest, tag, result)
-    end
-
-    def post_socket_io(dest, tag, result)
       unless @outputs[dest]
-        uri = 'http://' + dest
-        socket = SocketIO.connect(uri, sync: true)
+        host, port = dest.split(/:/, 2)
+        port = Integer(port)
+        socket = TCPSocket.new(host, port)
         @outputs[dest] = socket
       end
-      @outputs[dest].emit(tag, result)
+      data = {"tag" => tag, "data" => result}.to_msgpack
+      @outputs[dest].write(data)
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
다운로드 



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