[Groonga-commit] droonga/droonga-client-ruby at 1cf7783 [master] coolio: support sending before connect

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 2 17:00:07 JST 2014


Kouhei Sutou	2014-05-02 17:00:07 +0900 (Fri, 02 May 2014)

  New Revision: 1cf778385a15899c7bd61d18a39441ef6193d2ee
  https://github.com/droonga/droonga-client-ruby/commit/1cf778385a15899c7bd61d18a39441ef6193d2ee

  Message:
    coolio: support sending before connect

  Modified files:
    lib/droonga/client/connection/droonga-protocol/coolio.rb

  Modified: lib/droonga/client/connection/droonga-protocol/coolio.rb (+17 -3)
===================================================================
--- lib/droonga/client/connection/droonga-protocol/coolio.rb    2014-05-02 15:35:09 +0900 (d3673a9)
+++ lib/droonga/client/connection/droonga-protocol/coolio.rb    2014-05-02 17:00:07 +0900 (a601f03)
@@ -47,14 +47,28 @@ module Droonga
           end
 
           class Sender < ::Coolio::TCPSocket
-            def initialize(socket)
-              super(socket)
+            def initialize(*args)
+              super
+              @connected = false
+              @buffer = []
             end
 
             def send(tag, data)
               fluent_message = [tag, Time.now.to_i, data]
               packed_fluent_message = MessagePackPacker.pack(fluent_message)
-              write(packed_fluent_message)
+              if @connected
+                write(packed_fluent_message)
+              else
+                @buffer << packed_fluent_message
+              end
+            end
+
+            def on_connect
+              @connected = true
+              @buffer.each do |message|
+                write(message)
+              end
+              @buffer.clear
             end
           end
 
-------------- next part --------------
HTML����������������������������...
Download 



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