Skip to content

Commit aef6eeb

Browse files
committed
pubsub: default BufferedByteLimit
Change-Id: I4db83ae2c3915fdf11b25e0f0a7700fe68a512d3 Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/41692 Reviewed-by: Alex Hong <hongalex@google.com> Reviewed-by: Chris Broadfoot <cbro@google.com> Reviewed-by: kokoro <noreply+kokoro@google.com> Reviewed-by: James Hartig <fastest963@gmail.com>
1 parent f9732bf commit aef6eeb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pubsub/topic.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type PublishSettings struct {
7777
ByteThreshold int
7878

7979
// The number of goroutines that invoke the Publish RPC concurrently.
80+
//
8081
// Defaults to a multiple of GOMAXPROCS.
8182
NumGoroutines int
8283

@@ -85,6 +86,8 @@ type PublishSettings struct {
8586

8687
// The maximum number of bytes that the Bundler will keep in memory before
8788
// returning ErrOverflow.
89+
//
90+
// Defaults to DefaultPublishSettings.BufferedByteLimit.
8891
BufferedByteLimit int
8992
}
9093

@@ -431,7 +434,11 @@ func (t *Topic) initBundler() {
431434
}
432435
t.bundler.BundleByteThreshold = t.PublishSettings.ByteThreshold
433436

434-
t.bundler.BufferedByteLimit = t.PublishSettings.BufferedByteLimit
437+
bufferedByteLimit := DefaultPublishSettings.BufferedByteLimit
438+
if t.PublishSettings.BufferedByteLimit > 0 {
439+
bufferedByteLimit = t.PublishSettings.BufferedByteLimit
440+
}
441+
t.bundler.BufferedByteLimit = bufferedByteLimit
435442

436443
t.bundler.BundleByteLimit = MaxPublishRequestBytes
437444
// Unless overridden, allow many goroutines per CPU to call the Publish RPC concurrently.

0 commit comments

Comments
 (0)