Skip to content

Conversation

@suzmue
Copy link
Collaborator

@suzmue suzmue commented Jan 23, 2026

Add a new builder that can configure both the client settings and the batching settings for the Publisher and updated the examples to use the new builder.

The doc comments and examples are copied from the ClientBuilder and the PublisherPartialBuilder. The only client configuration that is not included is the polling configuration since this isn't relevant.

For #4282

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Jan 23, 2026
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 53.84615% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.65%. Comparing base (7b9df66) to head (b2cd951).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/pubsub/src/publisher/publisher.rs 53.84% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4343      +/-   ##
==========================================
- Coverage   94.87%   94.65%   -0.22%     
==========================================
  Files         188      188              
  Lines        7237     7276      +39     
==========================================
+ Hits         6866     6887      +21     
- Misses        371      389      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@suzmue suzmue force-pushed the feat/pubsub-unified-publisher-builder branch from 7efb993 to b2cd951 Compare January 23, 2026 17:43
@suzmue suzmue marked this pull request as ready for review January 23, 2026 18:24
@suzmue suzmue requested a review from a team as a code owner January 23, 2026 18:24
Copy link
Member

@dbolduc dbolduc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the examples to use the right client?

And can you also do a pass on the coverage for some of the new options? #4343 (comment)

The nits around wording are not a blocker for me approving

}

impl Publisher {
/// Creates `Publisher`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// Returns a builder for [Publisher]

Ok(publisher)
}

// Configure the batching options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?


// Configure the batching options.

/// Sets the maximum number of messages to be batched together for a single `Publish` call.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I know this PR is copying existing documentation, but we typically start docs with a short summary sentence like:

/// Set the maximum number of messages in a batch.
///
/// Blah blah blah more details.

https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html#documenting-components

self
}

/// Sets the byte threshold for batching in a single `Publish` call.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same, Set the maximum size for the messages in a batch.

(I am not coming up with these btw, I am copying the C++ docs: https://github.com/googleapis/google-cloud-cpp/blob/9694430272e74ce3dc9702e180b4bc7f7a61b708/google/cloud/pubsub/options.h#L110)

self
}

/// Sets the maximum amount of time the publisher will wait before sending a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same: "The maximum hold time for the messages." ?

Comment on lines +225 to +226
// Configure the client.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

/// # use gax::client_builder::examples;
/// # use gax::client_builder::Result;
/// # tokio_test::block_on(async {
/// use examples::Client; // Placeholder for examples
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use Publisher in the Publisher documentation, not a made up examples::Client.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below.

/// This is the main entry point for the publisher API. A single `BasePublisher`
/// can be used to create multiple `Publisher` clients for different topics.
/// A single `BasePublisher` can be used to create multiple `Publisher`
/// clients for different topics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: reflow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the Pub/Sub API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants