Struct aws_sdk_sqs::client::Builder

source ·
pub struct Builder<C = (), M = (), R = Standard> { /* private fields */ }
Expand description

A builder that provides more customization options when constructing a Client.

To start, call Builder::new. Then, chain the method calls to configure the Builder. When configured to your liking, call Builder::build. The individual methods have additional documentation.

Implementations§

Construct a new builder. This does not specify a connector or middleware. It uses the standard retry mechanism.

Connect to the service over HTTPS using the native TLS library on your platform using dynamic dispatch.

Create a Smithy client builder with an HTTPS connector and the standard retry policy over the default middleware implementation.

For convenience, this constructor type-erases the concrete TLS connector backend used using dynamic dispatch. This comes at a slight runtime performance cost. See DynConnector for details. To avoid that overhead, use [Builder::rustls_connector] or Builder::native_tls_connector instead.

Specify the connector for the eventual client to use.

The connector dictates how requests are turned into responses. Normally, this would entail sending the request to some kind of remote server, but in certain settings it’s useful to be able to use a custom connector instead, such as to mock the network for tests.

If you just want to specify a function from request to response instead, use Builder::connector_fn.

Use a function that directly maps each request to a response as a connector.

use aws_smithy_client::Builder;
use aws_smithy_http::body::SdkBody;
let client = Builder::new()
  .middleware(..)
  .connector_fn(|req: http::Request<SdkBody>| {
    async move {
      Ok(http::Response::new(SdkBody::empty()))
    }
  })
  .build();

Specify the middleware for the eventual client ot use.

The middleware adjusts requests before they are dispatched to the connector. It is responsible for filling in any request parameters that aren’t specified by the Smithy protocol definition, such as those used for routing (like the URL), authentication, and authorization.

The middleware takes the form of a tower::Layer that wraps the actual connection for each request. The tower::Service that the middleware produces must accept requests of the type aws_smithy_http::operation::Request and return responses of the type http::Response<SdkBody>, most likely by modifying the provided request in place, passing it to the inner service, and then ultimately returning the inner service’s response.

If your requests are already ready to be sent and need no adjustment, you can use tower::layer::util::Identity as your middleware.

Use a function-like middleware that directly maps each request.

use aws_smithy_client::Builder;
use aws_smithy_client::erase::DynConnector;
use aws_smithy_client::never::NeverConnector;
use aws_smithy_http::body::SdkBody;
let my_connector = DynConnector::new(
    // Your own connector here or use `dyn_https_connector()`
);
let client = Builder::new()
  .connector(my_connector)
  .middleware_fn(|req: aws_smithy_http::operation::Request| {
    req
  })
  .build();

Specify the retry policy for the eventual client to use.

By default, the Smithy client uses a standard retry policy that works well in most settings. You can use this method to override that policy with a custom one. A new policy instance will be instantiated for each request using retry::NewRequestPolicy. Each policy instance must implement tower::retry::Policy.

If you just want to modify the policy configuration for the standard retry policy, use Builder::set_retry_config.

Set the standard retry policy’s configuration. When config is None, the default retry policy will be used.

Set the standard retry policy’s configuration.

Set operation timeout config for the client. If operation_timeout_config is None, timeouts will be disabled.

Set operation timeout config for the client.

Set the AsyncSleep function that the Client will use to create things like timeout futures.

Set the AsyncSleep function that the Client will use to create things like timeout futures.

Use a connector that wraps the current connector.

Use a middleware that wraps the current middleware.

Build a Smithy service Client.

Build a type-erased Smithy service Client.

Note that if you’re using the standard retry mechanism, retry::Standard, DynClient<R> is equivalent to Client with no type arguments.

use aws_smithy_client::{Builder, Client};
struct MyClient {
    client: aws_smithy_client::Client,
}

let client = Builder::new()
    .https()
    .middleware(tower::layer::util::Identity::new())
    .build_dyn();
let client = MyClient { client };

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more