Skip to content

Commit d0e21c1

Browse files
authored
Rft: Update Invoker Trait (apache#97)
* refactor(dubbo): update invoker trait
1 parent 253c2f1 commit d0e21c1

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

dubbo/src/protocol/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ pub trait Invoker<ReqBody> {
4848

4949
fn get_url(&self) -> Url;
5050

51+
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
52+
5153
fn call(&mut self, req: ReqBody) -> Self::Future;
5254
}
5355

dubbo/src/protocol/triple/triple_invoker.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,24 @@ use tower_service::Service;
2121

2222
use crate::common::url::Url;
2323
use crate::protocol::Invoker;
24-
use crate::triple::transport::connection::Connection;
24+
use crate::triple::client::builder::{ClientBoxService, ClientBuilder};
2525

26-
#[allow(dead_code)]
27-
#[derive(Clone, Default)]
2826
pub struct TripleInvoker {
2927
url: Url,
30-
conn: Connection,
28+
conn: ClientBoxService,
3129
}
3230

3331
impl TripleInvoker {
3432
pub fn new(url: Url) -> TripleInvoker {
3533
let uri = http::Uri::from_str(&url.to_url()).unwrap();
3634
Self {
3735
url,
38-
conn: Connection::new().with_host(uri),
36+
conn: ClientBuilder::from(uri).connect(),
3937
}
4038
}
4139
}
4240

43-
impl<ReqBody> Invoker<http::Request<ReqBody>> for TripleInvoker
44-
where
45-
ReqBody: http_body::Body + Unpin + Send + 'static,
46-
ReqBody::Error: Into<crate::Error>,
47-
ReqBody::Data: Send + Unpin,
48-
{
41+
impl Invoker<http::Request<hyper::Body>> for TripleInvoker {
4942
type Response = http::Response<crate::BoxBody>;
5043

5144
type Error = crate::Error;
@@ -56,7 +49,14 @@ where
5649
self.url.clone()
5750
}
5851

59-
fn call(&mut self, req: http::Request<ReqBody>) -> Self::Future {
52+
fn call(&mut self, req: http::Request<hyper::Body>) -> Self::Future {
6053
self.conn.call(req)
6154
}
55+
56+
fn poll_ready(
57+
&mut self,
58+
cx: &mut std::task::Context<'_>,
59+
) -> std::task::Poll<Result<(), Self::Error>> {
60+
self.conn.poll_ready(cx)
61+
}
6262
}

dubbo/src/triple/client/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl From<Uri> for ClientBuilder {
8888
Self {
8989
uri: u,
9090
timeout: None,
91-
connector: "",
91+
connector: "tcp",
9292
}
9393
}
9494
}

0 commit comments

Comments
 (0)