Skip to content

Commit

Permalink
feat(tonic): Use NamedService without transport feature (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Feb 15, 2023
1 parent b712df6 commit 5acde56
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions tonic/src/service/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,9 @@ where
}

// required to use `InterceptedService` with `Router`
#[cfg(feature = "transport")]
impl<S, F> crate::transport::NamedService for InterceptedService<S, F>
impl<S, F> crate::server::NamedService for InterceptedService<S, F>
where
S: crate::transport::NamedService,
S: crate::server::NamedService,
{
const NAME: &'static str = S::NAME;
}
Expand Down
6 changes: 4 additions & 2 deletions tonic/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
//! # unimplemented!()
//! # }
//! # }
//! # impl tonic::transport::NamedService for Svc {
//! # impl tonic::server::NamedService for Svc {
//! # const NAME: &'static str = "some_svc";
//! # }
//! # let my_svc = Svc;
Expand Down Expand Up @@ -99,10 +99,12 @@ mod tls;
pub use self::channel::{Channel, Endpoint};
pub use self::error::Error;
#[doc(inline)]
pub use self::server::{NamedService, Server};
pub use self::server::Server;
#[doc(inline)]
pub use self::service::grpc_timeout::TimeoutExpired;
pub use self::tls::Certificate;
#[doc(inline)]
pub use crate::server::NamedService;
pub use hyper::{Body, Uri};

pub(crate) use self::service::executor::Executor;
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/transport/server/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl TcpIncoming {
/// ```no_run
/// # use tower_service::Service;
/// # use http::{request::Request, response::Response};
/// # use tonic::{body::BoxBody, transport::{Body, NamedService, Server, server::TcpIncoming}};
/// # use tonic::{body::BoxBody, server::NamedService, transport::{Body, Server, server::TcpIncoming}};
/// # use core::convert::Infallible;
/// # use std::error::Error;
/// # fn main() { } // Cannot have type parameters, hence instead define:
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/transport/service/router.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
body::{boxed, BoxBody},
transport::NamedService,
server::NamedService,
};
use http::{Request, Response};
use hyper::Body;
Expand Down

0 comments on commit 5acde56

Please sign in to comment.