-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
BatchSettings.builder().build() encourages failure by making required arguments optional #2542
Comments
What about giving everything defaults, so that it's ok if you only set one value? |
Proposal:
WDYT? |
I think we should just set defaults in |
Note that there are two defaults at play here. One is BatchingSettings.DEFAULT and another is I think
|
I think the default for BatchingSettings should be the values for no batching (send one at a time). |
I vote against addressing this in documentation only. It's like hanging an
"open" sign on a locked door with a little note at the bottom that says
"JK. We are closed for the day."
On Fri, Oct 27, 2017 at 12:45 AM Garrett Jones ***@***.***> wrote:
I think the default for BatchingSettings should be the values for no
batching (send one at a time).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2542 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARrMFuwzmeXdjz9k-SWXbQNMX_As9VR8ks5swV_UgaJpZM4QA7ZM>
.
--
Kir Titievsky | Product Manager | Google Cloud Pub/Sub
<https://cloud.google.com/pubsub/overview>
|
Current pubsub Publisher settings seem to require an instance of BatchingSettings with multiple values set to non-null values. However, the builder pattern encourages setting a single setting at a time. For example, I wanted to make sure that messages were batched into 100 messages batches. So I did this:
publisher = Publisher.defaultBuilder(topicName).setBatchingSettings( BatchingSettings.newBuilder().setElementCountThreshold(100L).build()).build();
which fails with a NullPointerException .
Turns out I must set all other values of BatchingSettings to set one since the call above produces an object like this:
BatchingSettings{elementCountThreshold=100, requestByteThreshold=null, delayThreshold=null, isEnabled=true, flowControlSettings=FlowControlSettings{maxOutstandingElementCount=null, maxOutstandingRequestBytes=null, limitExceededBehavior=Ignore}}
Which took me a good 20 minutes to figure out.
What I wish we did here was an API that required all required parameters, like so (for example):
BatchingSettings.newBuilder().setThresholds(elementCount, requestByte, delay)
The text was updated successfully, but these errors were encountered: