edrevo commented on a change in pull request #9987:
URL: https://github.com/apache/arrow/pull/9987#discussion_r624519673
##########
File path: rust/ballista/rust/scheduler/src/main.rs
##########
@@ -56,11 +61,35 @@ async fn start_server(
"Ballista v{} Scheduler listening on {:?}",
BALLISTA_VERSION, addr
);
- let server =
- SchedulerGrpcServer::new(SchedulerServer::new(config_backend,
namespace));
- Ok(Server::builder()
- .add_service(server)
- .serve(addr)
+ Ok(Server::bind(&addr)
+ .serve(make_service_fn(move |_| {
+ let scheduler_server =
SchedulerServer::new(config_backend.clone(), namespace.clone());
+ let scheduler_grpc_server =
SchedulerGrpcServer::new(scheduler_server.clone());
+
+ let mut tonic = TonicServer::builder()
+ .add_service(scheduler_grpc_server)
+ .into_service();
+ let mut warp = warp::service(get_routes(scheduler_server));
+
+ future::ok::<_, Infallible>(tower::service_fn(
+ move |req: hyper::Request<hyper::Body>| {
+ let header = req.headers().get(hyper::header::ACCEPT);
+ if header.is_some() &&
header.unwrap().eq("application/json") {
+ return Either::Left(
+ warp.call(req)
+ .map_ok(|res| res.map(EitherBody::Left))
+ .map_err(Error::from),
+ );
+ }
+ Either::Right(
+ tonic
+ .call(req)
+ .map_ok(|res| res.map(EitherBody::Right))
+ .map_err(Error::from),
+ )
+ },
+ ))
Review comment:
Sorry I'm super late to this PR. Does this change mean that a
SchedulerGrpcServer is being built for every request?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]