Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97337854 authored by Zach Johnson's avatar Zach Johnson
Browse files

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
parent 9d874bd6
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -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<Runtime>) -> 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();
+3 −2
Original line number Diff line number Diff line
@@ -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<Runtime>) -> Self {
        Self { hci_exports, rt }
    pub fn create(hci_exports: HciExports, rt: Arc<Runtime>) -> grpcio::Service {
        create_hci_layer_facade(Self { hci_exports, rt })
    }
}