@@ -190,54 +190,63 @@ impl PublisherBuilder {
190190 Ok ( publisher)
191191 }
192192
193- /// Sets the maximum number of messages to be batched together for a single `Publish` call.
194- /// When this number is reached, the batch is sent.
193+ /// Sets the message count threshold for batching.
195194 ///
196- /// Setting this to `1` disables batching by message count.
195+ /// The publisher will send a batch of messages when the number of messages
196+ /// in the batch reaches this threshold.
197197 ///
198198 /// # Example
199+ ///
199200 /// ```
200201 /// # use google_cloud_pubsub::client::Publisher;
201202 /// # async fn sample() -> anyhow::Result<()> {
202203 /// let publisher = Publisher::builder("projects/my-project/topics/my-topic")
203204 /// .set_message_count_threshold(100)
204- /// .build().await?;
205+ /// .build()
206+ /// .await?;
205207 /// # Ok(()) }
206208 /// ```
207209 pub fn set_message_count_threshold ( mut self , threshold : u32 ) -> PublisherBuilder {
208210 self . batching_options = self . batching_options . set_message_count_threshold ( threshold) ;
209211 self
210212 }
211213
212- /// Sets the byte threshold for batching in a single `Publish` call.
213- /// When this many bytes are accumulated, the batch is sent.
214+ /// Sets the byte threshold for batching.
215+ ///
216+ /// The publisher will send a batch of messages when the total size of the
217+ /// messages in the batch reaches this threshold.
214218 ///
215219 /// # Example
220+ ///
216221 /// ```
217222 /// # use google_cloud_pubsub::client::Publisher;
218223 /// # async fn sample() -> anyhow::Result<()> {
219224 /// let publisher = Publisher::builder("projects/my-project/topics/my-topic")
220- /// .set_byte_threshold(100)
221- /// .build().await?;
225+ /// .set_byte_threshold(1024) // 1 KiB
226+ /// .build()
227+ /// .await?;
222228 /// # Ok(()) }
223229 /// ```
224230 pub fn set_byte_threshold ( mut self , threshold : u32 ) -> PublisherBuilder {
225231 self . batching_options = self . batching_options . set_byte_threshold ( threshold) ;
226232 self
227233 }
228234
229- /// Sets the maximum amount of time the publisher will wait before sending a
230- /// batch. When this delay is reached, the current batch is sent, regardless
231- /// of the number of messages or total byte size.
235+ /// Sets the delay threshold for batching.
236+ ///
237+ /// The publisher will wait a maximum of this amount of time before
238+ /// sending a batch of messages.
232239 ///
233240 /// # Example
241+ ///
234242 /// ```
235243 /// # use google_cloud_pubsub::client::Publisher;
236244 /// # use std::time::Duration;
237245 /// # async fn sample() -> anyhow::Result<()> {
238246 /// let publisher = Publisher::builder("projects/my-project/topics/my-topic")
239247 /// .set_delay_threshold(Duration::from_millis(50))
240- /// .build().await?;
248+ /// .build()
249+ /// .await?;
241250 /// # Ok(()) }
242251 /// ```
243252 pub fn set_delay_threshold ( mut self , threshold : Duration ) -> PublisherBuilder {
@@ -428,17 +437,19 @@ impl PublisherPartialBuilder {
428437 }
429438 }
430439
431- /// Sets the maximum number of messages to be batched together for a single `Publish` call.
432- /// When this number is reached, the batch is sent.
440+ /// Sets the message count threshold for batching.
433441 ///
434- /// Setting this to `1` disables batching by message count.
442+ /// The publisher will send a batch of messages when the number of messages
443+ /// in the batch reaches this threshold.
435444 ///
436445 /// # Example
446+ ///
437447 /// ```
438448 /// # use google_cloud_pubsub::client::BasePublisher;
439449 /// # async fn sample() -> anyhow::Result<()> {
440450 /// # let client = BasePublisher::builder().build().await?;
441- /// let publisher = client.publisher("projects/my-project/topics/my-topic")
451+ /// let publisher = client
452+ /// .publisher("projects/my-project/topics/my-topic")
442453 /// .set_message_count_threshold(100)
443454 /// .build();
444455 /// # Ok(()) }
@@ -448,16 +459,20 @@ impl PublisherPartialBuilder {
448459 self
449460 }
450461
451- /// Sets the byte threshold for batching in a single `Publish` call.
452- /// When this many bytes are accumulated, the batch is sent.
462+ /// Sets the byte threshold for batching.
463+ ///
464+ /// The publisher will send a batch of messages when the total size of the
465+ /// messages in the batch reaches this threshold.
453466 ///
454467 /// # Example
468+ ///
455469 /// ```
456470 /// # use google_cloud_pubsub::client::BasePublisher;
457471 /// # async fn sample() -> anyhow::Result<()> {
458472 /// # let client = BasePublisher::builder().build().await?;
459- /// let publisher = client.publisher("projects/my-project/topics/my-topic")
460- /// .set_byte_threshold(100)
473+ /// let publisher = client
474+ /// .publisher("projects/my-project/topics/my-topic")
475+ /// .set_byte_threshold(1024) // 1 KiB
461476 /// .build();
462477 /// # Ok(()) }
463478 /// ```
@@ -466,17 +481,20 @@ impl PublisherPartialBuilder {
466481 self
467482 }
468483
469- /// Sets the maximum amount of time the publisher will wait before sending a
470- /// batch. When this delay is reached, the current batch is sent, regardless
471- /// of the number of messages or total byte size.
484+ /// Sets the delay threshold for batching.
485+ ///
486+ /// The publisher will wait a maximum of this amount of time before
487+ /// sending a batch of messages.
472488 ///
473489 /// # Example
490+ ///
474491 /// ```
475492 /// # use google_cloud_pubsub::client::BasePublisher;
476493 /// # use std::time::Duration;
477494 /// # async fn sample() -> anyhow::Result<()> {
478495 /// # let client = BasePublisher::builder().build().await?;
479- /// let publisher = client.publisher("projects/my-project/topics/my-topic")
496+ /// let publisher = client
497+ /// .publisher("projects/my-project/topics/my-topic")
480498 /// .set_delay_threshold(Duration::from_millis(50))
481499 /// .build();
482500 /// # Ok(()) }
0 commit comments