fix(examples): Remove use of VecDeque as a placeholder type (#143)
This commit is contained in:
committed by
James Nugent
parent
f9502dfd7e
commit
354d4fdc35
@@ -2,13 +2,14 @@ pub mod pb {
|
||||
tonic::include_proto!("grpc.examples.echo");
|
||||
}
|
||||
|
||||
use futures::Stream;
|
||||
use pb::{EchoRequest, EchoResponse};
|
||||
use std::collections::VecDeque;
|
||||
use std::pin::Pin;
|
||||
use tonic::{body::BoxBody, transport::Server, Request, Response, Status, Streaming};
|
||||
use tower::Service;
|
||||
|
||||
type EchoResult<T> = Result<Response<T>, Status>;
|
||||
type Stream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type ResponseStream = Pin<Box<dyn Stream<Item = Result<EchoResponse, Status>> + Send + Sync>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EchoServer;
|
||||
@@ -20,7 +21,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Ok(Response::new(EchoResponse { message }))
|
||||
}
|
||||
|
||||
type ServerStreamingEchoStream = Stream;
|
||||
type ServerStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn server_streaming_echo(
|
||||
&self,
|
||||
@@ -36,7 +37,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
|
||||
type BidirectionalStreamingEchoStream = Stream;
|
||||
type BidirectionalStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn bidirectional_streaming_echo(
|
||||
&self,
|
||||
|
||||
@@ -2,13 +2,16 @@ pub mod pb {
|
||||
tonic::include_proto!("grpc.examples.echo");
|
||||
}
|
||||
|
||||
use pb::{EchoRequest, EchoResponse};
|
||||
use std::{collections::VecDeque, net::SocketAddr};
|
||||
use futures::Stream;
|
||||
use std::net::SocketAddr;
|
||||
use std::pin::Pin;
|
||||
use tokio::sync::mpsc;
|
||||
use tonic::{transport::Server, Request, Response, Status, Streaming};
|
||||
|
||||
use pb::{EchoRequest, EchoResponse};
|
||||
|
||||
type EchoResult<T> = Result<Response<T>, Status>;
|
||||
type Stream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type ResponseStream = Pin<Box<dyn Stream<Item = Result<EchoResponse, Status>> + Send + Sync>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EchoServer {
|
||||
@@ -23,7 +26,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Ok(Response::new(EchoResponse { message }))
|
||||
}
|
||||
|
||||
type ServerStreamingEchoStream = Stream;
|
||||
type ServerStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn server_streaming_echo(
|
||||
&self,
|
||||
@@ -39,7 +42,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
|
||||
type BidirectionalStreamingEchoStream = Stream;
|
||||
type BidirectionalStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn bidirectional_streaming_echo(
|
||||
&self,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::collections::VecDeque;
|
||||
use futures::Stream;
|
||||
use std::pin::Pin;
|
||||
use tonic::{transport::Server, Request, Response, Status};
|
||||
|
||||
pub mod hello_world {
|
||||
@@ -19,6 +20,8 @@ use echo::{
|
||||
EchoRequest, EchoResponse,
|
||||
};
|
||||
|
||||
type ResponseStream = Pin<Box<dyn Stream<Item = Result<EchoResponse, Status>> + Send + Sync>>;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let addr = "[::1]:50051".parse().unwrap();
|
||||
@@ -64,6 +67,6 @@ impl Echo for MyEcho {
|
||||
Ok(Response::new(EchoResponse { message }))
|
||||
}
|
||||
|
||||
type ServerStreamingEchoStream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type BidirectionalStreamingEchoStream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type ServerStreamingEchoStream = ResponseStream;
|
||||
type BidirectionalStreamingEchoStream = ResponseStream;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,16 @@ pub mod pb {
|
||||
tonic::include_proto!("/grpc.examples.echo");
|
||||
}
|
||||
|
||||
use futures::Stream;
|
||||
use pb::{EchoRequest, EchoResponse};
|
||||
use std::collections::VecDeque;
|
||||
use std::pin::Pin;
|
||||
use tonic::{
|
||||
transport::{Identity, Server, ServerTlsConfig},
|
||||
Request, Response, Status, Streaming,
|
||||
};
|
||||
|
||||
type EchoResult<T> = Result<Response<T>, Status>;
|
||||
type Stream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type ResponseStream = Pin<Box<dyn Stream<Item = Result<EchoResponse, Status>> + Send + Sync>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EchoServer;
|
||||
@@ -22,7 +23,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Ok(Response::new(EchoResponse { message }))
|
||||
}
|
||||
|
||||
type ServerStreamingEchoStream = Stream;
|
||||
type ServerStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn server_streaming_echo(
|
||||
&self,
|
||||
@@ -38,7 +39,7 @@ impl pb::server::Echo for EchoServer {
|
||||
Err(Status::unimplemented("not implemented"))
|
||||
}
|
||||
|
||||
type BidirectionalStreamingEchoStream = Stream;
|
||||
type BidirectionalStreamingEchoStream = ResponseStream;
|
||||
|
||||
async fn bidirectional_streaming_echo(
|
||||
&self,
|
||||
|
||||
@@ -2,14 +2,14 @@ pub mod pb {
|
||||
tonic::include_proto!("grpc.examples.echo");
|
||||
}
|
||||
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use futures::Stream;
|
||||
use pb::{EchoRequest, EchoResponse};
|
||||
use std::pin::Pin;
|
||||
use tonic::transport::{Certificate, Identity, Server, ServerTlsConfig};
|
||||
use tonic::{Request, Response, Status};
|
||||
|
||||
type EchoResult<T> = Result<Response<T>, Status>;
|
||||
type Stream = VecDeque<Result<EchoResponse, Status>>;
|
||||
type ResponseStream = Pin<Box<dyn Stream<Item = Result<EchoResponse, Status>> + Send + Sync>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EchoServer;
|
||||
@@ -21,8 +21,8 @@ impl pb::server::Echo for EchoServer {
|
||||
Ok(Response::new(EchoResponse { message }))
|
||||
}
|
||||
|
||||
type ServerStreamingEchoStream = Stream;
|
||||
type BidirectionalStreamingEchoStream = Stream;
|
||||
type ServerStreamingEchoStream = ResponseStream;
|
||||
type BidirectionalStreamingEchoStream = ResponseStream;
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
||||
Reference in New Issue
Block a user