Class: Lumberjack::AckingProtocolV2

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(window_size) ⇒ AckingProtocolV2

Returns a new instance of AckingProtocolV2.


416
417
418
419
# File 'lib/lumberjack/server.rb', line 416

def initialize(window_size)
  @window_size = window_size
  @every = (window_size / ACK_RATIO).round
end

Instance Method Details

#ack?(sequence) ⇒ Boolean

Returns:

  • (Boolean)

421
422
423
424
425
426
427
428
429
# File 'lib/lumberjack/server.rb', line 421

def ack?(sequence)
  if @window_size == sequence
    true
  elsif sequence % @every == 0
    true
  else
    false
  end
end

#ack_frame(sequence) ⇒ Object


431
432
433
# File 'lib/lumberjack/server.rb', line 431

def ack_frame(sequence)
  ["2A", sequence].pack("A*N")
end