From a9e0bd0c3971df5929d911a899f5378b38436f19 Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Tue, 19 Nov 2024 14:57:30 +0100 Subject: [PATCH] target app configurable, default focus --- README.md | 4 +++- src/beam.rs | 3 ++- src/config.rs | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 18e8c12..bb54941 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Spot can be run locally with the provided [docker-compose](./docker-compose.yml) Spot can also be run from command line stating command line parameters, like so: ```bash -cargo run -- --beam-proxy-url http://localhost:8081 --beam-app-id app1.proxy1.broker --beam-secret App1Secret --cors-origin any --bind-addr 127.0.0.1:8055 --catalogue-url https://raw.githubusercontent.com/samply/lens/main/packages/demo/public/catalogues/catalogue-dktk.json +cargo run -- --beam-proxy-url http://localhost:8081 --beam-app-id app1.proxy1.broker --beam-secret App1Secret --cors-origin any --bind-addr 127.0.0.1:8055 --catalogue-url https://raw.githubusercontent.com/samply/lens/main/packages/demo/public/catalogues/catalogue-dktk.json --target app1 ``` The following environment variables are mandatory for the usage of Spot. @@ -32,6 +32,8 @@ Optional environment variables: URL to prism, if catalogue-url is not stated, this is never used [env: PRISM_URL=] [default: http://localhost:8066] --bind-addr The socket address this server will bind to [env: BIND_ADDR=] [default: 0.0.0.0:8055] +--target + Target_application_name [env: TARGET=] [default: focus] ``` ## API diff --git a/src/beam.rs b/src/beam.rs index f2f5674..8e1c6e5 100644 --- a/src/beam.rs +++ b/src/beam.rs @@ -6,9 +6,10 @@ pub fn create_beam_task( target_sites: Vec, query: String, ) -> TaskRequest { + let target = &CONFIG.target; 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(); + let to = target_sites.into_iter().map(|site| AppId::new_unchecked(format!("{target}.{site}.{broker_id}"))).collect(); let metadata = if let Some(project) = &CONFIG.project { serde_json::json!({ "project": project diff --git a/src/config.rs b/src/config.rs index e742fb3..302341d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,7 +2,7 @@ use std::{convert::Infallible, net::SocketAddr, path::PathBuf}; use beam_lib::AppId; use clap::Parser; -use reqwest::{Url, header::InvalidHeaderValue}; +use reqwest::{header::InvalidHeaderValue, Url}; use tower_http::cors::AllowOrigin; #[derive(Parser, Clone, Debug)] @@ -37,12 +37,16 @@ pub struct Config { pub catalogue_url: Option, /// URL to prism - #[clap(long, env, default_value= "http://localhost:8066")] + #[clap(long, env, default_value = "http://localhost:8066")] pub prism_url: Url, /// Path to a file which will contain the query logs #[clap(long, env, value_hint = clap::ValueHint::FilePath)] pub log_file: Option, + + /// Target_application_name + #[clap(long, env, value_parser, default_value = "focus")] + pub target: String, } fn parse_cors(v: &str) -> Result {