Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Updated BatchingSettings default value to Long.MAX_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulKQL committed Jun 19, 2019
1 parent b4681cc commit 1d16842
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
/**
* Represents the batching settings to use for an API method that is capable of batching.
*
* <p>Each batching client will have to define their own set of default values for these thresholds,
* which would be safest behavior for their jobs.
* <p>Each batching client must define their own set of default values for these thresholds, which
* would be the safest behavior for their jobs.
*
* <p>The default instance of this settings are configured to <b>not</b> use batching (i.e. the
* batch size threshold is 1). This is the safest default behavior, which has meaning in all
* possible scenarios. Users are expected to configure actual batching thresholds explicitly: the
* element count, the request bytes count.
* <p>The default instance of this settings are configured to accept elements until either of the
* threshold reaches {@link Long#MAX_VALUE}) or an explicit call to {@link Batcher#flush()} is made
* or the {@link Batcher#close()} is called. Users are expected to configure actual batching
* thresholds explicitly: the element count or the request bytes count.
*
* <p>Warning: With the incorrect settings, it is possible to cause long periods of dead waiting
* time.
Expand All @@ -57,10 +57,11 @@
*
* <ul>
* <li><b>Message Count Threshold</b>: Once this many messages are queued, send all of the
* messages in a single call. The default value is 1 message.
* messages in a single call, even if the request byte threshold has not been exceed yet. The
* default value is {@link Long#MAX_VALUE} messages.
* <li><b>Request Byte Threshold</b>: Once the number of bytes in the batched request reaches this
* threshold, send all of the messages in a single call, even if message count thresholds has
* not been exceeded yet. The default value is 1 byte.
* threshold, send all of the messages in a single call, even if message count threshold has
* not been exceeded yet. The default value is {@link Long#MAX_VALUE} bytes.
* </ul>
*
* <p>These thresholds are treated as triggers, not as limits. Each threshold is an independent
Expand All @@ -79,8 +80,8 @@ public abstract class BatchingSettings {
/** Get a new builder. */
public static Builder newBuilder() {
return new AutoValue_BatchingSettings.Builder()
.setElementCountThreshold(1L)
.setRequestByteThreshold(1L);
.setElementCountThreshold(Long.MAX_VALUE)
.setRequestByteThreshold(Long.MAX_VALUE);
}

/** Get a builder with the same values as this object. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -70,6 +71,13 @@ public class BatcherImplTest {
.setElementCountThreshold(1000L)
.build();

@After
public void tearDown() throws InterruptedException {
if (underTest != null) {
underTest.close();
}
}

/** The accumulated results in the test are resolved when {@link Batcher#flush()} is called. */
@Test
public void testResultsAreResolvedAfterFlush() throws Exception {
Expand Down

0 comments on commit 1d16842

Please sign in to comment.