From 0d0d078d019e70bdab8ac18f247793e494490828 Mon Sep 17 00:00:00 2001 From: janskiba Date: Fri, 10 Nov 2023 11:52:53 +0000 Subject: [PATCH] Change config var names --- env.default | 5 +++-- src/beam.rs | 4 ++-- src/main.rs | 18 +++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/env.default b/env.default index 0b08855..11902c0 100644 --- a/env.default +++ b/env.default @@ -2,7 +2,8 @@ ## You need to register at a broker for this BROKER_ID=broker PROXY_ID=proxy1.$BROKER_ID -PROXY_URL=http://localhost:8081 +BEAM_PROXY_URL=http://localhost:8081 ## You can change these as you want, because their local secrets BEAM_APP_ID=app1.$PROXY_ID -BEAM_APP_SECRET=App1Secret +BEAM_SECRET=App1Secret +BIND_ADDR=0.0.0.0:8090 diff --git a/src/beam.rs b/src/beam.rs index 420c38b..6e95683 100644 --- a/src/beam.rs +++ b/src/beam.rs @@ -6,12 +6,12 @@ pub fn create_beam_task( target_sites: Vec, query: String, ) -> TaskRequest { - let proxy_id = CONFIG.beam_app.proxy_id(); + let proxy_id = CONFIG.beam_app_id.proxy_id(); let broker_id = proxy_id.as_ref().split_once('.').expect("Invalid beam id in config").1; let to = target_sites.into_iter().map(|site| AppId::new_unchecked(format!("focus.{site}.{broker_id}"))).collect(); TaskRequest { id, - from: CONFIG.beam_app.clone(), + from: CONFIG.beam_app_id.clone(), to, metadata: serde_json::Value::Null, body: query.into(), diff --git a/src/main.rs b/src/main.rs index 6085fce..2f9e2da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,19 +24,19 @@ mod beam; #[clap(author, version, about, long_about = None)] struct Config { /// URL of the Beam Proxy - #[clap(env)] - beam_url: Url, + #[clap(long, env)] + beam_proxy_url: Url, /// Beam AppId of this application - #[clap(env, value_parser = |v: &str| Ok::<_, Infallible>(AppId::new_unchecked(v)))] - beam_app: AppId, + #[clap(long, env, value_parser = |v: &str| Ok::<_, Infallible>(AppId::new_unchecked(v)))] + beam_app_id: AppId, /// Credentials to use on the Beam Proxy - #[clap(env)] + #[clap(long, env)] beam_secret: String, /// The socket address this server will bind to - #[clap(env, default_value = "0.0.0.0:8080")] + #[clap(long, env, default_value = "0.0.0.0:8080")] bind_addr: SocketAddr, } @@ -44,9 +44,9 @@ static CONFIG: Lazy = Lazy::new(|| Config::parse()); static BEAM_CLIENT: Lazy = Lazy::new(|| { BeamClient::new( - &CONFIG.beam_app, + &CONFIG.beam_app_id, &CONFIG.beam_secret, - CONFIG.beam_url.clone(), + CONFIG.beam_proxy_url.clone(), ) }); @@ -122,7 +122,7 @@ async fn handle_listen_to_beam_tasks( .send() .await .map_err(|err| { - println!("Failed request to {} with error: {}", CONFIG.beam_url, err); + println!("Failed request to {} with error: {}", CONFIG.beam_proxy_url, err); ( StatusCode::BAD_GATEWAY, format!("Error calling beam, check the server logs."),