Commit 49acc9be authored by Nugine's avatar Nugine
Browse files

s3s-aws: connector: add client type

parent a1086a47
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ use s3s::S3Result;

use std::ops::Not;

use aws_sdk_s3::config::RuntimeComponents;
use aws_smithy_runtime_api::client::http::{HttpClient, HttpConnectorSettings, SharedHttpConnector};
use aws_smithy_runtime_api::client::http::{HttpConnector, HttpConnectorFuture};
use aws_smithy_runtime_api::client::orchestrator::HttpRequest as AwsHttpRequest;
use aws_smithy_runtime_api::client::orchestrator::HttpResponse as AwsHttpResponse;
@@ -14,6 +16,21 @@ use hyper::header::HOST;
use hyper::http;
use hyper::{Request, Response};

#[derive(Debug)]
pub struct Client(SharedS3Service);

impl HttpClient for Client {
    fn http_connector(&self, _: &HttpConnectorSettings, _: &RuntimeComponents) -> SharedHttpConnector {
        SharedHttpConnector::new(Connector(self.0.clone()))
    }
}

impl From<SharedS3Service> for Client {
    fn from(val: SharedS3Service) -> Self {
        Self(val)
    }
}

#[derive(Debug, Clone)]
pub struct Connector(SharedS3Service);

+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ mod event_stream;
pub mod conv;

mod connector;
pub use self::connector::Connector;
pub use self::connector::{Client, Connector};

mod proxy;
pub use self::proxy::Proxy;
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ uuid = { version = "1.4.1", features = ["v4"] }
anyhow = { version = "1.0.73", features = ["backtrace"] }
aws-config = { version = "1.1.2", default-features = false }
aws-credential-types = { version = "1.1.2", features = ["test-util"] }
aws-sdk-s3 = "1.12.0"
aws-sdk-s3 = { version = "1.12.0", features = ["behavior-version-latest"] }
once_cell = "1.18.0"
s3s-aws = { version = "0.9.0-dev", path = "../s3s-aws" }
tokio = { version = "1.31.0", features = ["full"] }
+3 −3
Original line number Diff line number Diff line
@@ -68,13 +68,13 @@ fn config() -> &'static SdkConfig {
            b.build()
        };

        // Convert to aws http connector
        let conn = s3s_aws::Connector::from(service.into_shared());
        // Convert to aws http client
        let client = s3s_aws::Client::from(service.into_shared());

        // Setup aws sdk config
        SdkConfig::builder()
            .credentials_provider(SharedCredentialsProvider::new(cred))
            .http_connector(conn)
            .http_client(client)
            .region(Region::new(REGION))
            .endpoint_url(format!("http://{DOMAIN_NAME}"))
            .build()