Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dubbo/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub trait Invoker<ReqBody> {

fn get_url(&self) -> Url;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;

fn call(&mut self, req: ReqBody) -> Self::Future;
}

Expand Down
24 changes: 12 additions & 12 deletions dubbo/src/protocol/triple/triple_invoker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,24 @@ use tower_service::Service;

use crate::common::url::Url;
use crate::protocol::Invoker;
use crate::triple::transport::connection::Connection;
use crate::triple::client::builder::{ClientBoxService, ClientBuilder};

#[allow(dead_code)]
#[derive(Clone, Default)]
pub struct TripleInvoker {
url: Url,
conn: Connection,
conn: ClientBoxService,
}

impl TripleInvoker {
pub fn new(url: Url) -> TripleInvoker {
let uri = http::Uri::from_str(&url.to_url()).unwrap();
Self {
url,
conn: Connection::new().with_host(uri),
conn: ClientBuilder::from(uri).connect(),
}
}
}

impl<ReqBody> Invoker<http::Request<ReqBody>> for TripleInvoker
where
ReqBody: http_body::Body + Unpin + Send + 'static,
ReqBody::Error: Into<crate::Error>,
ReqBody::Data: Send + Unpin,
{
impl Invoker<http::Request<hyper::Body>> for TripleInvoker {
type Response = http::Response<crate::BoxBody>;

type Error = crate::Error;
Expand All @@ -56,7 +49,14 @@ where
self.url.clone()
}

fn call(&mut self, req: http::Request<ReqBody>) -> Self::Future {
fn call(&mut self, req: http::Request<hyper::Body>) -> Self::Future {
self.conn.call(req)
}

fn poll_ready(
&mut self,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Result<(), Self::Error>> {
self.conn.poll_ready(cx)
}
}
2 changes: 1 addition & 1 deletion dubbo/src/triple/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl From<Uri> for ClientBuilder {
Self {
uri: u,
timeout: None,
connector: "",
connector: "tcp",
}
}
}