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.



8
9
10
# File 'lib/kafka/pending_message_queue.rb', line 8

def initialize
  clear
end

Instance Attribute Details

#bytesizeObject (readonly)

Returns the value of attribute bytesize.



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

def bytesize
  @bytesize
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Instance Method Details

#clearObject



22
23
24
25
26
# File 'lib/kafka/pending_message_queue.rb', line 22

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

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

Yields each message in the queue.

Yield Parameters:

Returns:

  • (nil)


37
38
39
# File 'lib/kafka/pending_message_queue.rb', line 37

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

#empty?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/kafka/pending_message_queue.rb', line 18

def empty?
  @messages.empty?
end

#replace(messages) ⇒ Object



28
29
30
31
# File 'lib/kafka/pending_message_queue.rb', line 28

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

#write(message) ⇒ Object



12
13
14
15
16
# File 'lib/kafka/pending_message_queue.rb', line 12

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