Skip to content

Commit

Permalink
app name param name changed to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
enola-dkfz committed Mar 23, 2023
1 parent 59fc52f commit 41788e0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 12 deletions.
59 changes: 59 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'focus'",
"cargo": {
"args": [
"run",
"--bin=focus",
"--package=focus"
],
"filter": {
"name": "focus",
"kind": "bin"
}
},
"args": [
"--beam-proxy-url=http://localhost:8081/",
"--beam-app-id=app1.proxy1.broker",
"--api-key=App1Secret",
"--retry-count=5",
"--blaze-url=http://localhost:8089/fhir/"
],
"env": {
"BEAM_PROXY_URL": "http://localhost:8081",
"BLAZE_URL": "http://localhost:8089/fhir",
"PROXY_ID": "proxy1.broker",
"API_KEY": "App1Secret",
"BEAM_APP_ID_LONG": "app1.proxy1.broker",
"RETRY_COUNT": "5",
},
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'focus'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=focus",
"--package=focus"
],
"filter": {
"name": "focus",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
12 changes: 6 additions & 6 deletions src/beam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub async fn retrieve_tasks() -> Result<Vec<BeamTask>, FocusError> {
let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id, CONFIG.api_key))
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id_long, CONFIG.api_key))
.map_err(|e| {
FocusError::ConfigurationError(format!(
"Cannot assemble authorization header: {}",
Expand Down Expand Up @@ -238,13 +238,13 @@ pub async fn answer_task(task: &BeamTask, result: &BeamResult) -> Result<(), Foc
let result_task = result.task;
let url = format!(
"{}v1/tasks/{}/results/{}",
CONFIG.beam_proxy_url, &result_task, CONFIG.beam_app_id
CONFIG.beam_proxy_url, &result_task, CONFIG.beam_app_id_long
);

let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id, CONFIG.api_key))
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id_long, CONFIG.api_key))
.map_err(|e| {
FocusError::ConfigurationError(format!(
"Cannot assemble authorization header: {}",
Expand Down Expand Up @@ -285,16 +285,16 @@ pub async fn answer_task(task: &BeamTask, result: &BeamResult) -> Result<(), Foc
pub async fn fail_task(task: &BeamTask, body: impl Into<String>) -> Result<(), FocusError> {
let body = body.into();
warn!("Reporting failed task with id {}: {}", task.id, body);
let result = BeamResult::perm_failed(CONFIG.beam_app_id.clone(), vec![task.from.clone()], task.id, body);
let result = BeamResult::perm_failed(CONFIG.beam_app_id_long.clone(), vec![task.from.clone()], task.id, body);
let url = format!(
"{}v1/tasks/{}/results/{}",
CONFIG.beam_proxy_url, task.id, CONFIG.beam_app_id
CONFIG.beam_proxy_url, task.id, CONFIG.beam_app_id_long
);

let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id, CONFIG.api_key))
HeaderValue::from_str(&format!("ApiKey {} {}", CONFIG.beam_app_id_long, CONFIG.api_key))
.map_err(|e| {
FocusError::ConfigurationError(format!(
"Cannot assemble authorization header: {}",
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct CliArgs {

/// This application's beam AppId, e.g. focus.proxy1.broker.samply.de
#[clap(long, env, value_parser)]
beam_app_id: String,
beam_app_id_long: String,

/// This applications beam API key
#[clap(long, env, value_parser)]
Expand All @@ -49,7 +49,7 @@ struct CliArgs {

pub(crate) struct Config {
pub beam_proxy_url: Uri,
pub beam_app_id: AppId,
pub beam_app_id_long: AppId,
pub api_key: String,
pub retry_count: usize,
pub blaze_url: Uri,
Expand All @@ -67,7 +67,7 @@ impl Config {
let client = prepare_reqwest_client(&tls_ca_certificates)?;
let config = Config {
beam_proxy_url: cli_args.beam_proxy_url,
beam_app_id: AppId::new(cli_args.beam_app_id)?,
beam_app_id_long: AppId::new(cli_args.beam_app_id_long)?,
api_key: cli_args.api_key,
retry_count: cli_args.retry_count,
blaze_url: cli_args.blaze_url,
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn run_query(task: &BeamTask, query: &Query) -> Result<BeamResult, FocusEr
return Ok(run_cql_query(task, query).await)?;
} else {
return Ok(beam::BeamResult::perm_failed(
CONFIG.beam_app_id.clone(),
CONFIG.beam_app_id_long.clone(),
vec![task.from.clone()],
task.id,
format!("Can't run inqueries with language {}", query.lang),
Expand All @@ -141,7 +141,7 @@ async fn run_query(task: &BeamTask, query: &Query) -> Result<BeamResult, FocusEr

async fn run_cql_query(task: &BeamTask, query: &Query) -> Result<BeamResult, FocusError> {
let mut err = beam::BeamResult::perm_failed(
CONFIG.beam_app_id.clone(),
CONFIG.beam_app_id_long.clone(),
vec![task.to_owned().from],
task.to_owned().id,
String::new(),
Expand Down Expand Up @@ -206,7 +206,7 @@ fn beam_result(
) -> Result<beam::BeamResult, FocusError> {
let data = general_purpose::STANDARD.encode(measure_report.as_bytes());
return Ok(beam::BeamResult::succeeded(
CONFIG.beam_app_id.clone(),
CONFIG.beam_app_id_long.clone(),
vec![task.from],
task.id,
data,
Expand Down

0 comments on commit 41788e0

Please sign in to comment.