Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current state: Under discussion

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

The Kafka RPC message format has no inherent support for handling Double values, however some interfaces may benefit from their addition. The particular motivating case is in implementing a quotas admin client API (KIP-546), which natively accepts Double values, but there's no direct way to define them in the RPC messages. Instead of attempting to work around this limitation, it'd be useful to extent the RPC format to support Double values.

Public Interfaces

Adds double as a possible RPC protocol field type.

This has no immediate impact to any existing public interfaces. It'll permit new and existing messages to add double fields to their structure in subsequent iterations.

Proposed Changes

Adds the following code block to clients/src/main/java/org/apache/kafka/common/protocol/types/Type.java and support code to Struct.java.

...

Code Block
titlegenerator/src/main/java/org/apache/kafka/message/MessageGenerator.java
Hash code: Double.hashCode(value)

Empty value: (double) 0

Parsing a default value string: Double.parseDouble(defaultValue)

Compatibility, Deprecation, and Migration Plan

  • No deprecation or migration necessary.
  • Compatibility
    • Let's say existing message DescribeConfigsRequest added a double field.
      • If the client is old but server is new, then it won't attempt to set the double field, so it won't be serialized in the request.
      • If the client is new but server is old, then the server won't understand the request due to a version mismatch (this setup is generally not advised).
    • If a new request with a double field is added, both client and server must be aware of the message, and therefore will be aware of the double message type.

Rejected Alternatives

  • Requiring the application to serialize into an existing RPC type (int64). This is prone to error and introduces additional complexity in areas where the application shouldn't have to worry about it.