Class: Firehose::Server::MessageBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/firehose/server/message_buffer.rb

Overview

Encapsulates a sequence of messages from the server along with their consumer_sequences calculate by offset.

Defined Under Namespace

Classes: Message

Constant Summary collapse

DEFAULT_SIZE =

Number of messages that Redis buffers for the client if its connection drops, then reconnects.

100

Instance Method Summary collapse

Constructor Details

#initialize(message_list, channel_sequence, consumer_sequence = nil) ⇒ MessageBuffer

Returns a new instance of MessageBuffer.



12
13
14
15
16
# File 'lib/firehose/server/message_buffer.rb', line 12

def initialize(message_list, channel_sequence, consumer_sequence = nil)
  @message_list = message_list
  @channel_sequence = channel_sequence.to_i
  @consumer_sequence = consumer_sequence.to_i
end

Instance Method Details

#remaining_messagesObject



18
19
20
# File 'lib/firehose/server/message_buffer.rb', line 18

def remaining_messages
  messages.last(remaining_message_count)
end