Skip to content

Commit

Permalink
target app configurable, default focus
Browse files Browse the repository at this point in the history
  • Loading branch information
enola-dkfz committed Nov 19, 2024
1 parent 38cb5b1 commit a9e0bd0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <BIND_ADDR>
The socket address this server will bind to [env: BIND_ADDR=] [default: 0.0.0.0:8055]
--target <TARGET>
Target_application_name [env: TARGET=] [default: focus]
```

## API
Expand Down
3 changes: 2 additions & 1 deletion src/beam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ pub fn create_beam_task(
target_sites: Vec<String>,
query: String,
) -> TaskRequest<RawString> {
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
Expand Down
8 changes: 6 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -37,12 +37,16 @@ pub struct Config {
pub catalogue_url: Option<Url>,

/// 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<PathBuf>,

/// Target_application_name
#[clap(long, env, value_parser, default_value = "focus")]
pub target: String,
}

fn parse_cors(v: &str) -> Result<AllowOrigin, InvalidHeaderValue> {
Expand Down

0 comments on commit a9e0bd0

Please sign in to comment.