Sha256: 8df231d05f858e6e082f17c8ae457b897880d17a12f7ef9c0f92fc1c29a806b6

Contents?: true

Size: 1.39 KB

Versions: 27

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

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

      # Partition's error code
      # @return [Integer]
      attr_reader :err

      # Partition metadata in the context of a consumer
      # @return [String, nil]
      attr_reader :metadata

      # @private
      def initialize(partition, offset, err = 0, metadata = nil)
        @partition = partition
        @offset = offset
        @err = err
        @metadata = metadata
      end

      # Human readable representation of this partition.
      # @return [String]
      def to_s
        message = "<Partition #{partition}"
        message += " offset=#{offset}" if offset
        message += " err=#{err}" if err != 0
        message += " metadata=#{metadata}" if metadata != nil
        message += ">"
        message
      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

27 entries across 27 versions & 1 rubygems

Version Path
karafka-rdkafka-0.17.6 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.5 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.4 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.3 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.2 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.2.rc1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.1.beta1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.17.0 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.14.11 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.2 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.16.1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.16.0 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.16.0.rc1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0.rc2 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0.rc1 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0.beta3 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0.beta2 lib/rdkafka/consumer/partition.rb
karafka-rdkafka-0.15.0.beta1 lib/rdkafka/consumer/partition.rb