apache_dubbo/triple/transport/connector/
mod.rs1pub mod http_connector;
19
20use hyper::Uri;
21use tower::make::MakeConnection;
22use tower_service::Service;
23
24use super::io::BoxIO;
25
26pub struct Connector<C> {
27 inner: C,
28}
29
30impl<C> Connector<C> {
31 pub fn new(inner: C) -> Connector<C> {
32 Self { inner }
33 }
34}
35
36impl<C> Service<Uri> for Connector<C>
37where
38 C: MakeConnection<Uri>,
39 C::Connection: Unpin + Send + 'static,
40 C::Future: Send + 'static,
41 crate::Error: From<C::Error> + Send + 'static,
42{
43 type Response = BoxIO;
44
45 type Error = crate::Error;
46
47 type Future = crate::BoxFuture<Self::Response, Self::Error>;
48
49 fn poll_ready(
50 &mut self,
51 cx: &mut std::task::Context<'_>,
52 ) -> std::task::Poll<Result<(), Self::Error>> {
53 MakeConnection::poll_ready(&mut self.inner, cx).map_err(Into::into)
54 }
55
56 fn call(&mut self, uri: Uri) -> Self::Future {
57 let conn = self.inner.make_connection(uri);
58
59 Box::pin(async move {
60 let io = conn.await?;
61 Ok(BoxIO::new(io))
62 })
63 }
64}