1
0
mirror of https://github.com/bitwarden/server synced 2026-02-18 18:33:29 +00:00

Start scaffolding hosting applications

This commit is contained in:
Matt Gibson
2025-11-04 09:14:25 -08:00
parent ab1eaddb18
commit f2136bb809
13 changed files with 241 additions and 11 deletions

View File

@@ -0,0 +1,21 @@
use std::sync::Arc;
use akd::{directory::ReadOnlyDirectory, storage::StorageManager};
use tracing::instrument;
use bitwarden_akd_configuration::BitwardenV1Configuration;
use akd_storage::DatabaseType;
use common::VrfStorageType;
struct AppState {
// Add any shared state here, e.g., database connections
directory: ReadOnlyDirectory<BitwardenV1Configuration, DatabaseType, VrfStorageType>,
}
#[instrument(skip_all, name = "reader_start")]
pub async fn start(db: DatabaseType, vrf: VrfStorageType) {
let storage_manager = StorageManager::new_no_cache(db);
let _app = AppState {
directory: ReadOnlyDirectory::new(storage_manager, vrf).await.unwrap(),
};
println!("Reader started");
}

View File

@@ -0,0 +1,40 @@
//! The Reader crate is responsible for handling read requests to the AKD. It requires only read permissions to the
//! underlying data stores, and can be horizontally scaled as needed.
use akd::ecvrf::VRFKeyStorage;
use akd_storage::db_config::DbConfig;
use common::VrfStorageType;
use reader::start;
use tracing::info;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
// Read connection string from env var
let connection_string = std::env::var("AKD_MSSQL_CONNECTION_STRING")
.expect("AKD_MSSQL_CONNECTION_STRING must be set.");
let db_config = DbConfig::MsSql {
connection_string,
pool_size: 10,
};
let db = db_config
.connect()
.await
.expect("Failed to connect to database");
let vrf = VrfStorageType::HardCodedAkdVRF;
let web_server_handle = tokio::spawn(async move {
start(db, vrf).await;
});
// Wait for both services to complete
tokio::select! {
_ = web_server_handle => {
info!("Web service completed");
}
}
}