-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tonic): Remove
Sync
requirement for streams (#804)
- Loading branch information
1 parent
1f3df8d
commit 23c1392
Showing
31 changed files
with
207 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,24 @@ | ||
[workspace] | ||
members = [ | ||
"tonic", | ||
"tonic-build", | ||
"tonic-health", | ||
"tonic-types", | ||
"tonic-reflection", | ||
"tonic-web", | ||
|
||
# Non-published crates | ||
"examples", | ||
"interop", | ||
|
||
# Tests | ||
"tests/included_service", | ||
"tests/same_name", | ||
"tests/service_named_service", | ||
"tests/wellknown", | ||
"tests/wellknown-compiled", | ||
"tests/extern_path/uuid", | ||
"tests/ambiguous_methods", | ||
"tests/extern_path/my_application", | ||
"tests/integration_tests", | ||
"tests/stream_conflict", | ||
"tests/root-crate-path", | ||
"tests/compression", | ||
"tonic-web/tests/integration" | ||
"tonic", | ||
"tonic-build", | ||
"tonic-health", | ||
"tonic-types", | ||
"tonic-reflection", | ||
"tonic-web", # Non-published crates | ||
"examples", | ||
"interop", # Tests | ||
"tests/included_service", | ||
"tests/same_name", | ||
"tests/service_named_service", | ||
"tests/wellknown", | ||
"tests/wellknown-compiled", | ||
"tests/extern_path/uuid", | ||
"tests/ambiguous_methods", | ||
"tests/extern_path/my_application", | ||
"tests/integration_tests", | ||
"tests/stream_conflict", | ||
"tests/root-crate-path", | ||
"tests/compression", | ||
"tonic-web/tests/integration", | ||
] | ||
|
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
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,47 @@ | ||
use futures::FutureExt; | ||
use integration_tests::pb::{test_stream_server, InputStream, OutputStream}; | ||
use tonic::{transport::Server, Request, Response, Status}; | ||
|
||
type Stream<T> = | ||
std::pin::Pin<Box<dyn futures::Stream<Item = std::result::Result<T, Status>> + Send + 'static>>; | ||
|
||
#[tokio::test] | ||
async fn status_from_server_stream_with_source() { | ||
struct Svc; | ||
|
||
#[tonic::async_trait] | ||
impl test_stream_server::TestStream for Svc { | ||
type StreamCallStream = Stream<OutputStream>; | ||
|
||
async fn stream_call( | ||
&self, | ||
_: Request<InputStream>, | ||
) -> Result<Response<Self::StreamCallStream>, Status> { | ||
let s = Unsync(0 as *mut ()); | ||
|
||
Ok(Response::new(Box::pin(s) as Self::StreamCallStream)) | ||
} | ||
} | ||
|
||
let svc = test_stream_server::TestStreamServer::new(Svc); | ||
|
||
Server::builder() | ||
.add_service(svc) | ||
.serve("127.0.0.1:1339".parse().unwrap()) | ||
.now_or_never(); | ||
} | ||
|
||
struct Unsync(*mut ()); | ||
|
||
unsafe impl Send for Unsync {} | ||
|
||
impl futures::Stream for Unsync { | ||
type Item = Result<OutputStream, Status>; | ||
|
||
fn poll_next( | ||
self: std::pin::Pin<&mut Self>, | ||
_cx: &mut std::task::Context<'_>, | ||
) -> std::task::Poll<Option<Self::Item>> { | ||
unimplemented!() | ||
} | ||
} |
Oops, something went wrong.