Update interop server
This commit is contained in:
+1
-1
@@ -3,5 +3,5 @@ members = [
|
||||
"tonic",
|
||||
"tonic-build",
|
||||
"tonic-examples",
|
||||
# "tonic-interop",
|
||||
"tonic-interop",
|
||||
]
|
||||
|
||||
@@ -3,12 +3,12 @@ mod data;
|
||||
use futures::{Stream, StreamExt};
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use tokio::sync::{mpsc, Lock};
|
||||
use tonic::transport::Server;
|
||||
use tonic::{Request, Response, Status};
|
||||
use std::pin::Pin;
|
||||
|
||||
pub mod routeguide {
|
||||
include!(concat!(env!("OUT_DIR"), "/routeguide.rs"));
|
||||
@@ -147,7 +147,10 @@ impl routeguide::RouteGuide for RouteGuide {
|
||||
};
|
||||
|
||||
// TODO: Clean this up
|
||||
Ok(Response::new(Box::pin(output) as Pin<Box<dyn Stream<Item = Result<RouteNote, Status>> + Send + 'static>>))
|
||||
Ok(Response::new(Box::pin(output)
|
||||
as Pin<
|
||||
Box<dyn Stream<Item = Result<RouteNote, Status>> + Send + 'static>,
|
||||
>))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,9 +170,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let svc = routeguide::RouteGuideServer::new(route_guide);
|
||||
|
||||
Server::builder()
|
||||
.serve(addr, svc)
|
||||
.await?;
|
||||
Server::builder().serve(addr, svc).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ prost = "0.5"
|
||||
prost-derive = "0.5"
|
||||
bytes = "0.4"
|
||||
http = "0.1"
|
||||
futures-core-preview = "=0.3.0-alpha.18"
|
||||
futures-util-preview = "=0.3.0-alpha.18"
|
||||
|
||||
console = "0.7"
|
||||
|
||||
@@ -2,7 +2,7 @@ fn main() {
|
||||
let files = &["proto/grpc/testing/test.proto"];
|
||||
let dirs = &["proto/grpc/testing"];
|
||||
|
||||
tonic_build::compile_protos(files, dirs).unwrap();
|
||||
tonic_build::compile_protos(files, dirs, "grpc.testing").unwrap();
|
||||
|
||||
// prevent needing to rebuild if files (or deps) haven't changed
|
||||
for file in files {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
use structopt::StructOpt;
|
||||
use tonic::transport::Server;
|
||||
use tonic::{Code, Request, Response, Status};
|
||||
use tonic::{Code, Request, Response, Status, Server};
|
||||
use std::pin::Pin;
|
||||
|
||||
pub mod pb {
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
include!(concat!(env!("OUT_DIR"), "/grpc.testing.rs"));
|
||||
tonic::client!(service = "grpc.testing.TestService", proto = "self");
|
||||
}
|
||||
|
||||
use pb::*;
|
||||
@@ -16,17 +15,21 @@ pub struct TestService {
|
||||
data: String,
|
||||
}
|
||||
|
||||
#[tonic::server(service = "grpc.testing.TestService", proto = "pb")]
|
||||
impl TestService {
|
||||
pub async fn empty_call(&self, _request: Request<Empty>) -> Result<Response<Empty>, Status> {
|
||||
type Result<T> = std::result::Result<Response<T>, Status>;
|
||||
type Streaming<T> = Request<tonic::Streaming<T>>;
|
||||
type Stream<T> = Pin<Box<dyn futures_core::Stream<Item = std::result::Result<T, Status>> + Send + 'static>>;
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl pb::TestService for TestService {
|
||||
async fn empty_call(&self, _request: Request<Empty>) -> Result<Empty> {
|
||||
println!("empty_call");
|
||||
Ok(Response::new(Empty {}))
|
||||
}
|
||||
|
||||
pub async fn unary_call(
|
||||
async fn unary_call(
|
||||
&self,
|
||||
request: Request<SimpleRequest>,
|
||||
) -> Result<Response<SimpleResponse>, Status> {
|
||||
) -> Result<SimpleResponse> {
|
||||
println!("unary_call");
|
||||
|
||||
let req = request.into_inner();
|
||||
@@ -53,6 +56,36 @@ impl TestService {
|
||||
|
||||
Ok(Response::new(res))
|
||||
}
|
||||
|
||||
async fn cacheable_unary_call(&self, _: Request<SimpleRequest>) -> Result<SimpleResponse> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
type StreamingOutputCallStream = Stream<StreamingOutputCallResponse>;
|
||||
|
||||
async fn streaming_output_call(&self, _: Request<StreamingOutputCallRequest>) -> Result<Self::StreamingOutputCallStream> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn streaming_input_call(&self, _: Streaming<StreamingInputCallRequest>) -> Result<StreamingInputCallResponse> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
type FullDuplexCallStream = Stream<StreamingOutputCallResponse>;
|
||||
|
||||
async fn full_duplex_call(&self, _: Streaming<StreamingOutputCallRequest>) -> Result<Self::FullDuplexCallStream> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
type HalfDuplexCallStream = Stream<StreamingOutputCallResponse>;
|
||||
|
||||
async fn half_duplex_call(&self, _: Streaming<StreamingOutputCallRequest>) -> Result<Self::HalfDuplexCallStream> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
async fn unimplemented_call(&self, _: Request<Empty>) -> Result<Empty> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(StructOpt)]
|
||||
@@ -62,7 +95,7 @@ struct Opts {
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
let matches = Opts::from_args();
|
||||
|
||||
pretty_env_logger::init();
|
||||
|
||||
@@ -7,12 +7,6 @@ use tonic::{metadata::MetadataValue, Code, Request, Response, Status};
|
||||
pub type TestClient = TestServiceClient<Channel>;
|
||||
pub type UnimplementedClient = UnimplementedServiceClient<Channel>;
|
||||
|
||||
tonic::client!(service = "grpc.testing.TestService", proto = "crate::pb");
|
||||
tonic::client!(
|
||||
service = "grpc.testing.UnimplementedService",
|
||||
proto = "crate::pb"
|
||||
);
|
||||
|
||||
const LARGE_REQ_SIZE: usize = 271828;
|
||||
const LARGE_RSP_SIZE: i32 = 314159;
|
||||
const REQUEST_LENGTHS: &'static [i32] = &[27182, 8, 1828, 45904];
|
||||
|
||||
Reference in New Issue
Block a user