37 lines
818 B
Rust
37 lines
818 B
Rust
mod uuid;
|
|
mod grpc;
|
|
mod http;
|
|
mod telemetry;
|
|
|
|
pub mod core {
|
|
tonic::include_proto!("core");
|
|
}
|
|
|
|
use crate::telemetry::TelemetryManagementService;
|
|
use std::error::Error;
|
|
use std::sync::Arc;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
pub async fn setup() -> Result<(), Box<dyn Error>> {
|
|
let cancellation_token = CancellationToken::new();
|
|
{
|
|
let cancellation_token = cancellation_token.clone();
|
|
tokio::spawn(async move {
|
|
let _ = tokio::signal::ctrl_c().await;
|
|
cancellation_token.cancel();
|
|
});
|
|
}
|
|
|
|
let tlm = Arc::new(TelemetryManagementService::new());
|
|
|
|
let grpc_server = grpc::setup(cancellation_token.clone(), tlm.clone())?;
|
|
|
|
let result = http::setup(tlm).await;
|
|
cancellation_token.cancel();
|
|
result?;
|
|
grpc_server.await?;
|
|
|
|
Ok(())
|
|
}
|
|
|