C0urante commented on code in PR #12544:
URL: https://github.com/apache/kafka/pull/12544#discussion_r1008043521


##########
connect/runtime/src/main/java/org/apache/kafka/connect/util/ConnectUtils.java:
##########
@@ -171,4 +175,28 @@ public static ConnectException maybeWrap(Throwable t, 
String message) {
         return new ConnectException(message, t);
     }
 
+    /**
+     * Create the base of a {@link CommonClientConfigs#CLIENT_ID_DOC client 
ID} that can be
+     * used for Kafka clients instantiated by this worker. Workers should 
append an extra identifier
+     * to the end of this base ID to include extra information on what they 
are using it for; for example,
+     * {@code clientIdBase(config, advertisedUrl) + "configs"} could be used 
as the client ID for a
+     * consumer, producer, or admin client used to interact with a worker's 
config topic.
+     * @param config the worker config; may not be null
+     * @param advertisedUrl the advertised URL for the worker; may not be null
+     * @return the base client ID for this worker; never null, never empty, 
and will always end in a
+     * hyphen ('-')
+     */
+    public static String clientIdBase(WorkerConfig config, String 
advertisedUrl) {
+        String clusterId = Optional.ofNullable(config.groupId())
+                .orElse("connect");

Review Comment:
   We don't need coverage for this case yet since all code paths that lead to 
this method pass in a `DistributedConfig`, which is guaranteed to have a 
non-null `groupId`, but it cost little to account for it anyways so I figured 
we might as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to