chia7712 commented on code in PR #17626: URL: https://github.com/apache/kafka/pull/17626#discussion_r1828199595
########## clients/src/main/java/org/apache/kafka/clients/admin/ListGroupsOptions.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kafka.clients.admin; + +import org.apache.kafka.common.GroupType; +import org.apache.kafka.common.annotation.InterfaceStability; + +import java.util.Collections; +import java.util.Set; + +/** + * Options for {@link Admin#listGroups()}. + * <p> + * The API of this class is evolving, see {@link Admin} for details. + */ [email protected] +public class ListGroupsOptions extends AbstractOptions<ListGroupsOptions> { + + private Set<GroupType> types = Collections.emptySet(); + + /** + * If types is set, only groups of these types will be returned by listGroups(). + * Otherwise, all groups are returned. + */ + public ListGroupsOptions withTypes(Set<GroupType> types) { Review Comment: > I prefer enums, but I am not 100% convinced with how this works at the moment. We have separate enums for the different group states, but I wonder whether we'd just be better off with a single GroupState enum that is the union of all of the existing groups. In practice, ConsumerGroupState contains all of the states of the other groups already. I planned to use `state` as an example to respond to @dajac's argument. :smile: > This unlocks another possibility which is ListGroupsOptions.withStates which I consider worth having. If the enum can cover all possible (including future) values, it would be ideal to use an enum in the query. As @dajac mentioned, an enum is preferable to a string in this case. > Work out what to do with values beyond the current enum so that an admin client has a chance to cope with new states or group types This wouldn't be an issue if we accept that users need to update their clients to use new features. Alternatively, we could keep using enums as query filters since users can omit the filters to query 'new' groups with an 'old' client. The real issue is that users will only see 'unknown' in the response, even if the RPC response carries the correct value. A workaround is to add a method to ListGroupsResult to return the 'raw value' for those "unknown" field. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
