use fundamentum_edge_proto::com::fundamentum::edge::v1::{ telemetry_server::{Telemetry, TelemetryServer}, TelemetryRequest, }; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use tonic::transport::Server; use tonic::{Request, Response, Status, Streaming}; #[derive(Default)] pub struct TelemetryService {} impl TelemetryService { pub fn new() -> Self { Self {} } } #[tonic::async_trait] impl Telemetry for TelemetryService { async fn publish( &self, request: Request>, ) -> Result, Status> { let mut stream = request.into_inner(); while let Some(req) = stream.message().await? { println!("Received: {:?}", req); } Ok(Response::new(())) } async fn publish_one( &self, request: Request, ) -> Result, Status> { println!("Received: {:?}", request.into_inner()); Ok(Response::new(())) } } #[tokio::main] async fn main() -> Result<(), Box> { let socket_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080); let telemetry_svc = TelemetryService::new(); let router = Server::builder().add_service(TelemetryServer::new(telemetry_svc)); router.serve(socket_addr).await?; Ok(()) }