Skip to content

Commit

Permalink
feat(zonerouter): add client type (#2037)
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Han <[email protected]>
  • Loading branch information
superhx authored Sep 26, 2024
1 parent 691b16b commit 6e761b0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@

public class ClientIdKey {
public static final String AVAILABILITY_ZONE = "automq_az";
public static final String CLIENT_TYPE = "automq_type";
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public String rack() {
return list.get(0);
}

public ClientType clientType() {
List<String> list = metadata.get(ClientIdKey.CLIENT_TYPE);
if (list == null || list.isEmpty()) {
return null;
}
return ClientType.parse(list.get(0));
}

public String clientId() {
return clientId;
}
Expand Down
28 changes: 28 additions & 0 deletions core/src/main/java/kafka/automq/zonerouter/ClientType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2024, AutoMQ HK Limited.
*
* The use of this file is governed by the Business Source License,
* as detailed in the file "/LICENSE.S3Stream" included in this repository.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0
*/

package kafka.automq.zonerouter;

public enum ClientType {
PRODUCER, CONSUMER;

public static ClientType parse(String str) {
switch (str) {
case "producer":
return PRODUCER;
case "consumer":
return CONSUMER;
default:
return null;
}
}

}

0 comments on commit 6e761b0

Please sign in to comment.