Skip to content

Commit b4eb9dd

Browse files
author
Mauricio Cassola
committed
Add background processing
1 parent 0719cf6 commit b4eb9dd

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/main.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use tower::{Service, ServiceExt};
1111
use tracing as log;
1212
use tracing::Instrument;
1313
use triagebot::{db, github, handlers::Context, notification_listing, payload, EventName};
14-
// use std::{time::Duration, thread};
15-
// use tokio::task;
14+
use std::{time::Duration, thread};
15+
use tokio::task;
1616

1717
async fn handle_agenda_request(req: String) -> anyhow::Result<String> {
1818
if req == "/agenda/lang/triage" {
@@ -237,21 +237,19 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
237237
let pool = db::ClientPool::new();
238238
db::run_migrations(&*pool.get().await)
239239
.await
240-
.context("database migrations")?;
240+
.context("database migrations")?;
241241

242-
db::run_scheduled_events(&*pool.get().await)
243-
.await
244-
.context("database scheduled_events")?;
242+
task::spawn(async move {
243+
let pool = db::ClientPool::new();
245244

246-
// task::spawn(async move {
247-
// loop {
248-
// thread::sleep(Duration::from_secs(60)); // every one minute
245+
loop {
246+
thread::sleep(Duration::from_secs(60)); // every one minute
249247

250-
// db::run_scheduled_events(&*pool.get().await)
251-
// .await
252-
// .context("database scheduled_events")?;
253-
// }
254-
// });
248+
db::run_scheduled_events(&*pool.get().await)
249+
.await
250+
.context("database scheduled_events").unwrap();
251+
}
252+
});
255253

256254
let client = Client::new();
257255
let gh = github::GithubClient::new_with_default_token(client.clone());

0 commit comments

Comments
 (0)