Add more instrument macros
This commit is contained in:
parent
5bdf8d0f2d
commit
d37c09d8d9
2 changed files with 9 additions and 0 deletions
|
@ -76,6 +76,7 @@ impl UserAuthenticator {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ServerPadlockGenerator {
|
||||
secret: PadlockGenerationSecret,
|
||||
}
|
||||
|
@ -85,11 +86,13 @@ impl ServerPadlockGenerator {
|
|||
todo!()
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
pub fn generate_padlock(&self, server_hash: &ServerHash) -> ServerPadlock {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UserServerKeyGenerator {
|
||||
user_authenticator: Arc<UserAuthenticator>,
|
||||
padlock_generator: Arc<ServerPadlockGenerator>,
|
||||
|
@ -100,6 +103,7 @@ impl UserServerKeyGenerator {
|
|||
todo!()
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
pub async fn generate_user_server_key(
|
||||
&self,
|
||||
username: &str,
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::str::FromStr;
|
|||
|
||||
use secrecy::ExposeSecret;
|
||||
use sqlx::{query, query_as, sqlite::SqliteConnectOptions, Connection, SqliteConnection};
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::secrets::UserToken;
|
||||
|
||||
|
@ -22,6 +23,7 @@ pub struct SqliteDatabase {
|
|||
}
|
||||
|
||||
impl SqliteDatabase {
|
||||
#[instrument]
|
||||
pub async fn open() -> Self {
|
||||
let options = SqliteConnectOptions::from_str(DB_URI_DEFAULT)
|
||||
.expect("Invalid database URI")
|
||||
|
@ -38,6 +40,7 @@ impl SqliteDatabase {
|
|||
db
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
pub async fn init(&mut self) {
|
||||
query(&format!(
|
||||
"CREATE TABLE IF NOT EXISTS {TABLE_USER_TOKENS} (
|
||||
|
@ -56,6 +59,7 @@ impl SqliteDatabase {
|
|||
}
|
||||
|
||||
impl Database for SqliteDatabase {
|
||||
#[instrument]
|
||||
async fn get_token(&mut self, username: &str) -> Result<Option<UserToken>, sqlx::Error> {
|
||||
let row: Option<(String,)> = query_as(
|
||||
"SELECT token
|
||||
|
@ -73,6 +77,7 @@ impl Database for SqliteDatabase {
|
|||
Ok(row.map(|(token_str, ..)| UserToken::from(token_str)))
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn save_token(&mut self, username: &str, token: &UserToken) -> Result<(), sqlx::Error> {
|
||||
query(&format!(
|
||||
"INSERT INTO {TABLE_USER_TOKENS}
|
||||
|
|
Loading…
Reference in a new issue