Class: Kafka::PendingMessageQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/kafka/pending_message_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePendingMessageQueue

Returns a new instance of PendingMessageQueue.


6
7
8
# File 'lib/kafka/pending_message_queue.rb', line 6

def initialize
  clear
end

Instance Attribute Details

#bytesizeObject (readonly)

Returns the value of attribute bytesize


4
5
6
# File 'lib/kafka/pending_message_queue.rb', line 4

def bytesize
  @bytesize
end

#sizeObject (readonly)

Returns the value of attribute size


4
5
6
# File 'lib/kafka/pending_message_queue.rb', line 4

def size
  @size
end

Instance Method Details

#clearObject


20
21
22
23
24
# File 'lib/kafka/pending_message_queue.rb', line 20

def clear
  @messages = []
  @size = 0
  @bytesize = 0
end

#each {|message| ... } ⇒ nil

Yields each message in the queue.

Yield Parameters:

Returns:

  • (nil)

35
36
37
# File 'lib/kafka/pending_message_queue.rb', line 35

def each(&block)
  @messages.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/kafka/pending_message_queue.rb', line 16

def empty?
  @messages.empty?
end

#replace(messages) ⇒ Object


26
27
28
29
# File 'lib/kafka/pending_message_queue.rb', line 26

def replace(messages)
  clear
  messages.each {|message| write(message) }
end

#write(message) ⇒ Object


10
11
12
13
14
# File 'lib/kafka/pending_message_queue.rb', line 10

def write(message)
  @messages << message
  @size += 1
  @bytesize += message.bytesize
end