From 95576f24c99b34d033f70ce85f6f73c09d0e03f3 Mon Sep 17 00:00:00 2001 From: Lucio Franco Date: Mon, 23 Sep 2019 17:09:20 -0400 Subject: [PATCH] Add more docs --- tonic/src/transport/channel.rs | 7 +++++++ tonic/src/transport/mod.rs | 5 +++-- tonic/src/transport/server.rs | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tonic/src/transport/channel.rs b/tonic/src/transport/channel.rs index 4563038..df26e61 100644 --- a/tonic/src/transport/channel.rs +++ b/tonic/src/transport/channel.rs @@ -28,12 +28,17 @@ type Inner = Box< + 'static, >; +/// A default batteries included `transport` channel. +/// +/// This provides a fully featured http2 gRPC client based on [`hyper::Client`] +/// and `tower` services. #[derive(Clone)] pub struct Channel { svc: Buffer>, } impl Channel { + /// Create a [`Builder`] that can create a [`Channel`]. pub fn builder() -> Builder { Builder::new() } @@ -77,6 +82,8 @@ impl Builder { } } + /// Set the buffer size for when the inner client applies back pressure and + /// can no longer accept requests. Defaults to `1024`. pub fn buffer(&mut self, size: usize) -> &mut Self { self.buffer_size = size; self diff --git a/tonic/src/transport/mod.rs b/tonic/src/transport/mod.rs index fa367d7..35cff24 100644 --- a/tonic/src/transport/mod.rs +++ b/tonic/src/transport/mod.rs @@ -2,10 +2,11 @@ //! TODO: write transport docs. -mod channel; +pub mod channel; +pub mod server; + mod endpoint; mod error; -mod server; mod service; mod tls; diff --git a/tonic/src/transport/server.rs b/tonic/src/transport/server.rs index 2daba61..c43bf4c 100644 --- a/tonic/src/transport/server.rs +++ b/tonic/src/transport/server.rs @@ -25,15 +25,27 @@ use tower_service::Service; type BoxService = tower::util::BoxService, Response, crate::Error>; type Interceptor = Arc + Send + Sync + 'static>; +/// A default batteries included `transport` server. +/// +/// This is a wrapper around [`hyper::Server`] and provides an easy builder +/// pattern style [`Builder`]. This builder exposes easy configuration parameters +/// for providing a fully featured http2 based gRPC server. This should provide +/// a very good out of the box http2 server for use with tonic but is also a +/// reference implementation that should be a good starting point for anyone +/// wanting to create a more complex and/or specific implementation. #[derive(Debug)] -pub struct Server {} +pub struct Server { + _p: () +} impl Server { + /// Create a new [`Builder`] that can configure a Server. pub fn builder() -> Builder { Builder::new() } } +/// #[derive(Default)] pub struct Builder { tls: Option<(Vec, Vec)>, @@ -46,6 +58,7 @@ impl Builder { Default::default() } + /// Add a tls cert. pub fn tls(&mut self, pem: Vec, key: Vec) -> &mut Self { self.tls = Some((pem, key)); self