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>
diff --git a/pubsub/topic.go b/pubsub/topic.go
index 32aa0f5..7c3af35 100644
--- a/pubsub/topic.go
+++ b/pubsub/topic.go
@@ -77,6 +77,7 @@
 	ByteThreshold int
 
 	// The number of goroutines that invoke the Publish RPC concurrently.
+	//
 	// Defaults to a multiple of GOMAXPROCS.
 	NumGoroutines int
 
@@ -85,6 +86,8 @@
 
 	// The maximum number of bytes that the Bundler will keep in memory before
 	// returning ErrOverflow.
+	//
+	// Defaults to DefaultPublishSettings.BufferedByteLimit.
 	BufferedByteLimit int
 }
 
@@ -431,7 +434,11 @@
 	}
 	t.bundler.BundleByteThreshold = t.PublishSettings.ByteThreshold
 
-	t.bundler.BufferedByteLimit = t.PublishSettings.BufferedByteLimit
+	bufferedByteLimit := DefaultPublishSettings.BufferedByteLimit
+	if t.PublishSettings.BufferedByteLimit > 0 {
+		bufferedByteLimit = t.PublishSettings.BufferedByteLimit
+	}
+	t.bundler.BufferedByteLimit = bufferedByteLimit
 
 	t.bundler.BundleByteLimit = MaxPublishRequestBytes
 	// Unless overridden, allow many goroutines per CPU to call the Publish RPC concurrently.