Sha256: 6317a03a04fdb99ea85d7aec785f42de401b82716c1c38f610d3264eae406d32

Contents?: true

Size: 1.13 KB

Versions: 49

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Kafka
  module Protocol

    class ApiVersionsResponse
      class ApiInfo
        attr_reader :api_key, :min_version, :max_version

        def initialize(api_key:, min_version:, max_version:)
          @api_key, @min_version, @max_version = api_key, min_version, max_version
        end

        def api_name
          Protocol.api_name(api_key)
        end

        def version_supported?(version)
          (min_version..max_version).include?(version)
        end

        def to_s
          "#{api_name}=#{min_version}..#{max_version}"
        end

        def inspect
          "#<Kafka api version #{to_s}>"
        end
      end

      attr_reader :error_code, :apis

      def initialize(error_code:, apis:)
        @error_code = error_code
        @apis = apis
      end

      def self.decode(decoder)
        error_code = decoder.int16

        apis = decoder.array do
          ApiInfo.new(
            api_key: decoder.int16,
            min_version: decoder.int16,
            max_version: decoder.int16,
          )
        end

        new(error_code: error_code, apis: apis)
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ruby-kafka-1.5.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-aws-iam-1.4.5 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-aws-iam-1.4.4 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-aws-iam-1.4.3 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-aws-iam-1.4.2 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-aws-iam-1.4.1 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.4.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-temp-fork-0.0.2 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-temp-fork-0.0.1 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.3.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.2.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.1.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.1.0.beta1 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-1.0.0 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-0.7.10 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-0.7.9 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-0.7.8 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-0.7.7 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-custom-0.7.7.26 lib/kafka/protocol/api_versions_response.rb
ruby-kafka-0.7.6 lib/kafka/protocol/api_versions_response.rb