Sha256: 99a006a518b267ca2ff75c8c55af420033f5b69ad28a2099f7ea15006de89fda

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Rdkafka
  class Consumer
    # Information about a partition, used in {TopicPartitionList}.
    class Partition
      # Partition number
      # @return [Integer]
      attr_reader :partition

      # Partition's offset
      # @return [Integer, nil]
      attr_reader :offset

      # @private
      def initialize(partition, offset)
        @partition = partition
        @offset = offset
      end

      # Human readable representation of this partition.
      # @return [String]
      def to_s
        if offset.nil?
          "<Partition #{partition} without offset>"
        else
          "<Partition #{partition} with offset #{offset}>"
        end
      end

      # Human readable representation of this partition.
      # @return [String]
      def inspect
        to_s
      end

      # Whether another partition is equal to this
      # @return [Boolean]
      def ==(other)
        self.class == other.class &&
          self.partition == other.partition &&
          self.offset == other.offset
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rdkafka-0.4.2 lib/rdkafka/consumer/partition.rb
rdkafka-0.4.1 lib/rdkafka/consumer/partition.rb
rdkafka-0.4.0 lib/rdkafka/consumer/partition.rb