diff --git a/CHANGELOG.md b/CHANGELOG.md index 9069fe1..8f41ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Samply.Focus v0.7.0 2024-09-24 +In this release, we are extending the supported data backends beyond CQL-enabled FHIR stores. We now support PostgreSQL as well. Usage instructions are included in the Readme. + ## Major changes * PostgreSQL support added diff --git a/README.md b/README.md index 4d10240..b8960fd 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ In order to use Postgres querying, a Docker image built with the feature "dktk" POSTGRES_CONNECTION_STRING = "postgresql://postgres:Test.123@localhost:5432/postgres" # Postgres connection string ``` +Additionally when using Postgres this optional variable can be set: +```bash +MAX_DB_ATTEMPTS = "8" # Max number of attempts to connect to the database, default value: 8 +``` + Obfuscating zero counts is by default switched off. To enable obfuscating zero counts, set the env. variable `OBFUSCATE_ZERO`. Optionally, you can provide the `TLS_CA_CERTIFICATES_DIR` environment variable to add additional trusted certificates, e.g., if you have a TLS-terminating proxy server in place. The application respects the `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY`, and their respective lowercase equivalents. @@ -85,7 +90,7 @@ Creating a sample task containing an abstract syntax tree (AST) query using curl curl -v -X POST -H "Content-Type: application/json" --data '{"id":"7fffefff-ffef-fcff-feef-feffffffffff","from":"app1.proxy1.broker","to":["app1.proxy1.broker"],"ttl":"10s","failure_strategy":{"retry":{"backoff_millisecs":1000,"max_tries":5}},"metadata":{"project":"bbmri"},"body":"eyJsYW5nIjoiYXN0IiwicGF5bG9hZCI6ImV5SmhjM1FpT25zaWIzQmxjbUZ1WkNJNklrOVNJaXdpWTJocGJHUnlaVzRpT2x0N0ltOXdaWEpoYm1RaU9pSkJUa1FpTENKamFHbHNaSEpsYmlJNlczc2liM0JsY21GdVpDSTZJazlTSWl3aVkyaHBiR1J5Wlc0aU9sdDdJbXRsZVNJNkltZGxibVJsY2lJc0luUjVjR1VpT2lKRlVWVkJURk1pTENKemVYTjBaVzBpT2lJaUxDSjJZV3gxWlNJNkltMWhiR1VpZlN4N0ltdGxlU0k2SW1kbGJtUmxjaUlzSW5SNWNHVWlPaUpGVVZWQlRGTWlMQ0p6ZVhOMFpXMGlPaUlpTENKMllXeDFaU0k2SW1abGJXRnNaU0o5WFgxZGZWMTlMQ0pwWkNJNkltRTJaakZqWTJZekxXVmlaakV0TkRJMFppMDVaRFk1TFRSbE5XUXhNelZtTWpNME1DSjkifQ=="}' -H "Authorization: ApiKey app1.proxy1.broker App1Secret" http://localhost:8081/v1/tasks ``` -Creating a sample SQL task for a `SELECT_TABLES` query using curl: +Creating a sample SQL task for a `SELECT_TEST` query using curl: ```bash curl -v -X POST -H "Content-Type: application/json" --data '{"id":"7fffefff-ffef-fcff-feef-feffffffffff","from":"app1.proxy1.broker","to":["app1.proxy1.broker"],"ttl":"10s","failure_strategy":{"retry":{"backoff_millisecs":1000,"max_tries":5}},"metadata":{"project":"exliquid"},"body":"eyJwYXlsb2FkIjoiU0VMRUNUX1RBQkxFUyJ9"}' -H "Authorization: ApiKey app1.proxy1.broker App1Secret" http://localhost:8081/v1/tasks ``` diff --git a/src/config.rs b/src/config.rs index 8c05727..d45a408 100644 --- a/src/config.rs +++ b/src/config.rs @@ -162,10 +162,15 @@ struct CliArgs { #[clap(long, env, value_parser)] auth_header: Option, - /// Database connection string + /// Postgres connection string #[cfg(feature = "query-sql")] #[clap(long, env, value_parser)] postgres_connection_string: Option, + + /// Max number of attempts to connect to the database + #[cfg(feature = "query-sql")] + #[clap(long, env, value_parser, default_value = "8")] + max_db_attempts: u32, } pub(crate) struct Config { @@ -195,6 +200,8 @@ pub(crate) struct Config { pub auth_header: Option, #[cfg(feature = "query-sql")] pub postgres_connection_string: Option, + #[cfg(feature = "query-sql")] + pub max_db_attempts: u32, } impl Config { @@ -238,6 +245,8 @@ impl Config { auth_header: cli_args.auth_header, #[cfg(feature = "query-sql")] postgres_connection_string: cli_args.postgres_connection_string, + #[cfg(feature = "query-sql")] + max_db_attempts: cli_args.max_db_attempts, client, }; Ok(config) diff --git a/src/main.rs b/src/main.rs index 77ef6da..eac421c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,7 +133,7 @@ async fn get_db_pool() -> Result,ExitCode> { #[cfg(feature = "query-sql")] async fn get_db_pool() -> Result,ExitCode> { if let Some(connection_string) = CONFIG.postgres_connection_string.clone() { - match db::get_pg_connection_pool(&connection_string, 8).await { + match db::get_pg_connection_pool(&connection_string, CONFIG.max_db_attempts).await { Err(e) => { error!("Error connecting to database: {}", e); Err(ExitCode::from(8))