add publish log
This commit is contained in:
parent
02ab5ecaa6
commit
1bd19eff20
2 changed files with 3 additions and 2 deletions
|
@ -87,7 +87,8 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
if news_post.is_complete() {
|
||||
let title = news_post.title.clone().unwrap();
|
||||
if redis_service.is_post_seen(&title).await {
|
||||
redis_service.publish(news_post).await;
|
||||
redis_service.publish(&news_post).await;
|
||||
info!("Published {:?}", news_post);
|
||||
redis_service.mark_post_seen(&title, 60 * 60 * 24 * 3).await;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl RedisService {
|
|||
}
|
||||
|
||||
/// Publishes the post to the redis stream.
|
||||
pub async fn publish(&mut self, post: NewsPost) {
|
||||
pub async fn publish(&mut self, post: &NewsPost) {
|
||||
let serialized_post = serde_json::to_string(&post).unwrap();
|
||||
let result = redis::cmd("XADD")
|
||||
.arg(format!("posts:{}", self.stream_name))
|
||||
|
|
Loading…
Reference in a new issue