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
permalink #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
permalink #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 |
permalink #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
permalink #clear ⇒ Object
[View source]
22 23 24 25 26 |
# File 'lib/kafka/pending_message_queue.rb', line 22 def clear @messages = [] @size = 0 @bytesize = 0 end |
permalink #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 |
permalink #empty? ⇒ Boolean
18 19 20 |
# File 'lib/kafka/pending_message_queue.rb', line 18 def empty? @messages.empty? end |
permalink #replace(messages) ⇒ Object
[View source]
28 29 30 31 |
# File 'lib/kafka/pending_message_queue.rb', line 28 def replace() clear .each {|| write() } end |
permalink #write(message) ⇒ Object
[View source]
12 13 14 15 16 |
# File 'lib/kafka/pending_message_queue.rb', line 12 def write() @messages << @size += 1 @bytesize += .bytesize end |