diff --git a/shared/tunnelbroker-client/src/lib.rs b/shared/tunnelbroker-client/src/lib.rs --- a/shared/tunnelbroker-client/src/lib.rs +++ b/shared/tunnelbroker-client/src/lib.rs @@ -1,6 +1,8 @@ +use anyhow::Result; use lazy_static::lazy_static; use std::sync::Arc; use tokio::runtime::{Builder, Runtime}; +use tokio::sync::mpsc; use tonic::transport::Channel; pub mod tunnelbroker_pb { @@ -24,3 +26,18 @@ .block_on(TunnelbrokerServiceClient::connect(addr)) .expect("Failed to connect ot the Tunnelbroker Service") } + +pub async fn publish_message( + tx: &mpsc::Sender, + messages: Vec, +) -> Result<()> { + let messages = tunnelbroker_pb::MessageToTunnelbroker { + data: Some( + tunnelbroker_pb::message_to_tunnelbroker::Data::MessagesToSend( + tunnelbroker_pb::MessagesToSend { messages }, + ), + ), + }; + tx.send(messages).await?; + Ok(()) +}