You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
Extract the job tracing span logic to a layer
This commit is contained in:
@ -22,6 +22,10 @@ use mas_handlers::{AppState, HttpClientFactory, MatrixHomeserver};
|
||||
use mas_listener::{server::Server, shutdown::ShutdownStream};
|
||||
use mas_router::UrlBuilder;
|
||||
use mas_storage_pg::MIGRATOR;
|
||||
use rand::{
|
||||
distributions::{Alphanumeric, DistString},
|
||||
thread_rng,
|
||||
};
|
||||
use tokio::signal::unix::SignalKind;
|
||||
use tracing::{info, info_span, warn, Instrument};
|
||||
|
||||
@ -52,7 +56,7 @@ impl Options {
|
||||
let config: RootConfig = root.load_config()?;
|
||||
|
||||
// Connect to the database
|
||||
info!("Conntecting to the database");
|
||||
info!("Connecting to the database");
|
||||
let pool = database_from_config(&config.database).await?;
|
||||
|
||||
if self.migrate {
|
||||
@ -87,8 +91,12 @@ impl Options {
|
||||
let mailer = mailer_from_config(&config.email, &templates).await?;
|
||||
mailer.test_connection().await?;
|
||||
|
||||
info!("Starting task worker");
|
||||
let monitor = mas_tasks::init(&pool, &mailer);
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
let mut rng = thread_rng();
|
||||
let worker_name = Alphanumeric.sample_string(&mut rng, 10);
|
||||
|
||||
info!(worker_name, "Starting task worker");
|
||||
let monitor = mas_tasks::init(&worker_name, &pool, &mailer);
|
||||
// TODO: grab the handle
|
||||
tokio::spawn(monitor.run());
|
||||
}
|
||||
|
@ -15,7 +15,11 @@
|
||||
use clap::Parser;
|
||||
use mas_config::RootConfig;
|
||||
use mas_router::UrlBuilder;
|
||||
use tracing::{info_span, log::info};
|
||||
use rand::{
|
||||
distributions::{Alphanumeric, DistString},
|
||||
thread_rng,
|
||||
};
|
||||
use tracing::{info, info_span};
|
||||
|
||||
use crate::util::{database_from_config, mailer_from_config, templates_from_config};
|
||||
|
||||
@ -28,7 +32,7 @@ impl Options {
|
||||
let config: RootConfig = root.load_config()?;
|
||||
|
||||
// Connect to the database
|
||||
info!("Conntecting to the database");
|
||||
info!("Connecting to the database");
|
||||
let pool = database_from_config(&config.database).await?;
|
||||
|
||||
let url_builder = UrlBuilder::new(config.http.public_base.clone());
|
||||
@ -40,8 +44,12 @@ impl Options {
|
||||
mailer.test_connection().await?;
|
||||
drop(config);
|
||||
|
||||
info!("Starting task scheduler");
|
||||
let monitor = mas_tasks::init(&pool, &mailer);
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
let mut rng = thread_rng();
|
||||
let worker_name = Alphanumeric.sample_string(&mut rng, 10);
|
||||
|
||||
info!(worker_name, "Starting task scheduler");
|
||||
let monitor = mas_tasks::init(&worker_name, &pool, &mailer);
|
||||
|
||||
span.exit();
|
||||
|
||||
|
Reference in New Issue
Block a user