make: Prepare 0.3 release and update docs (#370)

* make: Prepare 0.3 release and update docs

* rebase against origin/master + get doc tests to compile

* fmt

* fix build
This commit is contained in:
Lucio Franco 2019-11-29 15:44:03 -05:00 committed by GitHub
parent c3c6780d31
commit b6c67182cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 26 deletions

View File

@ -18,6 +18,6 @@ members = [
# "tower-spawn-ready",
# "tower-test",
# "tower-timeout",
# "tower-make",
"tower-make",
# "tower-util",
]

View File

@ -25,6 +25,7 @@ jobs:
# - tower-reconnect
# - tower-retry
- tower-service
- tower-make
# - tower-spawn-ready
# - tower-test
# - tower-timeout

View File

@ -1,3 +1,8 @@
# 0.3.0 (November 29, 2019)
- Update `tokio` to `0.2`.
- Rename `io` feature to `connect`.
# 0.3.0-alpha.2a (September 30, 2019)
- Update `tokio-io` to `alpha.6`

View File

@ -1,12 +1,12 @@
[package]
name = "tower-make"
version = "0.3.0-alpha.2a"
version = "0.3.0"
authors = ["Tower Maintainers <team@tower-rs.com>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/tower-rs/tower"
homepage = "https://github.com/tower-rs/tower"
documentation = "https://docs.rs/tower-make/0.3.0-alpha.2"
documentation = "https://docs.rs/tower-make/0.3.0"
description = """
Trait aliases for Services that produce specific types of Responses.
"""
@ -14,10 +14,8 @@ categories = ["asynchronous", "network-programming"]
edition = "2018"
[features]
io = ["tokio-io"]
connect = ["tokio"]
[dependencies]
# we don't use any of the possibly unstable io bits, so we can be loose
# about the exact alpha version
tokio-io = { version = "0.2.0-alpha.6", optional = true }
tower-service = { version = "=0.3.0-alpha.2", path = "../tower-service" }
tower-service = { version = "0.3", path = "../tower-service" }
tokio = { version = "0.2", optional = true }

View File

@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/tower-make/0.3.0-alpha.2")]
#![doc(html_root_url = "https://docs.rs/tower-make/0.3.0")]
#![warn(
missing_debug_implementations,
missing_docs,
@ -8,11 +8,11 @@
//! Trait aliases for Services that produce specific types of Responses.
#[cfg(feature = "io")]
#[cfg(feature = "connect")]
mod make_connection;
mod make_service;
#[cfg(feature = "io")]
#[cfg(feature = "connect")]
pub use crate::make_connection::MakeConnection;
pub use crate::make_service::MakeService;

View File

@ -1,10 +1,10 @@
use crate::sealed::Sealed;
use std::future::Future;
use std::task::{Context, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service;
/// The MakeConnection trait is used to create transports
/// The MakeConnection trait is used to create transports.
///
/// The goal of this service is to allow composable methods for creating
/// `AsyncRead + AsyncWrite` transports. This could mean creating a TLS
@ -19,7 +19,7 @@ pub trait MakeConnection<Target>: Sealed<(Target,)> {
/// The future that eventually produces the transport
type Future: Future<Output = Result<Self::Connection, Self::Error>>;
/// Returns `Ready` when it is able to make more connections.
/// Returns `Poll::Ready(Ok(()))` when it is able to make more connections.
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
/// Connect and return a transport asynchronously

View File

@ -30,13 +30,9 @@ pub trait MakeService<Target, Request>: Sealed<(Target, Request)> {
/// Returns `Ready` when the factory is able to create more services.
///
/// If the service is at capacity, then `NotReady` is returned and the task
/// If the service is at capacity, then `Poll::Pending` is returned and the task
/// is notified when the service becomes ready again. This function is
/// expected to be called while on a task.
///
/// This is a **best effort** implementation. False positives are permitted.
/// It is permitted for the service to return `Ready` from a `poll_ready`
/// call and for the next invocation of `call` to result in an error.
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::MakeError>>;
/// Create and return a new service value asynchronously.

View File

@ -19,5 +19,9 @@ description = """
Trait representing an asynchronous, request / response based, client or server.
"""
categories = ["asynchronous", "network-programming"]
edition = "2018"
[dependencies]
[dev-dependencies]
http = "0.1"

View File

@ -41,9 +41,18 @@ use std::task::{Context, Poll};
///
/// As an example, here is how an HTTP request is processed by a server:
///
/// ```rust,ignore
/// impl Service<http::Request> for HelloWorld {
/// type Response = http::Response;
/// ```rust
/// # use std::pin::Pin;
/// # use std::task::{Poll, Context};
/// # use std::future::Future;
/// # use tower_service::Service;
///
/// use http::{Request, Response, StatusCode};
///
/// struct HelloWorld;
///
/// impl Service<Request<Vec<u8>>> for HelloWorld {
/// type Response = Response<Vec<u8>>;
/// type Error = http::Error;
/// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
///
@ -51,13 +60,24 @@ use std::task::{Context, Poll};
/// Poll::Ready(Ok(()))
/// }
///
/// fn call(&mut self, req: http::Request) -> Self::Future {
/// fn call(&mut self, req: Request<Vec<u8>>) -> Self::Future {
/// // create the body
/// let body: Vec<u8> = "hello, world!\n"
/// .as_bytes()
/// .to_owned();
/// // Create the HTTP response
/// let resp = http::Response::ok()
/// .with_body(b"hello world\n");
/// let resp = Response::builder()
/// .status(StatusCode::OK)
/// .body(body)
/// .expect("Unable to create `http::Response`");
///
/// // create a response in a future.
/// let fut = async {
/// Ok(resp)
/// };
///
/// // Return the response as an immediate future
/// Box::pin(async move { Ok(resp) })
/// Box::pin(fut)
/// }
/// }
/// ```