Project website + use Apalis crate for task queue (with redis backend)
ci/woodpecker/push/tests Pipeline was successful
ci/woodpecker/push/tests Pipeline was successful
instead channel and semaphore queue + upgrade to rust 1.99
This commit is contained in:
1 parent
c546707f72
commit
d74db2096c
23 files changed
+1234
-183
No files matched your search
@@ -2,6 +2,7 @@ use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
bot::Bot,
|
||||
dedup::Dedup,
|
||||
gitea::{GiteaAPI, WebhookType},
|
||||
open_router::OpenRouterClient,
|
||||
sandbox::SandboxConfig,
|
||||
@@ -18,6 +19,7 @@ mod api;
|
||||
mod bot;
|
||||
mod bot_actions;
|
||||
mod consts;
|
||||
mod dedup;
|
||||
mod env;
|
||||
mod errors;
|
||||
mod gitea;
|
||||
@@ -99,19 +101,24 @@ async fn run() -> anyhow::Result<()> {
|
||||
);
|
||||
}
|
||||
|
||||
let redis_conn = apalis_redis::connect(config.redis_url.clone()).await?;
|
||||
let storage: apalis_redis::RedisStorage<WebhookType> =
|
||||
apalis_redis::RedisStorage::new(redis_conn.clone());
|
||||
let dedup = Dedup::new(redis_conn);
|
||||
|
||||
let bot = Bot::new(
|
||||
gitea_user.login,
|
||||
gitea_api,
|
||||
open_router_client,
|
||||
config.bot_max_concurrent,
|
||||
config.open_router_model.clone(),
|
||||
sandbox,
|
||||
dedup.clone(),
|
||||
);
|
||||
|
||||
let (tx, rx) = tokio::sync::mpsc::channel::<WebhookType>(config.bot_max_concurrent * 2);
|
||||
let app_state = AppState {
|
||||
bot_tx: tx,
|
||||
bot: bot.clone(),
|
||||
storage: storage.clone(),
|
||||
bot_name: gitea_user.login.clone(),
|
||||
dedup,
|
||||
config,
|
||||
};
|
||||
|
||||
@@ -136,7 +143,7 @@ async fn run() -> anyhow::Result<()> {
|
||||
tokio::select! {
|
||||
result = async {
|
||||
tokio::try_join!(
|
||||
bot.start(rx, shutdown.clone()),
|
||||
bot.start(storage, shutdown.clone()),
|
||||
api::start(app_state, shutdown.clone()),
|
||||
signal
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user