mirror of
https://github.com/Noratrieb/101844-repro.git
synced 2026-01-15 22:55:02 +01:00
tower lol
This commit is contained in:
parent
1e415960ec
commit
40a6bd3bce
49 changed files with 4626 additions and 1 deletions
63
tower/tower-service/CHANGELOG.md
Normal file
63
tower/tower-service/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# 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)
|
||||
|
||||
- Improve example in `Service` docs. ([#510])
|
||||
|
||||
[#510]: https://github.com/tower-rs/tower/pull/510
|
||||
|
||||
# 0.3.0 (November 29, 2019)
|
||||
|
||||
- Update to `futures 0.3`.
|
||||
- Update documentation for `std::future::Future`.
|
||||
|
||||
# 0.3.0-alpha.2 (September 30, 2019)
|
||||
|
||||
- Documentation fixes.
|
||||
|
||||
# 0.3.0-alpha.1 (Aug 20, 2019)
|
||||
|
||||
* Switch to `std::future::Future`
|
||||
|
||||
# 0.2.0 (Dec 12, 2018)
|
||||
|
||||
* Change `Service`'s `Request` associated type to be a generic instead.
|
||||
* Before:
|
||||
|
||||
```rust
|
||||
impl Service for Client {
|
||||
type Request = HttpRequest;
|
||||
type Response = HttpResponse;
|
||||
// ...
|
||||
}
|
||||
```
|
||||
* After:
|
||||
|
||||
```rust
|
||||
impl Service<HttpRequest> for Client {
|
||||
type Response = HttpResponse;
|
||||
// ...
|
||||
}
|
||||
```
|
||||
* Remove `NewService`, use `tower_util::MakeService` instead.
|
||||
* Remove `Service::ready` and `Ready`, use `tower_util::ServiceExt` instead.
|
||||
|
||||
# 0.1.0 (Aug 9, 2018)
|
||||
|
||||
* Initial release
|
||||
28
tower/tower-service/Cargo.toml
Normal file
28
tower/tower-service/Cargo.toml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[package]
|
||||
name = "tower-service"
|
||||
# When releasing to crates.io:
|
||||
# - Update doc url
|
||||
# - Cargo.toml
|
||||
# - README.md
|
||||
# - Update CHANGELOG.md.
|
||||
# - Create "v0.3.x" git tag.
|
||||
version = "0.3.2"
|
||||
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-service/0.3.2"
|
||||
description = """
|
||||
Trait representing an asynchronous, request / response based, client or server.
|
||||
"""
|
||||
categories = ["asynchronous", "network-programming"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[dev-dependencies]
|
||||
http = "0.2"
|
||||
tower-layer = { version = "0.3", path = "../tower-layer" }
|
||||
tokio = { version = "1", features = ["macros", "time"] }
|
||||
futures = "0.3"
|
||||
25
tower/tower-service/LICENSE
Normal file
25
tower/tower-service/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2019 Tower Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
56
tower/tower-service/README.md
Normal file
56
tower/tower-service/README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Tower Service
|
||||
|
||||
The foundational `Service` trait that [Tower] is based on.
|
||||
|
||||
[![Crates.io][crates-badge]][crates-url]
|
||||
[![Documentation][docs-badge]][docs-url]
|
||||
[![Documentation (master)][docs-master-badge]][docs-master-url]
|
||||
[![MIT licensed][mit-badge]][mit-url]
|
||||
[![Build Status][actions-badge]][actions-url]
|
||||
[![Discord chat][discord-badge]][discord-url]
|
||||
|
||||
[crates-badge]: https://img.shields.io/crates/v/tower-service.svg
|
||||
[crates-url]: https://crates.io/crates/tower-service
|
||||
[docs-badge]: https://docs.rs/tower-service/badge.svg
|
||||
[docs-url]: https://docs.rs/tower-service
|
||||
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue
|
||||
[docs-master-url]: https://tower-rs.github.io/tower/tower_service
|
||||
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[mit-url]: LICENSE
|
||||
[actions-badge]: https://github.com/tower-rs/tower/workflows/CI/badge.svg
|
||||
[actions-url]:https://github.com/tower-rs/tower/actions?query=workflow%3ACI
|
||||
[discord-badge]: https://img.shields.io/discord/500028886025895936?logo=discord&label=discord&logoColor=white
|
||||
[discord-url]: https://discord.gg/EeF3cQw
|
||||
|
||||
## Overview
|
||||
|
||||
The [`Service`] trait provides the foundation upon which [Tower] is built. It is a
|
||||
simple, but powerful trait. At its heart, `Service` is just an asynchronous
|
||||
function of request to response.
|
||||
|
||||
```
|
||||
async fn(Request) -> Result<Response, Error>
|
||||
```
|
||||
|
||||
Implementations of `Service` take a request, the type of which varies per
|
||||
protocol, and returns a future representing the eventual completion or failure
|
||||
of the response.
|
||||
|
||||
Services are used to represent both clients and servers. An *instance* of
|
||||
`Service` is used through a client; a server *implements* `Service`.
|
||||
|
||||
By using standardizing the interface, middleware can be created. Middleware
|
||||
*implement* `Service` by passing the request to another `Service`. The
|
||||
middleware may take actions such as modify the request.
|
||||
|
||||
[`Service`]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
|
||||
[Tower]: https://crates.io/crates/tower
|
||||
## License
|
||||
|
||||
This project is licensed under the [MIT license](LICENSE).
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in Tower by you, shall be licensed as MIT, without any additional
|
||||
terms or conditions.
|
||||
20
tower/tower-service/src/lib.rs
Normal file
20
tower/tower-service/src/lib.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![warn(rust_2018_idioms, unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
use std::future::Future;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
pub trait Service<Request> {
|
||||
/// Responses given by the service.
|
||||
type Response;
|
||||
|
||||
/// Errors produced by the service.
|
||||
type Error;
|
||||
|
||||
/// The future response value.
|
||||
type Future: Future<Output = Result<Self::Response, Self::Error>>;
|
||||
|
||||
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
|
||||
|
||||
fn call(&mut self, req: Request) -> Self::Future;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue