tuwunel_admin/query/
globals.rs1use clap::Subcommand;
2use ruma::OwnedServerName;
3use tuwunel_core::Result;
4
5use crate::Context;
6
7#[derive(Debug, Subcommand)]
8pub(crate) enum GlobalsCommand {
10 DatabaseVersion,
11
12 CurrentCount,
13
14 SigningKeysFor {
17 origin: OwnedServerName,
18 },
19}
20
21pub(super) async fn process(subcommand: GlobalsCommand, context: &Context<'_>) -> Result {
23 let services = context.services;
24
25 match subcommand {
26 | GlobalsCommand::DatabaseVersion => {
27 let timer = tokio::time::Instant::now();
28 let results = services.globals.db.database_version().await;
29 let query_time = timer.elapsed();
30
31 write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
32 },
33 | GlobalsCommand::CurrentCount => {
34 let timer = tokio::time::Instant::now();
35 let results = services.globals.current_count();
36 let query_time = timer.elapsed();
37
38 write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
39 },
40 | GlobalsCommand::SigningKeysFor { origin } => {
41 let timer = tokio::time::Instant::now();
42 let results = services
43 .server_keys
44 .verify_keys_for(&origin)
45 .await;
46 let query_time = timer.elapsed();
47
48 write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
49 },
50 }
51 .await
52}