pub struct PublisherBuilder { /* private fields */ }Expand description
A builder for a Publisher.
Implementations§
Source§impl PublisherBuilder
impl PublisherBuilder
Sourcepub async fn build(self) -> Result<Publisher>
pub async fn build(self) -> Result<Publisher>
Creates a new Publisher from the builder’s configuration.
Sourcepub fn set_message_count_threshold(self, threshold: u32) -> PublisherBuilder
pub fn set_message_count_threshold(self, threshold: u32) -> PublisherBuilder
Sets the message count threshold for batching.
The publisher will send a batch of messages when the number of messages in the batch reaches this threshold.
§Example
let publisher = Publisher::builder("projects/my-project/topics/my-topic")
.set_message_count_threshold(100)
.build()
.await?;Sourcepub fn set_byte_threshold(self, threshold: u32) -> PublisherBuilder
pub fn set_byte_threshold(self, threshold: u32) -> PublisherBuilder
Sets the byte threshold for batching.
The publisher will send a batch of messages when the total size of the messages in the batch reaches this threshold.
§Example
let publisher = Publisher::builder("projects/my-project/topics/my-topic")
.set_byte_threshold(1024) // 1 KiB
.build()
.await?;Sourcepub fn set_delay_threshold(self, threshold: Duration) -> PublisherBuilder
pub fn set_delay_threshold(self, threshold: Duration) -> PublisherBuilder
Sets the delay threshold for batching.
The publisher will wait a maximum of this amount of time before sending a batch of messages.
§Example
let publisher = Publisher::builder("projects/my-project/topics/my-topic")
.set_delay_threshold(Duration::from_millis(50))
.build()
.await?;Sourcepub fn with_endpoint<V: Into<String>>(self, v: V) -> Self
pub fn with_endpoint<V: Into<String>>(self, v: V) -> Self
Sets the endpoint.
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_endpoint("http://private.googleapis.com")
.build().await?;Sourcepub fn with_tracing(self) -> Self
pub fn with_tracing(self) -> Self
Enables tracing.
The client libraries can be dynamically instrumented with the Tokio tracing framework. Setting this flag enables this instrumentation.
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_tracing()
.build().await?;Sourcepub fn with_credentials<T: Into<Credentials>>(self, v: T) -> Self
pub fn with_credentials<T: Into<Credentials>>(self, v: T) -> Self
Configure the authentication credentials.
Most Google Cloud services require authentication, though some services allow for anonymous access, and some services provide emulators where no authentication is required. More information about valid credentials types can be found in the google-cloud-auth crate documentation.
use google_cloud_auth::credentials::mds;
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_credentials(
mds::Builder::default()
.with_scopes(["https://www.googleapis.com/auth/cloud-platform.read-only"])
.build()?)
.build().await?;Sourcepub fn with_retry_policy<V: Into<RetryPolicyArg>>(self, v: V) -> Self
pub fn with_retry_policy<V: Into<RetryPolicyArg>>(self, v: V) -> Self
Configure the retry policy.
The client libraries can automatically retry operations that fail. The retry policy controls what errors are considered retryable, sets limits on the number of attempts or the time trying to make attempts.
use google_cloud_gax::retry_policy::RetryPolicyExt;
use google_cloud_pubsub::retry_policy::RetryableErrors;
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_retry_policy(RetryableErrors.with_attempt_limit(3))
.build().await?;Sourcepub fn with_backoff_policy<V: Into<BackoffPolicyArg>>(self, v: V) -> Self
pub fn with_backoff_policy<V: Into<BackoffPolicyArg>>(self, v: V) -> Self
Configure the retry backoff policy.
The client libraries can automatically retry operations that fail. The backoff policy controls how long to wait in between retry attempts.
use google_cloud_gax::exponential_backoff::ExponentialBackoff;
use std::time::Duration;
let policy = ExponentialBackoff::default();
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_backoff_policy(policy)
.build()
.await?;Sourcepub fn with_retry_throttler<V: Into<RetryThrottlerArg>>(self, v: V) -> Self
pub fn with_retry_throttler<V: Into<RetryThrottlerArg>>(self, v: V) -> Self
Configure the retry throttler.
Advanced applications may want to configure a retry throttler to Address Cascading Failures and when Handling Overload conditions. The client libraries throttle their retry loop, using a policy to control the throttling algorithm. Use this method to fine tune or customize the default retry throttler.
use google_cloud_gax::retry_throttler::AdaptiveThrottler;
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_retry_throttler(AdaptiveThrottler::default())
.build().await?;Sourcepub fn with_grpc_subchannel_count(self, v: usize) -> Self
pub fn with_grpc_subchannel_count(self, v: usize) -> Self
Configure the number of gRPC subchannels.
§Example
let client = Publisher::builder("projects/my-project/topics/my-topic")
.with_grpc_subchannel_count(4)
.build()
.await?;gRPC-based clients may exhibit high latency if many requests need to be demuxed over a single HTTP/2 connection (often called a subchannel in gRPC).
Consider using more subchannels if your application makes many concurrent requests. Consider using fewer subchannels if your application needs the file descriptors for other purposes.
Trait Implementations§
Source§impl Clone for PublisherBuilder
impl Clone for PublisherBuilder
Source§fn clone(&self) -> PublisherBuilder
fn clone(&self) -> PublisherBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PublisherBuilder
impl !UnwindSafe for PublisherBuilder
impl Freeze for PublisherBuilder
impl Send for PublisherBuilder
impl Sync for PublisherBuilder
impl Unpin for PublisherBuilder
impl UnsafeUnpin for PublisherBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request