Skip to content

Commit

Permalink
Platter support for auto-connection-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudy committed Mar 30, 2024
1 parent 2556b45 commit e257fc9
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 145 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions patron/src/client/builder.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use rustls::ClientConfig;

use crate::{
conn::{http::HttpConnectionBuilder, HttpConnector},
default_tls_config, Client,
};
use crate::{conn::http::HttpConnectionBuilder, default_tls_config, Client};

#[derive(Debug)]
pub struct Builder {
Expand Down Expand Up @@ -44,12 +41,12 @@ impl Builder {
}

impl Builder {
pub fn build(self) -> Client<HttpConnector> {
pub fn build(self) -> Client<HttpConnectionBuilder> {
let tls = self.tls.unwrap_or_else(super::default_tls_config);

Client {
transport: crate::conn::TcpConnector::new(self.tcp, tls),
protocol: HttpConnector::new(HttpConnectionBuilder::default()),
protocol: HttpConnectionBuilder::default(),
pool: self.pool.map(crate::pool::Pool::new),
}
}
Expand Down
10 changes: 5 additions & 5 deletions patron/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::conn::Connection;
use crate::conn::TransportStream;
use crate::pool::Checkout;
use crate::pool::Connector;
use crate::HttpConnectionBuilder;
use futures_util::future::BoxFuture;
use futures_util::FutureExt;
use http::uri::Port;
Expand All @@ -20,7 +21,6 @@ use tracing::warn;
mod builder;

use crate::conn;
use crate::conn::http::HttpConnector;
use crate::conn::tcp::TcpConnector;
use crate::pool::{self, PoolableConnection, Pooled};

Expand All @@ -33,7 +33,7 @@ use crate::Error;

/// An HTTP client
#[derive(Debug)]
pub struct Client<P = HttpConnector, T = TcpConnector>
pub struct Client<P = HttpConnectionBuilder, T = TcpConnector>
where
P: Protocol,
{
Expand Down Expand Up @@ -70,7 +70,7 @@ where
}
}

impl Client<HttpConnector, TcpConnector> {
impl Client<HttpConnectionBuilder, TcpConnector> {
/// A client builder for configuring the client.
pub fn builder() -> builder::Builder {
builder::Builder::default()
Expand All @@ -87,12 +87,12 @@ impl Client<HttpConnector, TcpConnector> {
crate::conn::TcpConnectionConfig::default(),
default_tls_config(),
),
protocol: conn::HttpConnector::new(conn::http::HttpConnectionBuilder::default()),
protocol: conn::http::HttpConnectionBuilder::default(),
}
}
}

impl Default for Client<HttpConnector> {
impl Default for Client<HttpConnectionBuilder> {
fn default() -> Self {
Self::new_tcp_http()
}
Expand Down
Loading

0 comments on commit e257fc9

Please sign in to comment.