maps-service/validation/src/publish_new.rs

36 lines
813 B
Rust
Raw Normal View History

2024-12-03 06:09:01 +00:00
use futures::StreamExt;
2024-12-03 06:52:01 +00:00
#[derive(Debug)]
2024-12-03 06:09:01 +00:00
enum PublishError{
}
2024-12-03 06:52:01 +00:00
impl std::fmt::Display for PublishError{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
write!(f,"{self:?}")
}
}
impl std::error::Error for PublishError{}
2024-12-03 06:09:01 +00:00
pub struct Publisher{
subscriber:async_nats::Subscriber,
2024-12-03 06:52:01 +00:00
roblox_cookie:rbx_asset::cookie::CookieContext,
2024-12-03 06:09:01 +00:00
}
impl Publisher{
2024-12-03 06:52:01 +00:00
pub async fn new(
nats:async_nats::Client,
roblox_cookie:rbx_asset::cookie::CookieContext,
)->Result<Self,async_nats::SubscribeError>{
2024-12-03 06:09:01 +00:00
Ok(Self{
subscriber:nats.subscribe("publish_new").await?,
2024-12-03 06:52:01 +00:00
roblox_cookie,
2024-12-03 06:09:01 +00:00
})
}
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);
}
}