From b2eaa03965ca52d5814361e2ac48b4e3ab414819 Mon Sep 17 00:00:00 2001 From: Zach Johnson Date: Thu, 29 Oct 2020 16:16:53 -0700 Subject: [PATCH] A few minor cleanups to hci facades * Bury the grpc service construction inside the facade service * no need to keep the rootcanal config around, pass it along without cloning Bug: 171749953 Tag: #gd-refactor Test: gd/cert/run --host Change-Id: If7820cecbcd899b7cab5c72678da986559bbcdd7 --- gd/rust/hci/src/facade/hci_facade_main.rs | 10 ++-------- gd/rust/hci/src/facade/hci_facade_server.rs | 5 +++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/gd/rust/hci/src/facade/hci_facade_main.rs b/gd/rust/hci/src/facade/hci_facade_main.rs index 8702d89e9..dab436a96 100644 --- a/gd/rust/hci/src/facade/hci_facade_main.rs +++ b/gd/rust/hci/src/facade/hci_facade_main.rs @@ -7,9 +7,7 @@ use futures::executor::block_on; use grpcio::*; use hal::rootcanal_hal::{RootcanalConfig, RootcanalHal}; use hci::facade::hci_facade_server::HciLayerFacadeService; -use hci::facade::protos::hci_layer_facade_grpc; use hci::Hci; -use hci_layer_facade_grpc::create_hci_layer_facade; use std::io::{self, Read}; use std::sync::Arc; @@ -19,14 +17,10 @@ use tokio::runtime::Runtime; async fn async_main(rt: Arc) -> Result<()> { let env = Arc::new(Environment::new(2)); - let rootcanal_config = RootcanalConfig::new(6402, "127.0.0.1"); - let hal_exports = RootcanalHal::start(rootcanal_config.clone(), Arc::clone(&rt)).await.unwrap(); + let hal_exports = RootcanalHal::start(RootcanalConfig::new(6402, "127.0.0.1"), Arc::clone(&rt)).await.unwrap(); let hci_exports = Hci::start(hal_exports, Arc::clone(&rt)); let mut server = ServerBuilder::new(env) - .register_service(create_hci_layer_facade(HciLayerFacadeService::new( - hci_exports, - Arc::clone(&rt), - ))) + .register_service(HciLayerFacadeService::create(hci_exports, Arc::clone(&rt))) .bind("0.0.0.0", 8999) .build() .unwrap(); diff --git a/gd/rust/hci/src/facade/hci_facade_server.rs b/gd/rust/hci/src/facade/hci_facade_server.rs index 29e8b38a2..fae450b88 100644 --- a/gd/rust/hci/src/facade/hci_facade_server.rs +++ b/gd/rust/hci/src/facade/hci_facade_server.rs @@ -22,11 +22,12 @@ pub struct HciLayerFacadeService { use super::protos::empty::Empty; use super::protos::facade::*; use super::protos::hci_layer_facade_grpc::HciLayerFacade; +use crate::facade::protos::hci_layer_facade_grpc::create_hci_layer_facade; impl HciLayerFacadeService { /// Create a new instance of HCI layer facade service - pub fn new(hci_exports: HciExports, rt: Arc) -> Self { - Self { hci_exports, rt } + pub fn create(hci_exports: HciExports, rt: Arc) -> grpcio::Service { + create_hci_layer_facade(Self { hci_exports, rt }) } } -- 2.11.0