Navigation Menu

Skip to content

Commit

Permalink
Add method to just reserve write
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jun 27, 2014
1 parent c75091d commit 1d909f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/droonga/buffered_tcp_socket.rb
Expand Up @@ -34,10 +34,15 @@ def on_connect
end

def write(data)
reserve_write(data)
schedule_write
data.bytesize
end

def reserve_write(data)
chunk = Chunk.new(@data_directory, data, Time.now, 0)
chunk.buffering
@_write_buffer << chunk
schedule_write
data.bytesize
end

Expand Down
11 changes: 8 additions & 3 deletions lib/droonga/fluent_message_sender.rb
Expand Up @@ -47,13 +47,18 @@ def shutdown
logger.trace("shutdown: done")
end

def send(tag, data)
def send(tag, data, options={})
logger.trace("send: start")
fluent_message = [tag, Time.now.to_i, data]
packed_fluent_message = MessagePackPacker.pack(fluent_message)
connect unless connected?
@socket.write(packed_fluent_message)
logger.trace("send: done")
if options[:reserve]
@socket.reserve_write(packed_fluent_message)
logger.trace("send: reserved")
else
@socket.write(packed_fluent_message)
logger.trace("send: done")
end
end

def resume
Expand Down

0 comments on commit 1d909f6

Please sign in to comment.