Page MenuHomePhabricator

No OneTemporary

diff --git a/services/tunnelbroker/src/database.rs b/services/tunnelbroker/src/database.rs
new file mode 100644
index 000000000..3d77801a3
--- /dev/null
+++ b/services/tunnelbroker/src/database.rs
@@ -0,0 +1,18 @@
+use aws_config::SdkConfig;
+use aws_sdk_dynamodb::Client;
+use std::sync::Arc;
+
+#[derive(Clone)]
+pub struct DatabaseClient {
+ client: Arc<Client>,
+}
+
+impl DatabaseClient {
+ pub fn new(aws_config: &SdkConfig) -> Self {
+ let client = Client::new(aws_config);
+
+ DatabaseClient {
+ client: Arc::new(client),
+ }
+ }
+}
diff --git a/services/tunnelbroker/src/main.rs b/services/tunnelbroker/src/main.rs
index bbda76dc9..8f2cebd98 100644
--- a/services/tunnelbroker/src/main.rs
+++ b/services/tunnelbroker/src/main.rs
@@ -1,41 +1,44 @@
pub mod config;
pub mod constants;
+pub mod database;
pub mod grpc;
pub mod websockets;
+
use anyhow::{anyhow, Result};
use config::CONFIG;
use dashmap::DashMap;
use once_cell::sync::Lazy;
use tokio::sync::mpsc::UnboundedSender;
use tracing::{self, Level};
use tracing_subscriber::EnvFilter;
pub static ACTIVE_CONNECTIONS: Lazy<DashMap<String, UnboundedSender<String>>> =
Lazy::new(DashMap::new);
#[tokio::main]
async fn main() -> Result<()> {
let filter = EnvFilter::builder()
.with_default_directive(Level::INFO.into())
.with_env_var(constants::LOG_LEVEL_ENV_VAR)
.from_env_lossy();
let subscriber = tracing_subscriber::fmt().with_env_filter(filter).finish();
tracing::subscriber::set_global_default(subscriber)
.expect("Unable to configure tracing");
config::parse_cmdline_args()?;
- let _aws_config = config::load_aws_config().await;
+ let aws_config = config::load_aws_config().await;
+ let _db_client = database::DatabaseClient::new(&aws_config);
let grpc_server = grpc::run_server();
let websocket_server = websockets::run_server();
tokio::select! {
Ok(_) = grpc_server => { Ok(()) },
Ok(_) = websocket_server => { Ok(()) },
else => {
tracing::error!("A grpc or websocket server crashed.");
Err(anyhow!("A grpc or websocket server crashed."))
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 23, 7:08 AM (1 d, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690531
Default Alt Text
(2 KB)

Event Timeline