Sha256: 5d035894d99b60bca7a49ff0a611a348b34d2707668c8607612f17f3b7d33800

Contents?: true

Size: 627 Bytes

Versions: 51

Compression:

Stored size: 627 Bytes

Contents

module Kafka

  class PendingMessageQueue
    attr_reader :size, :bytesize

    def initialize
      clear
    end

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

    def empty?
      @messages.empty?
    end

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

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

    # Yields each message in the queue.
    #
    # @yieldparam [PendingMessage] message
    # @return [nil]
    def each(&block)
      @messages.each(&block)
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
ruby-kafka-0.6.0.beta4 lib/kafka/pending_message_queue.rb
ruby-kafka-0.6.0.beta3 lib/kafka/pending_message_queue.rb
ruby-kafka-0.6.0.beta2 lib/kafka/pending_message_queue.rb
ruby-kafka-0.6.0.beta1 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.5 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.4 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.4.beta1 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.3 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.2 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.2.beta3 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.2.beta2 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.2.beta1 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.1 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.1.beta2 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.1.beta1 lib/kafka/pending_message_queue.rb
ruby-kafka-0.4.4 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.0 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.0.beta6 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.0.beta5 lib/kafka/pending_message_queue.rb
ruby-kafka-0.5.0.beta4 lib/kafka/pending_message_queue.rb