refactor: Move GrpcService definition up a module

pull/24376/head
Carol (Nichols || Goulding) 2021-02-01 13:16:03 -05:00
parent 9ff2ee99d8
commit 51d18e6ac7
2 changed files with 19 additions and 22 deletions

View File

@ -42,15 +42,26 @@ where
let stream = TcpListenerStream::new(socket);
tonic::transport::Server::builder()
.add_service(IOxTestingServer::new(service::GrpcService::new(
storage.clone(),
)))
.add_service(StorageServer::new(service::GrpcService::new(
storage.clone(),
)))
.add_service(FlightServiceServer::new(service::GrpcService::new(storage)))
.add_service(IOxTestingServer::new(GrpcService::new(storage.clone())))
.add_service(StorageServer::new(GrpcService::new(storage.clone())))
.add_service(FlightServiceServer::new(GrpcService::new(storage)))
.serve_with_incoming(stream)
.await
.context(ServerError {})
.log_if_error("Running Tonic Server")
}
#[derive(Debug)]
pub struct GrpcService<T: DatabaseStore> {
db_store: Arc<T>,
}
impl<T> GrpcService<T>
where
T: DatabaseStore + 'static,
{
/// Create a new GrpcService connected to `db_store`
pub fn new(db_store: Arc<T>) -> Self {
Self { db_store }
}
}

View File

@ -9,6 +9,7 @@ use super::{
},
expr::{self, AddRPCNode, Loggable, SpecialTagKeys},
input::GrpcInputs,
GrpcService,
};
use arrow_deps::{
arrow,
@ -246,21 +247,6 @@ impl Error {
}
}
#[derive(Debug)]
pub struct GrpcService<T: DatabaseStore> {
db_store: Arc<T>,
}
impl<T> GrpcService<T>
where
T: DatabaseStore + 'static,
{
/// Create a new GrpcService connected to `db_store`
pub fn new(db_store: Arc<T>) -> Self {
Self { db_store }
}
}
#[tonic::async_trait]
/// Implements the protobuf defined IOx rpc service for a DatabaseStore
impl<T> IOxTesting for GrpcService<T>