|
|
@@ -67,16 +67,21 @@ async fn update_daily_info(db: &Db, distributors: &BTreeMap<BridgeDistributor, S
|
|
|
|
|
|
async fn create_context_manager(
|
|
|
db_config: DbConfig,
|
|
|
+ distributors: BTreeMap<BridgeDistributor, String>,
|
|
|
context_rx: mpsc::Receiver<Command>,
|
|
|
mut kill: broadcast::Receiver<()>,
|
|
|
) {
|
|
|
tokio::select! {
|
|
|
- create_context = context_manager(db_config, context_rx) => create_context,
|
|
|
+ create_context = context_manager(db_config, distributors, context_rx) => create_context,
|
|
|
_ = kill.recv() => {println!("Shut down manager");},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async fn context_manager(db_config: DbConfig, mut context_rx: mpsc::Receiver<Command>) {
|
|
|
+async fn context_manager(
|
|
|
+ db_config: DbConfig,
|
|
|
+ distributors: BTreeMap<BridgeDistributor, String>,
|
|
|
+ mut context_rx: mpsc::Receiver<Command>,
|
|
|
+) {
|
|
|
let db: Db = sled::open(&db_config.db_path).unwrap();
|
|
|
|
|
|
while let Some(cmd) = context_rx.recv().await {
|
|
|
@@ -94,6 +99,9 @@ async fn context_manager(db_config: DbConfig, mut context_rx: mpsc::Receiver<Com
|
|
|
drop(shutdown_sig);
|
|
|
println!("Shutdown Sent.");
|
|
|
}
|
|
|
+ Update {} => {
|
|
|
+ update_daily_info(&db, &distributors).await;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -108,6 +116,7 @@ enum Command {
|
|
|
Shutdown {
|
|
|
shutdown_sig: broadcast::Sender<()>,
|
|
|
},
|
|
|
+ Update {},
|
|
|
}
|
|
|
|
|
|
#[tokio::main]
|
|
|
@@ -149,8 +158,9 @@ async fn main() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- let context_manager =
|
|
|
- spawn(async move { create_context_manager(config.db, request_rx, kill).await });
|
|
|
+ let context_manager = spawn(async move {
|
|
|
+ create_context_manager(config.db, config.distributors, request_rx, kill).await
|
|
|
+ });
|
|
|
|
|
|
let make_service = make_service_fn(move |_conn: &AddrStream| {
|
|
|
let request_tx = request_tx.clone();
|