Skip to content

How to: share underlying HTTP clients #2121

Answered by jdisanti
skeet70 asked this question in Q&A
Discussion options

You must be logged in to vote

There's no built-in support for sharing connectors currently, but it is possible to do it manually.

To share the connector between clients, you would need to use the connector() function on the Builder, and give it some kind of shared connector implementation. The built-in DynConnector calls the Clone implementation of whatever is inside of it.

A connector needs to implement the SmithyConnector trait, which is automatically implemented for anything that respects these bounds.

I think you'll have to do something like this:

#[derive(Clone)]
struct SharedConnector<I> {
    inner: /* some shareable type here, such as Arc<Mutex<I>> */
}

impl<I> SharedConnector<I> {
   fn new(inner: I) -> Self { 

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@skeet70
Comment options

@Velfi
Comment options

@skeet70
Comment options

@Velfi
Comment options

@skeet70
Comment options

Answer selected by Velfi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants