Class: Kafka::PendingMessageQueue
- Inherits:
-
Object
- Object
- Kafka::PendingMessageQueue
- Defined in:
- lib/kafka/pending_message_queue.rb
Instance Attribute Summary collapse
-
#bytesize ⇒ Object
readonly
Returns the value of attribute bytesize.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #clear ⇒ Object
-
#each {|message| ... } ⇒ nil
Yields each message in the queue.
- #empty? ⇒ Boolean
-
#initialize ⇒ PendingMessageQueue
constructor
A new instance of PendingMessageQueue.
- #replace(messages) ⇒ Object
- #write(message) ⇒ Object
Constructor Details
#initialize ⇒ PendingMessageQueue
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
#bytesize ⇒ Object (readonly)
Returns the value of attribute bytesize.
6 7 8 |
# File 'lib/kafka/pending_message_queue.rb', line 6 def bytesize @bytesize end |
#size ⇒ Object (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
#clear ⇒ Object
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.
37 38 39 |
# File 'lib/kafka/pending_message_queue.rb', line 37 def each(&block) @messages.each(&block) end |
#empty? ⇒ 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() clear .each {|| write() } end |
#write(message) ⇒ Object
12 13 14 15 16 |
# File 'lib/kafka/pending_message_queue.rb', line 12 def write() @messages << @size += 1 @bytesize += .bytesize end |