maps-service/validation/src/publisher.rs

26 lines
528 B
Rust
Raw Normal View History

2024-12-03 06:09:01 +00:00
use futures::StreamExt;
enum PublishError{
}
pub struct Publisher{
nats:async_nats::Client,
subscriber:async_nats::Subscriber,
}
impl Publisher{
pub async fn new(nats:async_nats::Client)->Result<Self,async_nats::SubscribeError>{
Ok(Self{
subscriber:nats.subscribe("publish").await?,
nats,
})
}
pub async fn run(mut self){
while let Some(message)=self.subscriber.next().await{
self.publish(message).await
}
}
async fn publish(&self,message:async_nats::Message){
println!("publish {:?}",message);
}
}