Struct ClientBuilder

Source
pub struct ClientBuilder { /* private fields */ }
Expand description

A builder for Storage.

let builder = Storage::builder();
let client = builder
    .with_endpoint("https://storage.googleapis.com")
    .build()
    .await?;

Implementations§

Source§

impl ClientBuilder

Source

pub async fn build(self) -> Result<Storage>

Creates a new client.

§Example
let client = Storage::builder().build().await?;
Source

pub fn with_endpoint<V: Into<String>>(self, v: V) -> Self

Sets the endpoint.

§Example
let client = Storage::builder()
    .with_endpoint("https://private.googleapis.com")
    .build()
    .await?;
Source

pub fn with_credentials<V: Into<Credentials>>(self, v: V) -> Self

Configures the authentication credentials.

Google Cloud Storage requires authentication for most buckets. Use this method to change the credentials used by the client. More information about valid credentials types can be found in the google-cloud-auth crate documentation.

§Example
use auth::credentials::mds;
let client = Storage::builder()
    .with_credentials(
        mds::Builder::default()
            .with_scopes(["https://www.googleapis.com/auth/cloud-platform.read-only"])
            .build()?)
    .build()
    .await?;
Source

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.

§Example
use gax::retry_policy::{AlwaysRetry, RetryPolicyExt};
let client = Storage::builder()
    .with_retry_policy(AlwaysRetry.with_attempt_limit(3))
    .build()
    .await?;
Source

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.

§Example
use gax::exponential_backoff::ExponentialBackoff;
use std::time::Duration;
let policy = ExponentialBackoff::default();
let client = Storage::builder()
    .with_backoff_policy(policy)
    .build()
    .await?;
Source

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 throtler.

§Example
use gax::retry_throttler::AdaptiveThrottler;
let client = Storage::builder()
    .with_retry_throttler(AdaptiveThrottler::default())
    .build()
    .await?;
Source

pub fn with_resumable_upload_threshold<V: Into<usize>>(self, v: V) -> Self

Sets the payload size threshold to switch from single-shot to resumable uploads.

§Example
let client = Storage::builder()
    .with_resumable_upload_threshold(0_usize) // Forces a resumable upload.
    .build()
    .await?;
let response = client
    .upload_object("projects/_/buckets/my-bucket", "my-object", "hello world")
    .send()
    .await?;
println!("response details={response:?}");

The client library can perform uploads using single-shot or resumable uploads. For small objects, single-shot uploads offer better performance, as they require a single HTTP transfer. For larger objects, the additional request latency is not significant, and resumable uploads offer better recovery on errors.

The library automatically selects resumable uploads when the payload is equal to or larger than this option. For smaller uploads the client library uses single-shot uploads.

The exact threshold depends on where the application is deployed and destination bucket location with respect to where the application is running. The library defaults should work well in most cases, but some applications may benefit from fine-tuning.

Source

pub fn with_resumable_upload_buffer_size<V: Into<usize>>(self, v: V) -> Self

Changes the buffer size for some resumable uploads.

§Example
let client = Storage::builder()
    .with_resumable_upload_buffer_size(32 * 1024 * 1024_usize)
    .build()
    .await?;
let response = client
    .upload_object("projects/_/buckets/my-bucket", "my-object", "hello world")
    .send()
    .await?;
println!("response details={response:?}");

When performing resumable uploads from sources without Seek the client library needs to buffer data in memory until it is persisted by the service. Otherwise the data would be lost if the upload fails. Applications may want to tune this buffer size:

  • Use smaller buffer sizes to support more concurrent uploads in the same application.
  • Use larger buffer sizes for better throughput. Sending many small buffers stalls the upload until the client receives a successful response from the service.

Keep in mind that there are diminishing returns on using larger buffers.

Source

pub fn with_download_resume_policy<V>(self, v: V) -> Self
where V: DownloadResumePolicy + 'static,

Configure the resume policy for downloads.

The Cloud Storage client library can automatically resume a download that is interrupted by a transient error. Applications may want to limit the number of download attempts, or may wish to expand the type of errors treated as retryable.

§Example
use google_cloud_storage::download_resume_policy::{AlwaysResume, DownloadResumePolicyExt};
let client = Storage::builder()
    .with_download_resume_policy(AlwaysResume.with_attempt_limit(3))
    .build()
    .await?;

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,