Method: Kafka::Protocol::DescribeConfigsResponse.decode

Defined in:
lib/kafka/protocol/describe_configs_response.rb

.decode(decoder) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/kafka/protocol/describe_configs_response.rb', line 37

def self.decode(decoder)
  throttle_time_ms = decoder.int32
  resources = decoder.array do
    error_code = decoder.int16
    error_message = decoder.string

    resource_type = decoder.int8
    if Kafka::Protocol::RESOURCE_TYPES[resource_type].nil?
      raise Kafka::ProtocolError, "Resource type not supported: #{resource_type}"
    end
    resource_name = decoder.string

    configs = decoder.array do
      ConfigEntry.new(
        name: decoder.string,
        value: decoder.string,
        read_only: decoder.boolean,
        is_default: decoder.boolean,
        is_sensitive: decoder.boolean,
      )
    end

    ResourceDescription.new(
      type: RESOURCE_TYPES[resource_type],
      name: resource_name,
      error_code: error_code,
      error_message: error_message,
      configs: configs
    )
  end

  new(throttle_time_ms: throttle_time_ms, resources: resources)
end