diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0048c0e --- /dev/null +++ b/.vscode/launch.json @@ -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}" + } + ] +} \ No newline at end of file diff --git a/src/beam.rs b/src/beam.rs index 4ca21c0..87d31b1 100644 --- a/src/beam.rs +++ b/src/beam.rs @@ -195,7 +195,7 @@ pub async fn retrieve_tasks() -> Result, 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: {}", @@ -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: {}", @@ -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) -> 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: {}", diff --git a/src/config.rs b/src/config.rs index 16042bd..3a241bb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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)] @@ -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, @@ -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, diff --git a/src/main.rs b/src/main.rs index efa17b9..37bcb3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,7 @@ async fn run_query(task: &BeamTask, query: &Query) -> Result Result Result { 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(), @@ -206,7 +206,7 @@ fn beam_result( ) -> Result { 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,