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.

feat(document_storage_service): move to macro config (#4121)

Will Hutchinsona988e7216652
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.json
index 7603e0b088..d2f63ae671 100644
--- a/.github/workspace-dep-closures.json
+++ b/.github/workspace-dep-closures.json
@@ -1125,6 +1125,8 @@
"macro_auth",
"macro_aws_config",
"macro_axum_utils",
+ "macro_config",
+ "macro_config_derive",
"macro_cors",
"macro_db_client",
"macro_entrypoint",
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index f54cf6ffbe..d61e584955 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -3606,6 +3606,7 @@ dependencies = [
"macro_auth",
"macro_aws_config",
"macro_axum_utils",
+ "macro_config",
"macro_cors",
"macro_db_client",
"macro_entrypoint",
diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.toml
index 647f334511..51b6b3e57b 100644
--- a/rust/cloud-storage/document_storage_service/Cargo.toml
+++ b/rust/cloud-storage/document_storage_service/Cargo.toml
@@ -149,6 +149,7 @@ utoipa-swagger-ui = { workspace = true, features = ["axum"] }
uuid = { workspace = true }
zip = { workspace = true }
workspace-hack = { version = "0.1", path = "../workspace-hack" }
+macro_config = { path = "../macro_config" }
[dev-dependencies]
cool_asserts = "2"
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/export_document.rs b/rust/cloud-storage/document_storage_service/src/api/documents/export_document.rs
index 8f8edc7681..6108f59960 100644
--- a/rust/cloud-storage/document_storage_service/src/api/documents/export_document.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/documents/export_document.rs
@@ -204,7 +204,6 @@ async fn sign_docx_url(state: &ApiContext, key: &str) -> anyhow::Result<String>
let signed_options = get_cloudfront_signed_options(
&state
.config
- .vars
.document_storage_service_cloudfront_signer_public_key_id,
state
.config
@@ -218,7 +217,6 @@ async fn sign_docx_url(state: &ApiContext, key: &str) -> anyhow::Result<String>
let signed_url = get_presigned_url(
&state
.config
- .vars
.document_storage_service_cloudfront_distribution_url,
&encoded_key,
&signed_options,
diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/location.rs b/rust/cloud-storage/document_storage_service/src/api/documents/location.rs
index 772f98fa96..9c72628336 100644
--- a/rust/cloud-storage/document_storage_service/src/api/documents/location.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/documents/location.rs
@@ -127,7 +127,6 @@ async fn sign_document_key(
let signed_options = get_cloudfront_signed_options(
&state
.config
- .vars
.document_storage_service_cloudfront_signer_public_key_id,
state
.config
@@ -141,7 +140,6 @@ async fn sign_document_key(
let signed_url = get_presigned_url(
&state
.config
- .vars
.document_storage_service_cloudfront_distribution_url,
signed_key,
&signed_options,
@@ -229,7 +227,6 @@ async fn get_docx_urls(
let signed_options = get_cloudfront_signed_options(
&state
.config
- .vars
.document_storage_service_cloudfront_signer_public_key_id,
state
.config
@@ -242,7 +239,6 @@ async fn get_docx_urls(
let cloudfront_distribution_url = state
.config
- .vars
.document_storage_service_cloudfront_distribution_url
.as_ref();
diff --git a/rust/cloud-storage/document_storage_service/src/config.rs b/rust/cloud-storage/document_storage_service/src/config.rs
index 5242e56d86..b5a64e752b 100644
--- a/rust/cloud-storage/document_storage_service/src/config.rs
+++ b/rust/cloud-storage/document_storage_service/src/config.rs
@@ -1,225 +1,158 @@
+use anyhow::Context;
pub use macro_env::Environment;
-use macro_env_var::{env_var, maybe_env_var};
-use macro_service_urls::{ConnectionGatewayUrl, LexicalServiceUrl, SyncServiceUrl};
+use macro_env_var::{env_vars, maybe_env_vars};
use secretsmanager_client::LocalOrRemoteSecret;
-/// The configuration parameters for the application.
-///
-/// These can either be passed on the command line, or pulled from environment variables.
-/// The latter is preferred as environment variables are one of the recommended ways to
-/// populate the Docker container
-///
-/// See `.env.sample` in document-storage-service root for details.
-pub struct Config {
- pub vars: EnvVars,
-
- /// The port to listen for HTTP requests on.
- pub port: usize,
-
- /// The environment we are in
- pub environment: Environment,
-
- /// Connection gateway URL.
- pub connection_gateway_url: String,
-
- /// Sync service URL.
- pub sync_service_url: String,
-
- /// Lexical service URL.
- pub lexical_service_url: String,
-
- /// Maximum number of SQS messages to receive per poll for the delete document worker
- pub queue_max_messages: i32,
- /// SQS long-poll wait time in seconds for the delete document worker
- pub queue_wait_time_seconds: i32,
-
- /// The document limit for free users
- pub document_limit: u64,
-
- /// The number of seconds a presigned url is valid for
- pub document_storage_service_presigned_url_expiry_seconds: u64,
- /// The number of seconds a browser cache for a presigned url is valid for
- pub document_storage_service_presigned_url_browser_cache_expiry_seconds: u64,
- pub document_storage_service_cloudfront_signer_private_key:
- LocalOrRemoteSecret<DocumentStorageServiceCloudfrontSignerPrivateKeySecretName>,
-
- pub document_permission_jwt: LocalOrRemoteSecret<DocumentPermissionJwtSecretKey>,
-}
+pub const DEFAULT_PRESIGNED_URL_EXPIRY_SECONDS: u64 = 900; // 15 minutes
+pub const DEFAULT_PRESIGNED_URL_BROWSER_CACHE_EXPIRY_SECONDS: u64 = 840; // remember that this is just a suggestion to the client browser
-env_var! {
- struct EnvVars {
- pub DatabaseUrl,
- pub DatabaseUrlReadonly,
- pub DocumentStorageBucket,
- pub DocxDocumentUploadBucket,
- pub DocumentDeleteQueue,
- pub DocumentStorageServiceCloudfrontDistributionUrl,
- pub DocumentStorageServiceCloudfrontSignerPublicKeyId,
- pub RedisUri,
- pub NotificationQueue,
- pub SearchEventQueue,
- pub BulkUploadRequestsTable,
- pub UploadStagingBucket,
- pub SyncServiceAuthKey,
- pub OpensearchUrl,
- pub OpensearchUsername,
- pub OpensearchPassword,
- pub ContactsQueue,
- pub GithubSyncAppUrl,
- pub GithubSyncAppClientId,
- pub LivekitServerUrl,
- pub LivekitApiKey,
- pub LivekitApiSecret,
- /// OpenAI API key used to generate task-dedup embeddings. Required —
- /// injected as `OPENAI_API_KEY` from the `openai-key` secret by the
- /// infra stack, the same way `document_cognition_service` consumes it.
- pub OpenaiApiKey,
- }
+env_vars! {
+ pub struct DatabaseUrl;
+ pub struct DatabaseUrlReadonly;
+ pub struct DocumentStorageBucket;
+ pub struct DocxDocumentUploadBucket;
+ pub struct DocumentDeleteQueue;
+ pub struct DocumentStorageServiceCloudfrontDistributionUrl;
+ pub struct DocumentStorageServiceCloudfrontSignerPublicKeyId;
+ pub struct RedisUri;
+ pub struct NotificationQueue;
+ pub struct SearchEventQueue;
+ pub struct BulkUploadRequestsTable;
+ pub struct UploadStagingBucket;
+ pub struct SyncServiceAuthKey;
+ pub struct OpensearchUrl;
+ pub struct OpensearchUsername;
+ pub struct OpensearchPassword;
+ pub struct ContactsQueue;
+ pub struct GithubSyncAppUrl;
+ pub struct GithubSyncAppClientId;
+ pub struct LivekitServerUrl;
+ pub struct LivekitApiKey;
+ pub struct LivekitApiSecret;
+ /// OpenAI API key used to generate task-dedup embeddings. Required —
+ /// injected as `OPENAI_API_KEY` from the `openai-key` secret by the
+ /// infra stack, the same way `document_cognition_service` consumes it.
+ pub struct OpenaiApiKey;
+ pub struct DocumentLimit;
+ pub struct DocumentStorageServicePresignedUrlExpirySeconds;
+ pub struct DocumentStorageServicePresignedUrlBrowserCacheExpirySeconds;
+ pub struct DocumentStorageServiceCloudfrontSignerPrivateKeySecretName;
+ #[derive(Clone)]
+ pub struct DocumentPermissionJwtSecretKey;
+ pub struct GithubWebhookSecretKey;
+ pub struct GithubSyncAppPemSecretKey;
+ pub struct CalWebhookSecretKey;
+ pub struct CalEventTypeContentNamesKey;
+ pub struct MetaPixelId;
+ pub struct MetaAccessToken;
+ #[derive(Clone)]
+ pub struct DocumentStorageServiceAuthKey;
+ pub struct InternalApiSecretKey;
}
-maybe_env_var! {
+maybe_env_vars! {
/// Optional name of the LiveKit agent to dispatch for call transcription.
pub struct LivekitTranscriptionAgentName;
-}
-
-maybe_env_var! {
/// Shared secret for internal call endpoints (e.g. transcript ingestion from the agent).
pub struct InternalCallSecret;
-}
-
-maybe_env_var! {
/// Public base URL of this service (e.g. `https://cloud-storage.macro.com`),
/// used to build the ring-status URL included in VoIP push payloads.
/// When unset, payloads omit the URL and native ring-status polling is off.
pub struct CallRingStatusBaseUrl;
-}
-
-maybe_env_var! {
/// S3 bucket for call recording egress.
pub struct CallRecordingS3Bucket;
-}
-maybe_env_var! {
/// AWS region for the call recording S3 bucket.
pub struct CallRecordingS3Region;
-}
-maybe_env_var! {
/// AWS access key for call recording S3 uploads.
pub struct CallRecordingS3AccessKey;
-}
-maybe_env_var! {
/// AWS secret key for call recording S3 uploads.
pub struct CallRecordingS3Secret;
-}
-
-env_var! { struct Port; }
-env_var! { struct DocumentLimit; }
-env_var! { struct DocumentStorageServicePresignedUrlExpirySeconds; }
-env_var! { struct DocumentStorageServicePresignedUrlBrowserCacheExpirySeconds; }
-env_var! { pub struct DocumentStorageServiceCloudfrontSignerPrivateKeySecretName; }
-env_var! {
- #[derive(Clone)]
- pub struct DocumentPermissionJwtSecretKey;
-}
-env_var! {
- pub struct GithubWebhookSecretKey;
-}
-
-env_var! {
- pub struct GithubSyncAppPemSecretKey;
-}
-
-env_var! {
- pub struct CalWebhookSecretKey;
-}
-
-env_var! {
- /// Secrets Manager secret name holding the JSON map from cal.com
- /// `eventTypeId` to Meta `content_name`.
- pub struct CalEventTypeContentNamesKey;
-}
-
-env_var! {
- /// Meta (Facebook) Conversions API pixel id. Required — pair with
- /// [`MetaAccessToken`] for cal → Meta Lead tracking. Set to a dummy
- /// value locally; it's only exercised when a cal webhook fires.
- pub struct MetaPixelId;
-}
-
-env_var! {
- /// Meta (Facebook) Conversions API access token. Required — see
- /// [`MetaPixelId`].
- pub struct MetaAccessToken;
-}
-
-maybe_env_var! {
/// Optional Meta test event code — routes events to Meta's test events
/// view instead of production tracking.
pub struct MetaTestEventCode;
}
-impl Config {
- pub fn from_env(
- document_storage_service_cloudfront_signer_private_key: LocalOrRemoteSecret<
- DocumentStorageServiceCloudfrontSignerPrivateKeySecretName,
- >,
- document_permission_jwt: LocalOrRemoteSecret<DocumentPermissionJwtSecretKey>,
- ) -> anyhow::Result<Self> {
- let environment = Environment::new_or_prod();
+/// The configuration parameters for the application.
+#[derive(macro_config::MacroConfig)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub struct Config {
+ pub database_url: DatabaseUrl,
+ pub database_url_readonly: DatabaseUrlReadonly,
+ pub document_storage_bucket: DocumentStorageBucket,
+ pub docx_document_upload_bucket: DocxDocumentUploadBucket,
+ pub document_delete_queue: DocumentDeleteQueue,
+ pub document_storage_service_cloudfront_distribution_url:
+ DocumentStorageServiceCloudfrontDistributionUrl,
+ pub document_storage_service_cloudfront_signer_public_key_id:
+ DocumentStorageServiceCloudfrontSignerPublicKeyId,
+ pub redis_uri: RedisUri,
+ pub notification_queue: NotificationQueue,
+ pub search_event_queue: SearchEventQueue,
+ pub bulk_upload_requests_table: BulkUploadRequestsTable,
+ pub upload_staging_bucket: UploadStagingBucket,
+ pub sync_service_auth_key: LocalOrRemoteSecret<SyncServiceAuthKey>,
+ pub opensearch_url: OpensearchUrl,
+ pub opensearch_username: OpensearchUsername,
+ pub opensearch_password: OpensearchPassword,
+ pub contacts_queue: ContactsQueue,
+ pub github_sync_app_url: GithubSyncAppUrl,
+ pub github_sync_app_client_id: GithubSyncAppClientId,
+ pub livekit_server_url: LivekitServerUrl,
+ pub livekit_api_key: LivekitApiKey,
+ pub livekit_api_secret: LivekitApiSecret,
+ pub openai_api_key: OpenaiApiKey,
+ pub github_webhook_secret_key: LocalOrRemoteSecret<GithubWebhookSecretKey>,
+ pub github_sync_app_pem_secret_key: LocalOrRemoteSecret<GithubSyncAppPemSecretKey>,
+ pub cal_webhook_secret_key: CalWebhookSecretKey,
+ pub cal_event_type_content_names_key: CalEventTypeContentNamesKey,
+ pub meta_pixel_id: MetaPixelId,
+ pub meta_access_token: MetaAccessToken,
+ pub document_storage_service_auth_key: DocumentStorageServiceAuthKey,
+ pub internal_api_secret_key: LocalOrRemoteSecret<InternalApiSecretKey>,
+ // pub vars: EnvVars,
+ /// The port to listen for HTTP requests on.
+ #[macro_config_default(8080)]
+ pub port: usize,
- let port = Port::new()
- .ok()
- .and_then(|v| v.as_ref().parse::<usize>().ok())
- .unwrap_or(8080);
+ /// The environment we are in
+ #[macro_config_default(Environment::new_or_prod())]
+ pub environment: Environment,
- let document_limit = DocumentLimit::new()
- .ok()
- .and_then(|v| v.as_ref().parse::<u64>().ok())
- .unwrap_or(20);
+ /// Maximum number of SQS messages to receive per poll for the delete document worker
+ #[macro_config_default(10)]
+ pub queue_max_messages: i32,
+ /// SQS long-poll wait time in seconds for the delete document worker
+ #[macro_config_default(4)]
+ pub queue_wait_time_seconds: i32,
- let document_storage_service_presigned_url_expiry_seconds =
- DocumentStorageServicePresignedUrlExpirySeconds::new()
- .ok()
- .and_then(|v| v.as_ref().parse::<u64>().ok())
- .unwrap_or(DEFAULT_PRESIGNED_URL_EXPIRY_SECONDS);
+ /// The document limit for free users
+ #[macro_config_default(20)]
+ pub document_limit: u64,
- let document_storage_service_presigned_url_browser_cache_expiry_seconds =
- DocumentStorageServicePresignedUrlBrowserCacheExpirySeconds::new()
- .ok()
- .and_then(|v| v.as_ref().parse::<u64>().ok())
- .unwrap_or(DEFAULT_PRESIGNED_URL_BROWSER_CACHE_EXPIRY_SECONDS);
+ /// The number of seconds a presigned url is valid for
+ #[macro_config_default(DEFAULT_PRESIGNED_URL_EXPIRY_SECONDS)]
+ pub document_storage_service_presigned_url_expiry_seconds: u64,
+ /// The number of seconds a browser cache for a presigned url is valid for
+ #[macro_config_default(DEFAULT_PRESIGNED_URL_BROWSER_CACHE_EXPIRY_SECONDS)]
+ pub document_storage_service_presigned_url_browser_cache_expiry_seconds: u64,
- let queue_max_messages: i32 = std::env::var("QUEUE_MAX_MESSAGES")
- .unwrap_or("10".to_string())
- .parse()
- .unwrap_or(10);
+ pub document_storage_service_cloudfront_signer_private_key:
+ LocalOrRemoteSecret<DocumentStorageServiceCloudfrontSignerPrivateKeySecretName>,
- let queue_wait_time_seconds: i32 = std::env::var("QUEUE_WAIT_TIME_SECONDS")
- .unwrap_or("4".to_string())
- .parse()
- .unwrap_or(4);
+ pub document_permission_jwt: LocalOrRemoteSecret<DocumentPermissionJwtSecretKey>,
- let vars = EnvVars::new()?;
- let connection_gateway_url = ConnectionGatewayUrl::new()?.to_string();
- let sync_service_url = SyncServiceUrl::new()?.to_string();
- let lexical_service_url = LexicalServiceUrl::new()?.to_string();
+ pub livekit_transcription_agent_name: LivekitTranscriptionAgentName,
+ pub internal_call_secret: InternalCallSecret,
+ pub call_ring_status_base_url: CallRingStatusBaseUrl,
+ pub call_recording_s3_bucket: CallRecordingS3Bucket,
+ pub call_recording_s3_region: CallRecordingS3Region,
+ pub call_recording_s3_access_key: CallRecordingS3AccessKey,
+ pub call_recording_s3_secret: CallRecordingS3Secret,
+ pub meta_test_event_code: MetaTestEventCode,
+}
- Ok(Config {
- vars,
- port,
- environment,
- connection_gateway_url,
- sync_service_url,
- lexical_service_url,
- queue_max_messages,
- queue_wait_time_seconds,
- document_limit,
- document_storage_service_presigned_url_expiry_seconds,
- document_storage_service_presigned_url_browser_cache_expiry_seconds,
- document_storage_service_cloudfront_signer_private_key,
- document_permission_jwt,
- })
+impl Config {
+ pub fn from_env() -> anyhow::Result<Self> {
+ macro_config::ConfigLoader::load::<Config>().context("failed to load config")
}
}
-
-pub const DEFAULT_PRESIGNED_URL_EXPIRY_SECONDS: u64 = 900; // 15 minutes
-pub const DEFAULT_PRESIGNED_URL_BROWSER_CACHE_EXPIRY_SECONDS: u64 = 840; // remember that this is just a suggestion to the client browser
diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rs
index 34c9ba31b2..974187c8cf 100644
--- a/rust/cloud-storage/document_storage_service/src/main.rs
+++ b/rust/cloud-storage/document_storage_service/src/main.rs
@@ -2,9 +2,8 @@
use crate::{
api::context::{ApiContext, DocumentStorageServiceAuthKey, TaskPropertiesAdapter},
config::{
- CalEventTypeContentNamesKey, CalWebhookSecretKey, DocumentPermissionJwtSecretKey,
- DocumentStorageServiceCloudfrontSignerPrivateKeySecretName, GithubSyncAppPemSecretKey,
- GithubWebhookSecretKey, MetaAccessToken, MetaPixelId, MetaTestEventCode,
+ CalEventTypeContentNamesKey, CalWebhookSecretKey, MetaAccessToken, MetaPixelId,
+ MetaTestEventCode,
},
service::s3::S3,
};
@@ -71,7 +70,7 @@ use github::outbound::pg_github_sync_repo::PgGithubSyncRepo;
use lexical_client::LexicalClient;
use macro_auth::middleware::decode_jwt::JwtValidationArgs;
use macro_entrypoint::MacroEntrypoint;
-use macro_middleware::auth::internal_access::InternalApiSecretKey;
+use macro_service_urls::{ConnectionGatewayUrl, LexicalServiceUrl, SyncServiceUrl};
use macro_sha_count_client::Redis;
use notification::domain::service::SqsNotificationIngress;
use notification::outbound::queue::SqsQueue;
@@ -114,23 +113,8 @@ async fn main() -> anyhow::Result<()> {
aws_sdk_secretsmanager::Client::new(&aws_config),
);
- let cloudfront_signer_private_key = secretsmanager_client
- .get_maybe_secret_value(
- env,
- DocumentStorageServiceCloudfrontSignerPrivateKeySecretName::new()?,
- )
- .await?;
-
- let document_permission_jwt_secret = secretsmanager_client
- .get_maybe_secret_value(env, DocumentPermissionJwtSecretKey::new()?)
- .await?;
-
// Parse our configuration from the environment.
- let config = Config::from_env(
- cloudfront_signer_private_key,
- document_permission_jwt_secret,
- )
- .context("expected to be able to generate config")?;
+ let config = Config::from_env().context("expected to be able to generate config")?;
tracing::trace!("initialized config");
@@ -143,7 +127,7 @@ async fn main() -> anyhow::Result<()> {
let db = PgPoolOptions::new()
.min_connections(min_connections)
.max_connections(max_connections)
- .connect(&config.vars.database_url)
+ .connect(&config.database_url)
.await
.context("could not connect to db")?;
@@ -156,7 +140,7 @@ async fn main() -> anyhow::Result<()> {
let readonly_db = match PgPoolOptions::new()
.min_connections(min_connections)
.max_connections(max_connections)
- .connect(&config.vars.database_url_readonly)
+ .connect(&config.database_url_readonly)
.await
{
Ok(pool) => {
@@ -173,7 +157,7 @@ async fn main() -> anyhow::Result<()> {
let dynamodb_client = DynamodbClient::new_from_client(
dynamo_db.clone(),
- Some(config.vars.bulk_upload_requests_table.as_ref().to_string()),
+ Some(config.bulk_upload_requests_table.as_ref().to_string()),
);
tracing::trace!("initialized dynamodb client");
@@ -182,13 +166,13 @@ async fn main() -> anyhow::Result<()> {
tracing::trace!("initialized s3 client");
let sqs_client = sqs_client::SQS::new(aws_sdk_sqs::Client::new(&aws_config))
- .search_event_queue(&config.vars.search_event_queue)
- .document_delete_queue(&config.vars.document_delete_queue);
+ .search_event_queue(&config.search_event_queue)
+ .document_delete_queue(&config.document_delete_queue);
let contacts_ingress = Arc::new(contacts::domain::service::SqsContactsIngress {
queue: contacts::outbound::ingress::SqsContactsQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- config.vars.contacts_queue.as_ref().to_string(),
+ config.contacts_queue.to_string(),
),
});
@@ -196,7 +180,7 @@ async fn main() -> anyhow::Result<()> {
// Redis handles it own connection pool internally. Each time we use redis
// we should be using redis_client.get_connection() to grab a specific connection
- let redis_client = redis::Client::open(config.vars.redis_uri.as_ref())
+ let redis_client = redis::Client::open(config.redis_uri.to_string().as_ref())
.expect("could not connect to redis client");
match redis_client.get_connection().is_err() {
@@ -208,34 +192,21 @@ async fn main() -> anyhow::Result<()> {
}
}
- let internal_api_secret = secretsmanager_client
- .get_maybe_secret_value(config.environment, InternalApiSecretKey::new()?)
- .await?;
-
let dss_auth_key = DocumentStorageServiceAuthKey::new()?;
let conn_gateway_client = ConnectionGatewayClient::new(
- internal_api_secret.as_ref().to_string(),
- config.connection_gateway_url.clone(),
+ config.internal_api_secret_key.as_ref().to_string(),
+ ConnectionGatewayUrl::new()?.to_string(),
);
- let sync_service_auth_key = match config.environment {
- Environment::Local => config.vars.sync_service_auth_key.as_ref().to_string(),
- _ => secretsmanager_client
- .get_secret_value(&config.vars.sync_service_auth_key)
- .await
- .context("unable to get secret")?
- .to_string(),
- };
-
let sync_service_client = Arc::new(SyncServiceClient::new(
- sync_service_auth_key,
- config.sync_service_url.clone(),
+ config.sync_service_auth_key.as_ref().to_string(),
+ SyncServiceUrl::new()?.to_string(),
));
let lexical_client = Arc::new(LexicalClient::new(
- internal_api_secret.as_ref().to_string(),
- config.lexical_service_url.clone(),
+ config.internal_api_secret_key.as_ref().to_string(),
+ LexicalServiceUrl::new()?.to_string(),
));
let jwt_validation_args =
@@ -243,19 +214,10 @@ async fn main() -> anyhow::Result<()> {
.await?;
// Initialize OpenSearch client
- let opensearch_password = match config.environment {
- Environment::Local => config.vars.opensearch_password.as_ref().to_string(),
- _ => secretsmanager_client
- .get_secret_value(&config.vars.opensearch_password)
- .await
- .context("unable to get opensearch secret")?
- .to_string(),
- };
-
let opensearch_client = OpensearchClient::new(
- config.vars.opensearch_url.as_ref().to_string(),
- config.vars.opensearch_username.as_ref().to_string(),
- opensearch_password,
+ config.opensearch_url.to_string(),
+ config.opensearch_username.to_string(),
+ config.opensearch_password.to_string(),
)
.context("unable to create opensearch client")?;
@@ -291,7 +253,7 @@ async fn main() -> anyhow::Result<()> {
SystemPropertiesServiceImpl::new(PgSystemPropertiesRepository::new(db.clone()));
let ingress_queue = SqsQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- config.vars.notification_queue.as_ref().to_string(),
+ config.notification_queue.to_string(),
);
let notification_ingress_service = Arc::new(SqsNotificationIngress {
queue: ingress_queue.clone(),
@@ -331,21 +293,19 @@ async fn main() -> anyhow::Result<()> {
let s3 = Arc::new(S3::new(
s3_client,
- config.vars.document_storage_bucket.as_ref(),
- config.vars.docx_document_upload_bucket.as_ref(),
- config.vars.upload_staging_bucket.as_ref(),
+ config.document_storage_bucket.as_ref(),
+ config.docx_document_upload_bucket.as_ref(),
+ config.upload_staging_bucket.as_ref(),
));
let system_properties_service = Arc::new(system_properties_service);
let document_repo = PgDocumentRepo::new(db.clone());
let cloudfront_config = CloudFrontConfig {
distribution_url: config
- .vars
.document_storage_service_cloudfront_distribution_url
.as_ref()
.to_string(),
signer_public_key_id: config
- .vars
.document_storage_service_cloudfront_signer_public_key_id
.as_ref()
.to_string(),
@@ -359,8 +319,8 @@ async fn main() -> anyhow::Result<()> {
};
let s3_upload_adapter = S3UploadUrlAdapter::new(
macro_aws_config::s3_client().await,
- config.vars.document_storage_bucket.as_ref(),
- config.vars.docx_document_upload_bucket.as_ref(),
+ config.document_storage_bucket.as_ref(),
+ config.docx_document_upload_bucket.as_ref(),
);
let markdown_initializer =
documents_hex::outbound::markdown_init::LexicalSyncMarkdownInitializer::new(
@@ -392,24 +352,16 @@ async fn main() -> anyhow::Result<()> {
ForeignEntityServiceImpl::new(PgForeignEntityRepo::new(db.clone())),
));
- let github_webhook_secret = secretsmanager_client
- .get_maybe_secret_value(env, GithubWebhookSecretKey::new()?)
- .await?;
-
- let github_sync_app_pem = secretsmanager_client
- .get_maybe_secret_value(env, GithubSyncAppPemSecretKey::new()?)
- .await?;
-
let foreign_entity_service = Arc::new(ForeignEntityServiceImpl::new(PgForeignEntityRepo::new(
db.clone(),
)));
let github_sync_service_impl = GithubSyncServiceImpl::new(
GithubSyncConfig {
- webhook_secret: github_webhook_secret.as_ref().to_string(),
- github_sync_app_url: config.vars.github_sync_app_url.to_string(),
- sync_app_pem: github_sync_app_pem.as_ref().to_string(),
- sync_app_client_id: config.vars.github_sync_app_client_id.to_string(),
+ webhook_secret: config.github_webhook_secret_key.as_ref().to_string(),
+ github_sync_app_url: config.github_sync_app_url.to_string(),
+ sync_app_pem: config.github_sync_app_pem_secret_key.as_ref().to_string(),
+ sync_app_client_id: config.github_sync_app_client_id.to_string(),
},
document_service.clone(),
foreign_entity_service.clone(),
@@ -455,18 +407,22 @@ async fn main() -> anyhow::Result<()> {
let cal_webhook_state = CalWebhookRouterState::new(cal_webhook_service);
// Call service (LiveKit)
- let transcription_agent_name =
- config::LivekitTranscriptionAgentName::new().map(|v| v.as_ref().to_owned());
- let internal_call_secret = config::InternalCallSecret::new().map(|v| v.as_ref().to_owned());
+ let transcription_agent_name = config
+ .livekit_transcription_agent_name
+ .value()
+ .map(|v| v.to_owned());
+
+ let internal_call_secret = config.internal_call_secret.value().map(|v| v.to_owned());
+
anyhow::ensure!(
transcription_agent_name.is_none() || internal_call_secret.is_some(),
"LIVEKIT_TRANSCRIPTION_AGENT_NAME is set but INTERNAL_CALL_SECRET is missing — \
the transcription agent will not be able to submit transcripts"
);
let livekit_rtc_client = LivekitRtcClient::new(
- config.vars.livekit_server_url.as_ref(),
- config.vars.livekit_api_key.as_ref(),
- config.vars.livekit_api_secret.as_ref(),
+ config.livekit_server_url.as_ref(),
+ config.livekit_api_key.as_ref(),
+ config.livekit_api_secret.as_ref(),
transcription_agent_name,
);
let call_connection_service =
@@ -503,7 +459,7 @@ async fn main() -> anyhow::Result<()> {
(*entity_access_service).clone(),
(*notification_ingress_service).clone(),
recording_storage,
- config.vars.livekit_server_url.as_ref(),
+ config.livekit_server_url.as_ref(),
)
.with_summarizer(AiCallSummarizer::new());
if let Some(secret) = internal_call_secret {
@@ -566,7 +522,7 @@ async fn main() -> anyhow::Result<()> {
// Create the SQS worker for delete document processing before config is moved
let delete_document_worker = sqs_worker::SQSWorker::new(
aws_sdk_sqs::Client::new(&aws_config),
- config.vars.document_delete_queue.as_ref().to_string(),
+ config.document_delete_queue.to_string(),
config.queue_max_messages,
config.queue_wait_time_seconds,
);
@@ -584,7 +540,7 @@ async fn main() -> anyhow::Result<()> {
// (resolved from the `openai-key` secret at deploy time by the infra stack),
// the same way `document_cognition_service` consumes it. Fail fast if it's
// empty so the service never starts with a broken task-dedup embedder.
- let openai_api_key = config.vars.openai_api_key.as_ref().to_owned();
+ let openai_api_key = config.openai_api_key.as_ref().to_owned();
anyhow::ensure!(
!openai_api_key.trim().is_empty(),
"OpenAI API key is required for task dedup embeddings",