Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

refactor(env_vars): add in database_env_vars crate (#4060)

Will Hutchinsonbe1620cbad68
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.json
index 3b20748af8..d5d6d020ee 100644
--- a/.github/workspace-dep-closures.json
+++ b/.github/workspace-dep-closures.json
@@ -179,6 +179,7 @@
"macro_entrypoint",
"macro_env",
"macro_env_var",
+ "macro_env_vars/database_env_vars",
"macro_middleware",
"macro_redis",
"macro_service_urls",
@@ -772,6 +773,7 @@
"macro_entrypoint",
"macro_env",
"macro_env_var",
+ "macro_env_vars/database_env_vars",
"macro_middleware",
"macro_service_urls",
"macro_user_id",
@@ -885,6 +887,11 @@
"unfurl",
"workspace-hack"
],
+ "database_env_vars": [
+ "macro_env_var",
+ "macro_env_vars/database_env_vars",
+ "workspace-hack"
+ ],
"dataloss_prevention_handler": [
"dataloss_prevention_handler",
"macro_aws_config",
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index f45e140097..06d4f0264a 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -675,6 +675,7 @@ dependencies = [
"comms_db_client",
"cookie",
"cool_asserts",
+ "database_env_vars",
"document_storage_service_client",
"doppleganger",
"doppler-config",
@@ -2598,6 +2599,7 @@ dependencies = [
"aws-sdk-sqs",
"axum",
"contacts",
+ "database_env_vars",
"http-body-util",
"macro_auth",
"macro_aws_config",
@@ -3119,6 +3121,15 @@ version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
+[[package]]
+name = "database_env_vars"
+version = "0.1.0"
+dependencies = [
+ "macro_env_var",
+ "tracing",
+ "workspace-hack",
+]
+
[[package]]
name = "dataloss_prevention_handler"
version = "0.1.0"
diff --git a/rust/cloud-storage/authentication_service/Cargo.toml b/rust/cloud-storage/authentication_service/Cargo.toml
index 3dadc39b4c..ccb635e369 100644
--- a/rust/cloud-storage/authentication_service/Cargo.toml
+++ b/rust/cloud-storage/authentication_service/Cargo.toml
@@ -130,6 +130,7 @@ utoipa-swagger-ui = { workspace = true }
uuid = { workspace = true }
doppler-config = { workspace = true }
workspace-hack = { version = "0.1", path = "../workspace-hack" }
+database_env_vars = { path = "../macro_env_vars/database_env_vars" }
[dev-dependencies]
cool_asserts = "2"
diff --git a/rust/cloud-storage/authentication_service/src/config.rs b/rust/cloud-storage/authentication_service/src/config.rs
index 6f8fc4bbbd..4db6cc2ef7 100644
--- a/rust/cloud-storage/authentication_service/src/config.rs
+++ b/rust/cloud-storage/authentication_service/src/config.rs
@@ -1,6 +1,7 @@
use std::sync::LazyLock;
use anyhow::Context;
+use database_env_vars::{DatabaseUrl, RedisUri};
pub use macro_env::Environment;
use macro_env_var::{env_vars, maybe_env_vars};
@@ -12,8 +13,6 @@ pub static BASE_URL: LazyLock<String> = LazyLock::new(|| {
env_vars! {
pub struct BaseUrl;
- pub struct DatabaseUrl;
- pub struct RedisUri;
pub struct FusionAuthTenantId;
pub struct FusionAuthApiSecretKey;
pub struct FusionAuthClientId;
diff --git a/rust/cloud-storage/contacts_service/Cargo.toml b/rust/cloud-storage/contacts_service/Cargo.toml
index bac2698c29..bc61ddeac0 100644
--- a/rust/cloud-storage/contacts_service/Cargo.toml
+++ b/rust/cloud-storage/contacts_service/Cargo.toml
@@ -44,6 +44,7 @@ macro_service_urls = { path = "../macro_service_urls" }
workspace-hack = { version = "0.1", path = "../workspace-hack" }
macro_env_var = { path = "../macro_env_var" }
macro_config = { path = "../macro_config" }
+database_env_vars = { path = "../macro_env_vars/database_env_vars" }
[features]
mock = []
diff --git a/rust/cloud-storage/contacts_service/src/config.rs b/rust/cloud-storage/contacts_service/src/config.rs
index a0b6371899..3200e99ea0 100644
--- a/rust/cloud-storage/contacts_service/src/config.rs
+++ b/rust/cloud-storage/contacts_service/src/config.rs
@@ -1,11 +1,10 @@
use anyhow::Context;
+use database_env_vars::{DatabaseUrl, RedisUri};
pub use macro_env::Environment;
use macro_env_var::{env_vars, maybe_env_vars};
env_vars! {
pub struct BaseUrl;
- pub struct DatabaseUrl;
- pub struct RedisUri;
pub struct ContactsQueue;
}
@@ -47,8 +46,8 @@ impl Config {
Config {
port: 0,
environment: Environment::Local,
- database_url: DatabaseUrl::new_testing(""),
- redis_uri: RedisUri::new_testing(""),
+ database_url: DatabaseUrl::Comptime(""),
+ redis_uri: RedisUri::Comptime(""),
contacts_queue: ContactsQueue::new_testing(""),
contacts_queue_max_messages: ContactsQueueMaxMessages::new_unset(),
contacts_queue_wait_time_seconds: ContactsQueueWaitTimeSeconds::new_unset(),
diff --git a/rust/cloud-storage/macro_env_vars/database_env_vars/Cargo.toml b/rust/cloud-storage/macro_env_vars/database_env_vars/Cargo.toml
new file mode 100644
index 0000000000..9af54f7242
--- /dev/null
+++ b/rust/cloud-storage/macro_env_vars/database_env_vars/Cargo.toml
@@ -0,0 +1,10 @@
+[package]
+edition = "2024"
+name = "database_env_vars"
+publish = false
+version = "0.1.0"
+
+[dependencies]
+tracing = { workspace = true }
+macro_env_var = { path = "../../macro_env_var" }
+workspace-hack = { version = "0.1", path = "../../workspace-hack" }
diff --git a/rust/cloud-storage/macro_env_vars/database_env_vars/src/lib.rs b/rust/cloud-storage/macro_env_vars/database_env_vars/src/lib.rs
new file mode 100644
index 0000000000..d64ddd062e
--- /dev/null
+++ b/rust/cloud-storage/macro_env_vars/database_env_vars/src/lib.rs
@@ -0,0 +1,14 @@
+//! This crate contains the macro_env_var structs for our databases.
+//! This allows us to standardize how we configure a service to use these databases.
+//! Each value in this crate should match the key name of the environment variable you provide in
+//! the doppler configuration.
+#![deny(missing_docs)]
+
+use macro_env_var::env_vars;
+
+env_vars! {
+/// MacroDB database url
+pub struct DatabaseUrl;
+/// MacroCache redis uri
+pub struct RedisUri;
+}