-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service): create own
Service
trait (#2920)
This removes the dependency on `tower-service`, and simplifies the `Service` trait to be used by hyper's server connections. Closes #2853 BREAKING CHANGE: Change any manual `impl tower::Service` to implement `hyper::service::Service` instead. The `poll_ready` method has been removed.
- Loading branch information
Showing
10 changed files
with
54 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::future::Future; | ||
|
||
/// An asynchronous function from a `Request` to a `Response`. | ||
/// | ||
/// The `Service` trait is a simplified interface making it easy to write | ||
/// network applications in a modular and reusable way, decoupled from the | ||
/// underlying protocol. | ||
/// | ||
/// # Functional | ||
/// | ||
/// A `Service` is a function of a `Request`. It immediately returns a | ||
/// `Future` representing the eventual completion of processing the | ||
/// request. The actual request processing may happen at any time in the | ||
/// future, on any thread or executor. The processing may depend on calling | ||
/// other services. At some point in the future, the processing will complete, | ||
/// and the `Future` will resolve to a response or error. | ||
/// | ||
/// At a high level, the `Service::call` function represents an RPC request. The | ||
/// `Service` value can be a server or a client. | ||
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>>; | ||
|
||
/// Process the request and return the response asynchronously. | ||
fn call(&mut self, req: Request) -> Self::Future; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.