Repository navigation
Description
Motivation
In the CommandConnect of the Pulsar API protocol, there is a client_version field, which is configured by the client with a string that describes the client SDK. This description can be queried via the pulsar-admin topics stats command.
| required string client_version = 1; |
However, this field is hard-coded (though generated according to the version) in each client AFAIK. It could bring an issue that if client SDK B depends on client SDK A directly, the client_version field is still the description of SDK A.
Currently the issue exists in the Python and the Node.js clients, which are both based on the C++ client. It means that when an application written in the Python or Node.js Pulsar SDK connects to Pulsar, the stats show that they are C++ client.
Further more, the Java client can also be called by other languages directly, including JVM languages like Scala, and script languages like JRuby. Here is an example that a Scala Pulsar client uses the official Java client as the dependency:
However, the PulsarVersion class is generated automatically and the version is fixed. It would be meaningful to differ the wrapper and the base library.
Goal
Make the client version string configurable for each PulsarClientImpl instance. Then the library that depends on the pulsar-client dependency can wrap the PulsarClientImpl with its own client version.
API Changes
Add the following method to ClientBuilderImpl:
/**
* Set the description.
*
* <p> By default, when the client connects to the broker, a version string like "Pulsar-Java-v<x.y.z>" will be
* carried and saved by the broker. The client version string could be queried from the topic stats.
*
* <p> This method provides a way to add more description to a specific PulsarClient instance. If it's configured,
* the description will be appended to the original client version string, with '-' as the separator.
*
* <p>For example, if the client version is 3.0.0, and the description is "forked", the final client version string
* will be "Pulsar-Java-v3.0.0-forked".
*
* @param description the description of the current PulsarClient instance
* @throws IllegalArgumentException if the length of description exceeds 64
*/
public ClientBuilder description(String description) { /* ... */ }Then the library provider should cast the ClientBuilder to ClientBuilderImpl before setting other fields:
var client = ((ClientBuilderImpl) PulsarClient.builder()).description("xxx").serviceUrl(url).build();Implementation
The implementation could be trivial. In ClientCnx#newConnectCommand, append the non-blank description to the version string.
Alternatives
Configure the client version with a static method
there may be multiple usages of the Java client in the same JVM, and you
want each client to report correctly its versionwe would need to use the Java security Manager in order to prevent
malicious code to modify the version or some other mechanism to prevent
overriding the version.
Configure the client version for each PulsarClient
This way could override the original client version string. For example, if a client uses official the Pulsar Client 3.0.0 that might have a bug as the dependency, we might not know the original client version if it's overriden.
Configure the description string for PulsarClient
We cannot prevent a custom library from serializing
whatever they would like in the field, but making this field easily
available to application code could be confusing and might decrease
the value of the version information.
Generally users should not set this description, the client version string is used to identify a specific implementation of the Pulsar API. If there is a strong demand to configure the description for the API layer (PulsarClient), we can open a new PIP later.
Anything else?
No response
Activity
[-]PIP-254: Support configuring client version at client level[/-][+]PIP-254: Support configuring client version at SDK level[/+][-]PIP-254: Support configuring client version at SDK level[/-][+]PIP-254: Support configuring client version[/+]PIP-254: Support configuring client version
PIP-254: Support configuring client version
[-]PIP-254: Support configuring client version[/-][+]PIP-254: Support configuring client version with a description suffix[/+]PIP-254: Support configuring client version
PIP-254: Support configuring client version
PIP-254: Support configuring client version
PIP-254: Support configuring client version
github-actions commentedon Apr 14, 2023
The issue had no activity for 30 days, mark with Stale label.
PIP-254: Support configuring client version with a description suffix
PIP-254: Support configuring client version with a description suffix (…
tisonkun commentedon Jun 12, 2023
I think this is supported with the linked PRs. It may not be a requirement for all clients. Closing...