Project website + use Apalis crate for task queue (with redis backend)
ci/woodpecker/push/tests Pipeline was successful

instead channel and semaphore queue + upgrade to rust 1.99
This commit is contained in:
qpismont committed 2026-10-05 20:44:57 +00:00
1 parent c546707f72
commit d74db2096c
23 files changed
+1234 -183

No files matched your search

+16 -6
View File
@@ -14,7 +14,10 @@ use tracing::{info, instrument};
use tokio_util::sync::CancellationToken;
use apalis::prelude::Storage;
use crate::consts::{GITEA_EVENT_TYPE_HEADER_NAME, GITEA_SIG_HEADER_NAME, MAX_WEBHOOK_BODY_SIZE};
use crate::dedup::{Dedup, WEBHOOK_TTL};
use crate::errors::AppError;
use crate::gitea::WebhookType;
use crate::metrics;
@@ -61,15 +64,22 @@ async fn webhook(
metrics::webhook_received(event_type);
let event_id = wb.event_id();
if app_state.bot.check_and_mark(event_id).await {
let webhook_key = Dedup::webhook_key(event_id);
if !app_state
.dedup
.claim(&webhook_key, WEBHOOK_TTL)
.await
.map_err(anyhow::Error::from)?
{
metrics::webhook_duplicate(event_type);
return Err(AppError::AlreadyProcessedErr);
}
if app_state.bot_tx.try_send(wb).is_err() {
app_state.bot.unmark(event_id).await;
metrics::webhook_channel_full(event_type);
return Err(AppError::ChannelFullErr);
let mut storage = app_state.storage.clone();
if let Err(err) = storage.push(wb).await {
app_state.dedup.release(&webhook_key).await.ok();
metrics::webhook_enqueue_failed(event_type);
return Err(AppError::EnqueueErr(anyhow::Error::from(err)));
}
Ok((StatusCode::CREATED, "Task started"))
@@ -109,7 +119,7 @@ where
});
});
let webhook = parse_webhook(&type_header, &app_state.bot.name(), &body_bytes)?;
let webhook = parse_webhook(&type_header, &app_state.bot_name, &body_bytes)?;
Ok(WebhookExtract(webhook))
}
}