-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][pip] PIP-303: Add optional parameters for getPartitionedStats #21228
Conversation
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.
More overloads will be added in this way. I'm wondering if we can just pass a XXXOption
to replace so many parameters?
Good advice, I'll use @Data
@Builder
public class GetPartitionedStatsOptions {
/**
* Set to true to get precise backlog, Otherwise get imprecise backlog.
*/
private final boolean getPreciseBacklog;
/**
* Whether to get backlog size for each subscription.
*/
private final boolean subscriptionBacklogSize;
/**
* Whether to get the earliest time in backlog.
*/
private final boolean getEarliestTimeInBacklog;
}
CompletableFuture<PartitionedTopicStats> getPartitionedStatsAsync(
String topic, boolean perPartition, boolean getPreciseBacklog, boolean subscriptionBacklogSize,
boolean getEarliestTimeInBacklog, GetPartitionedStatsOptions getPartitionedStatsOptions); Any other suggestions? |
I think we can package all parameters other than default PartitionedTopicStats getPartitionedStats(String topic, boolean perPartition) throws PulsarAdminException {
return getPartitionedStats(topic, perPartition, false, false, false);
} |
Great, I'll create a class @Data
@Builder
public class GetPartitionedStatsOptions {
/**
* Set to true to get precise backlog, Otherwise get imprecise backlog.
*/
private final boolean getPreciseBacklog;
/**
* Whether to get backlog size for each subscription.
*/
private final boolean subscriptionBacklogSize;
/**
* Whether to get the earliest time in backlog.
*/
private final boolean getEarliestTimeInBacklog;
/**
* Whether to exclusive publishers.
*/
private final boolean exclusivePublishers;
/**
* Whether to exclusive subscriptions.
*/
private final boolean exclusiveSubscriptions;
} Refer to this API: pulsar/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/GetStatsOptions.java Lines 26 to 41 in 82237d3
pulsar/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Topics.java Lines 1136 to 1144 in c9fba5f
If there are no other issues, I'll update the PIP docuement. |
The pr had no activity for 30 days, mark with Stale label. |
@BewareMyPower I have updated the PIP, please take a look. |
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.
Overall LGTM.
I just think the name would better be "excludeXxxx" rather than "exclusiveXxx" because the logic is excluding the publishers or consumers from the stats, not including "exclusive" publishers or consumers.
This was my clerical error, done. |
pip/pip-303.md
Outdated
TopicStatsImpl getStats(boolean getPreciseBacklog, boolean subscriptionBacklogSize, | ||
boolean getEarliestTimeInBacklog, boolean excludePublishers, boolean excludeConsumers); | ||
|
||
CompletableFuture<? extends TopicStatsImpl> asyncGetStats(boolean getPreciseBacklog, |
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.
IMO, we only need to add an async method to avoid blocking the thread.
For the method arguments, we can also use the above design that moving these arguments to a class.
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.
Good suggestion, done.
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.
I left a suggestion, can you confirm?
LGTM
Releted issue: #21200
Documentation
doc
doc-required
doc-not-needed
doc-complete