Bug 1785002 - Update tower-service to 0.3.2. r=emilio,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D154756
This commit is contained in:
Mike Hommey 2022-08-16 21:38:25 +00:00
Родитель ae4a75d456
Коммит 89755616b7
6 изменённых файлов: 127 добавлений и 14 удалений

4
Cargo.lock сгенерированный
Просмотреть файл

@ -5423,9 +5423,9 @@ checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"
[[package]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.1" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
[[package]] [[package]]
name = "tracing" name = "tracing"

Просмотреть файл

@ -655,6 +655,11 @@ criteria = "safe-to-deploy"
version = "0.1.0" version = "0.1.0"
notes = "Simple algorithm crate with no unsafe code or capability usage." notes = "Simple algorithm crate with no unsafe code or capability usage."
[[audits.tower-service]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-run"
delta = "0.3.1 -> 0.3.2"
[[audits.tracy-rs]] [[audits.tracy-rs]]
who = "Glenn Watson <git@intuitionlibrary.com>" who = "Glenn Watson <git@intuitionlibrary.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"a202a1d257e8b3def187b371f26a47161afae5804040d7ad43d344809d1d1674","Cargo.toml":"09b0ebd19eac7f2185ac817da8d3877dea0725502d1ad1bbb96ea4fdf2621b42","LICENSE":"4249c8e6c5ebb85f97c77e6457c6fafc1066406eb8f1ef61e796fbdc5ff18482","README.md":"da9cb4815bf06e0991df6bf4e9f46272e26115dcc4e2c8f9ffc05e11d486179e","src/lib.rs":"d24ae2a7f7e075372839fddd13f833268d8e9ff8ffa3ca7aa1bf00e18fb57b80"},"package":"360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"} {"files":{"CHANGELOG.md":"961cd98312a75f437e0dcd51eeb3bb61f0bbe778d5fb9203ab8a287bd9cfc84b","Cargo.toml":"81b3940c5bd437f362f4c52d442e49750263eae37b3188202c475340b7255f36","LICENSE":"4249c8e6c5ebb85f97c77e6457c6fafc1066406eb8f1ef61e796fbdc5ff18482","README.md":"da9cb4815bf06e0991df6bf4e9f46272e26115dcc4e2c8f9ffc05e11d486179e","src/lib.rs":"0acd9a6540ea50c0c60c212ba7ef89a7dd7542e99cc6854db2fdd1d5db63a715"},"package":"b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"}

16
third_party/rust/tower-service/CHANGELOG.md поставляемый
Просмотреть файл

@ -1,5 +1,21 @@
# Unreleased # Unreleased
- None
# 0.3.2 (June 17, 2022)
## Added
- **docs**: Clarify subtlety around cloning and readiness in the `Service` docs
([#548])
- **docs**: Clarify details around shared resource consumption in `poll_ready()`
([#662])
[#548]: https://github.com/tower-rs/tower/pull/548
[#662]: https://github.com/tower-rs/tower/pull/662
# 0.3.1 (November 29, 2019) # 0.3.1 (November 29, 2019)
- Improve example in `Service` docs. ([#510]) - Improve example in `Service` docs. ([#510])

27
third_party/rust/tower-service/Cargo.toml поставляемый
Просмотреть файл

@ -3,27 +3,32 @@
# When uploading crates to the registry Cargo will automatically # When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility # "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies # with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies # to registry (e.g., crates.io) dependencies.
# #
# If you believe there's an error in this file please file an # If you are reading this file be aware that the original Cargo.toml
# issue against the rust-lang/cargo repository. If you're # will likely look very different (and much more reasonable).
# editing this file be aware that the upstream Cargo.toml # See Cargo.toml.orig for the original contents.
# will likely look very different (and much more reasonable)
[package] [package]
edition = "2018" edition = "2018"
name = "tower-service" name = "tower-service"
version = "0.3.1" version = "0.3.2"
authors = ["Tower Maintainers <team@tower-rs.com>"] authors = ["Tower Maintainers <team@tower-rs.com>"]
description = "Trait representing an asynchronous, request / response based, client or server.\n" description = """
Trait representing an asynchronous, request / response based, client or server.
"""
homepage = "https://github.com/tower-rs/tower" homepage = "https://github.com/tower-rs/tower"
documentation = "https://docs.rs/tower-service/0.3.1" documentation = "https://docs.rs/tower-service/0.3.2"
readme = "README.md" readme = "README.md"
categories = ["asynchronous", "network-programming"] categories = [
"asynchronous",
"network-programming",
]
license = "MIT" license = "MIT"
repository = "https://github.com/tower-rs/tower" repository = "https://github.com/tower-rs/tower"
[dependencies] [dependencies]
[dev-dependencies.futures] [dev-dependencies.futures]
version = "0.3" version = "0.3"
@ -32,6 +37,10 @@ version = "0.2"
[dev-dependencies.tokio] [dev-dependencies.tokio]
version = "1" version = "1"
features = [
"macros",
"time",
]
[dev-dependencies.tower-layer] [dev-dependencies.tower-layer]
version = "0.3" version = "0.3"

87
third_party/rust/tower-service/src/lib.rs поставляемый
Просмотреть файл

@ -1,11 +1,11 @@
#![doc(html_root_url = "https://docs.rs/tower-service/0.3.1")]
#![warn( #![warn(
missing_debug_implementations, missing_debug_implementations,
missing_docs, missing_docs,
rust_2018_idioms, rust_2018_idioms,
unreachable_pub unreachable_pub
)] )]
#![deny(broken_intra_doc_links)] #![forbid(unsafe_code)]
// `rustdoc::broken_intra_doc_links` is checked on CI
//! Definition of the core `Service` trait to Tower //! Definition of the core `Service` trait to Tower
//! //!
@ -231,6 +231,83 @@ use std::task::{Context, Poll};
/// `Service` provides a mechanism by which the caller is able to coordinate /// `Service` provides a mechanism by which the caller is able to coordinate
/// readiness. `Service::poll_ready` returns `Ready` if the service expects that /// readiness. `Service::poll_ready` returns `Ready` if the service expects that
/// it is able to process a request. /// it is able to process a request.
///
/// # Be careful when cloning inner services
///
/// Services are permitted to panic if `call` is invoked without obtaining `Poll::Ready(Ok(()))`
/// from `poll_ready`. You should therefore be careful when cloning services for example to move
/// them into boxed futures. Even though the original service is ready, the clone might not be.
///
/// Therefore this kind of code is wrong and might panic:
///
/// ```rust
/// # use std::pin::Pin;
/// # use std::task::{Poll, Context};
/// # use std::future::Future;
/// # use tower_service::Service;
/// #
/// struct Wrapper<S> {
/// inner: S,
/// }
///
/// impl<R, S> Service<R> for Wrapper<S>
/// where
/// S: Service<R> + Clone + 'static,
/// R: 'static,
/// {
/// type Response = S::Response;
/// type Error = S::Error;
/// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
/// Poll::Ready(Ok(()))
/// }
///
/// fn call(&mut self, req: R) -> Self::Future {
/// let mut inner = self.inner.clone();
/// Box::pin(async move {
/// // `inner` might not be ready since its a clone
/// inner.call(req).await
/// })
/// }
/// }
/// ```
///
/// You should instead use [`std::mem::replace`] to take the service that was ready:
///
/// ```rust
/// # use std::pin::Pin;
/// # use std::task::{Poll, Context};
/// # use std::future::Future;
/// # use tower_service::Service;
/// #
/// struct Wrapper<S> {
/// inner: S,
/// }
///
/// impl<R, S> Service<R> for Wrapper<S>
/// where
/// S: Service<R> + Clone + 'static,
/// R: 'static,
/// {
/// type Response = S::Response;
/// type Error = S::Error;
/// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
/// Poll::Ready(Ok(()))
/// }
///
/// fn call(&mut self, req: R) -> Self::Future {
/// let clone = self.inner.clone();
/// // take the service that was ready
/// let mut inner = std::mem::replace(&mut self.inner, clone);
/// Box::pin(async move {
/// inner.call(req).await
/// })
/// }
/// }
/// ```
pub trait Service<Request> { pub trait Service<Request> {
/// Responses given by the service. /// Responses given by the service.
type Response; type Response;
@ -254,6 +331,12 @@ pub trait Service<Request> {
/// Once `poll_ready` returns `Poll::Ready(Ok(()))`, a request may be dispatched to the /// Once `poll_ready` returns `Poll::Ready(Ok(()))`, a request may be dispatched to the
/// service using `call`. Until a request is dispatched, repeated calls to /// service using `call`. Until a request is dispatched, repeated calls to
/// `poll_ready` must return either `Poll::Ready(Ok(()))` or `Poll::Ready(Err(_))`. /// `poll_ready` must return either `Poll::Ready(Ok(()))` or `Poll::Ready(Err(_))`.
///
/// Note that `poll_ready` may reserve shared resources that are consumed in a subsequent
/// invocation of `call`. Thus, it is critical for implementations to not assume that `call`
/// will always be invoked and to ensure that such resources are released if the service is
/// dropped before `call` is invoked or the future returned by `call` is dropped before it
/// is polled.
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
/// Process the request and return the response asynchronously. /// Process the request and return the response asynchronously.