Class: Lumberjack::AckingProtocolV2
- Inherits:
-
Object
- Object
- Lumberjack::AckingProtocolV2
- Defined in:
- lib/lumberjack/server.rb
Overview
Allow lumberjack to send partial ack back to the producer only V2 client support partial Acks
Send Ack on every 20% of the data, so with default settings every 200 events This should reduce the congestion on retransmit.
Constant Summary collapse
- ACK_RATIO =
5
Instance Method Summary collapse
- #ack?(sequence) ⇒ Boolean
- #ack_frame(sequence) ⇒ Object
-
#initialize(window_size) ⇒ AckingProtocolV2
constructor
A new instance of AckingProtocolV2.
Constructor Details
#initialize(window_size) ⇒ AckingProtocolV2
Returns a new instance of AckingProtocolV2.
414 415 416 417 |
# File 'lib/lumberjack/server.rb', line 414 def initialize(window_size) @window_size = window_size @every = (window_size / ACK_RATIO).round end |
Instance Method Details
#ack?(sequence) ⇒ Boolean
419 420 421 422 423 424 425 426 427 |
# File 'lib/lumberjack/server.rb', line 419 def ack?(sequence) if @window_size == sequence true elsif sequence % @every == 0 true else false end end |
#ack_frame(sequence) ⇒ Object
429 430 431 |
# File 'lib/lumberjack/server.rb', line 429 def ack_frame(sequence) ["2A", sequence].pack("A*N") end |