-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KIP 848 ListGroups API #2245
base: dev_fix_formatting
Are you sure you want to change the base?
KIP 848 ListGroups API #2245
Changes from all commits
8452969
532fca2
ef1cf95
d3996f8
35d67c2
e274123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -583,27 +583,67 @@ static async Task ListConsumerGroupsAsync(string bootstrapServers, string[] comm | |
{ | ||
var timeout = TimeSpan.FromSeconds(30); | ||
var statesList = new List<ConsumerGroupState>(); | ||
try | ||
var groupTypesList = new List<ConsumerGroupType>(); | ||
var isType = false; | ||
var isState = false; | ||
foreach (var commandArg in commandArgs) | ||
{ | ||
if (commandArgs.Length > 0) | ||
if (commandArg == "-states") | ||
{ | ||
timeout = TimeSpan.FromSeconds(Int32.Parse(commandArgs[0])); | ||
if (isState) | ||
{ | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [-states <match_state_1> <match_state_2> ... <match_state_N>] [-types <group_type_1> .. <group_type_M>]"); | ||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
isState = true; | ||
} | ||
if (commandArgs.Length > 1) | ||
else if (commandArg == "-types") | ||
{ | ||
for (int i = 1; i < commandArgs.Length; i++) | ||
if (isType) | ||
{ | ||
statesList.Add(Enum.Parse<ConsumerGroupState>(commandArgs[i])); | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [-states <match_state_1> <match_state_2> ... <match_state_N>] [-types <group_type_1> .. <group_type_M>]"); | ||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
isType = true; | ||
} | ||
else | ||
{ | ||
if (isState) | ||
{ | ||
try | ||
{ | ||
statesList.Add(Enum.Parse<ConsumerGroupState>(commandArg)); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [-states <match_state_1> <match_state_2> ... <match_state_N>] [-types <group_type_1> .. <group_type_M>]"); | ||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
} | ||
else if (isType) | ||
{ | ||
try | ||
{ | ||
groupTypesList.Add(Enum.Parse<ConsumerGroupType>(commandArg)); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [-states <match_state_1> <match_state_2> ... <match_state_N>] [-types <group_type_1> .. <group_type_M>]"); | ||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [-states <match_state_1> <match_state_2> ... <match_state_N>] [-types <group_type_1> .. <group_type_M>]"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of the usage in codebase mentions timeout seconds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the examples convention I am saying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the remove line 602(just below this comment), it had |
||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
} | ||
} | ||
catch (SystemException) | ||
{ | ||
Console.WriteLine("usage: .. <bootstrapServers> list-consumer-groups [<timeout_seconds> <match_state_1> <match_state_2> ... <match_state_N>]"); | ||
Environment.ExitCode = 1; | ||
return; | ||
} | ||
|
||
using (var adminClient = new AdminClientBuilder(new AdminClientConfig { BootstrapServers = bootstrapServers }).Build()) | ||
{ | ||
try | ||
|
@@ -612,7 +652,9 @@ static async Task ListConsumerGroupsAsync(string bootstrapServers, string[] comm | |
{ | ||
RequestTimeout = timeout, | ||
MatchStates = statesList, | ||
MatchGroupTypes = groupTypesList, | ||
}); | ||
Console.WriteLine("The Broker Response depends on the Broker Version Being used, all the Request Options may not be used for the final request"); | ||
Console.WriteLine(result); | ||
} | ||
catch (KafkaException e) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2024 Confluent Inc. | ||
// | ||
// Licensed 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. | ||
// | ||
// Refer to LICENSE for more information. | ||
|
||
|
||
namespace Confluent.Kafka | ||
{ | ||
/// <summary> | ||
/// Enumerates the different consumer group types. | ||
/// </summary> | ||
public enum ConsumerGroupType : int | ||
{ | ||
/// <summary> | ||
/// Unknown | ||
/// </summary> | ||
Unknown = 0, | ||
|
||
/// <summary> | ||
/// Consumer | ||
/// </summary> | ||
Consumer = 1, | ||
|
||
/// <summary> | ||
/// Classic | ||
/// </summary> | ||
Classic = 2, | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve the error message, state that this was a Duplicate states argument. Same for types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the duplicate state is Invalid args but still the example will run and yield a error like Invalid args.
This is basically error with exit code so user has put in wrong input format for the example.
like -state_cnt=2 state_1 -group_type_cnt=..
The above will error because only 1 state was given.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please suggest something if you feel it is still not sufficient.