feat: initial work on elasticsearch integration

Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
Zomatree
2026-03-19 23:04:37 +00:00
parent d9643ebd8d
commit 8009b3bf53
49 changed files with 1526 additions and 128 deletions

View File

@@ -0,0 +1,25 @@
use amqprs::{BasicProperties, Deliver, channel::{BasicAckArguments, Channel}, consumer::AsyncConsumer};
use async_trait::async_trait;
use revolt_database::events::rabbit::MessageDeletePayload;
use revolt_search::ElasticsearchClient;
pub struct MessageDeleteConsumer(pub ElasticsearchClient);
#[async_trait]
impl AsyncConsumer for MessageDeleteConsumer {
async fn consume(
&mut self,
channel: &Channel,
deliver: Deliver,
_basic_properties: BasicProperties,
content: Vec<u8>,
) {
let payload = serde_json::from_slice::<MessageDeletePayload>(&content).expect("Failed to decode message");
if self.0.delete_message(&payload.message_id).await.is_ok() {
channel.basic_ack(BasicAckArguments::new(deliver.delivery_tag(), false)).await.expect("Failed to ack");
} else {
// todo requeue
}
}
}