-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: create Service trait #2920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seanmonstar
merged 12 commits into
hyperium:master
from
tomkarw:feat-create-service-trait
Sep 8, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df6619a
chore: remove reexport of tower_service::Service as hyper::service::S…
tomkarw fede1cc
feat(service): add Service trait
tomkarw ca17e6f
chore: rename service::http::HttpService to service::tower_http::Towe…
tomkarw ab78dbc
feat(service): add service::HttpService that extends service::Service
tomkarw 0e077c5
feat(proto,server,service): completely remove server module's relianc…
tomkarw 7e298fe
chore: fix all examples and tests
tomkarw 72927a6
feat(client): implement hyper::service::Service instead of tower::Ser…
tomkarw 82f5fa5
chore(service): remove mentions of poll_ready in Service doc-strings
tomkarw 8c121b7
chore(client): remove Service implementation for client::conn::SendRe…
tomkarw 1c553e5
feat(proto): add poll_ready back to Dispatch trait, implement it simp…
tomkarw e2804d2
chore: revert full Dispatch.poll_ready implementation for Client and …
tomkarw 40adb7f
chore(proto): revert check in Dispatcher.poll_read_head with updated …
tomkarw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
seanmonstar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.