1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

Extract the job tracing span logic to a layer

This commit is contained in:
Quentin Gliech
2023-04-03 17:36:15 +02:00
parent f4fff72b22
commit 169d7ce6a2
9 changed files with 174 additions and 87 deletions

View File

@@ -68,9 +68,14 @@ pub async fn cleanup_expired_tokens(
Ok(())
}
pub(crate) fn register(monitor: Monitor<TokioExecutor>, state: &State) -> Monitor<TokioExecutor> {
pub(crate) fn register(
suffix: &str,
monitor: Monitor<TokioExecutor>,
state: &State,
) -> Monitor<TokioExecutor> {
let schedule = apalis_cron::Schedule::from_str("*/15 * * * * *").unwrap();
let worker = WorkerBuilder::new("cleanup-expired-tokens")
let worker_name = format!("{job}-{suffix}", job = CleanupExpiredTokensJob::NAME);
let worker = WorkerBuilder::new(worker_name)
.stream(CronStream::new(schedule).to_stream())
.layer(state.inject())
.build(job_fn(cleanup_expired_tokens));