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.

fix(notif): online checker false negatives (#4075)

Sean Ayecd55f9e5acf6
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.json
index 9c2556d545..7603e0b088 100644
--- a/.github/workspace-dep-closures.json
+++ b/.github/workspace-dep-closures.json
@@ -2901,11 +2901,14 @@
"last_online_tracker",
"macro_auth",
"macro_aws_config",
+ "macro_config",
+ "macro_config_derive",
"macro_cors",
"macro_db_client",
"macro_entrypoint",
"macro_env",
"macro_env_var",
+ "macro_env_vars/database_env_vars",
"macro_middleware",
"macro_service_urls",
"macro_tower_layers",
diff --git a/infra/stacks/notification-service/index.ts b/infra/stacks/notification-service/index.ts
index 5e511541f9..17e19ac336 100644
--- a/infra/stacks/notification-service/index.ts
+++ b/infra/stacks/notification-service/index.ts
@@ -94,6 +94,17 @@ const cloudStorageClusterName: pulumi.Output<string> = cloudStorageStack
.getOutput('cloudStorageClusterName')
.apply((arn) => arn as string);
+const connectionGatewayStack = new pulumi.StackReference(
+ 'connection-gateway-stack',
+ {
+ name: `macro-inc/connection-gateway/${stack}`,
+ }
+);
+
+const connectionGatewayRedisUrl: pulumi.Output<string> = connectionGatewayStack
+ .getOutput('connectionGatewayRedisUrl')
+ .apply((url) => url as string);
+
const DATABASE_URL = aws.secretsmanager
.getSecretVersionOutput({
secretId: config.require(`macro_db_secret_key`),
@@ -274,6 +285,10 @@ const notificationService = new NotificationService('notification-service', {
name: 'REDIS_URI',
value: pulumi.interpolate`redis://${MACRO_CACHE}`,
},
+ {
+ name: 'LAST_ONLINE_REDIS_URI',
+ value: pulumi.interpolate`redis://${connectionGatewayRedisUrl}`,
+ },
{
name: 'MACRO_API_TOKEN_ISSUER',
value: pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenIssuer}`,
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 2463c2d1c9..33f18b0518 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -8087,6 +8087,7 @@ dependencies = [
"aws-sdk-sqs",
"axum",
"chrono",
+ "database_env_vars",
"decode_jwt",
"email_formatting",
"hmac 0.12.1",
@@ -8095,6 +8096,7 @@ dependencies = [
"last_online_tracker",
"macro_auth",
"macro_aws_config",
+ "macro_config",
"macro_cors",
"macro_entrypoint",
"macro_env",
diff --git a/rust/cloud-storage/authentication_service/src/config.rs b/rust/cloud-storage/authentication_service/src/config.rs
index 4db6cc2ef7..d610abd53b 100644
--- a/rust/cloud-storage/authentication_service/src/config.rs
+++ b/rust/cloud-storage/authentication_service/src/config.rs
@@ -7,8 +7,10 @@ use macro_env_var::{env_vars, maybe_env_vars};
// BASE_URL config value. This is validated when creating the config in main.rs
pub static BASE_URL: LazyLock<String> = LazyLock::new(|| {
- macro_config::required_config_value("BASE_URL")
+ BaseUrl::new()
.expect("BASE_URL must be provided via APP_SECRETS_JSON or env")
+ .as_ref()
+ .to_string()
});
env_vars! {
diff --git a/rust/cloud-storage/convert_service/src/config.rs b/rust/cloud-storage/convert_service/src/config.rs
index 03ab985f11..b71c3a7b93 100644
--- a/rust/cloud-storage/convert_service/src/config.rs
+++ b/rust/cloud-storage/convert_service/src/config.rs
@@ -7,14 +7,18 @@ use macro_env_var::env_vars;
/// The path to the LibreOffice binary
pub static LOK_PATH: LazyLock<String> = LazyLock::new(|| {
- macro_config::required_config_value("LOK_PATH")
+ LokPath::new()
.expect("LOK_PATH must be provided via APP_SECRETS_JSON or env")
+ .as_ref()
+ .to_string()
});
/// The websocket response lambda
pub static WEB_SOCKET_RESPONSE_LAMBDA: LazyLock<String> = LazyLock::new(|| {
- macro_config::required_config_value("WEB_SOCKET_RESPONSE_LAMBDA")
+ WebSocketResponseLambda::new()
.expect("WEB_SOCKET_RESPONSE_LAMBDA must be provided via APP_SECRETS_JSON or env")
+ .as_ref()
+ .to_string()
});
env_vars! {
diff --git a/rust/cloud-storage/justfile b/rust/cloud-storage/justfile
index e4148b0e7d..31a406f64c 100644
--- a/rust/cloud-storage/justfile
+++ b/rust/cloud-storage/justfile
@@ -112,6 +112,7 @@ setup_test_envs:
echo "DATABASE_URL={{ DATABASE_URL }}" >> ./crm/.env
echo "DATABASE_URL={{ DATABASE_URL }}" >> ./bots/.env
echo "DATABASE_URL={{ DATABASE_URL }}" >> ./call_recording_preview_handler/.env
+ echo "DATABASE_URL={{ DATABASE_URL }}" >> ./share_permission_db_utils/.env
setup_macrodb:
just macro_db_client/create_db
diff --git a/rust/cloud-storage/macro_config/src/lib.rs b/rust/cloud-storage/macro_config/src/lib.rs
index 540ddbde9e..e660654169 100644
--- a/rust/cloud-storage/macro_config/src/lib.rs
+++ b/rust/cloud-storage/macro_config/src/lib.rs
@@ -115,12 +115,12 @@ fn read_config_value(key: &'static str) -> Option<String> {
}
/// Get a required value
-pub fn required_config_value(key: &'static str) -> MacroConfigResult<String> {
+fn required_config_value(key: &'static str) -> MacroConfigResult<String> {
read_config_value(key).ok_or(MacroConfigError::MissingRequiredValue(key))
}
/// Get an optional value
-pub fn optional_config_value(key: &'static str) -> Option<String> {
+fn optional_config_value(key: &'static str) -> Option<String> {
read_config_value(key)
}
diff --git a/rust/cloud-storage/macro_env_var/src/lib.rs b/rust/cloud-storage/macro_env_var/src/lib.rs
index afa2868142..752529329c 100644
--- a/rust/cloud-storage/macro_env_var/src/lib.rs
+++ b/rust/cloud-storage/macro_env_var/src/lib.rs
@@ -5,6 +5,7 @@ use thiserror::Error;
const APP_SECRETS_JSON_ENV: &str = "APP_SECRETS_JSON";
+#[allow(dead_code)]
fn read_std_env(s: &'static str) -> Result<String, std::env::VarError> {
std::env::var(s)
}
@@ -23,11 +24,6 @@ where
}
}
-/// Read a value from `APP_SECRETS_JSON` without mutating the process environment.
-pub fn read_from_app_secrets_json(key: &'static str) -> Option<String> {
- read_from_app_secrets_json_with(key, read_std_env)
-}
-
fn read_env_with<F>(s: &'static str, read_var: F) -> Result<String, VarNameErr>
where
F: Fn(&'static str) -> Result<String, std::env::VarError>,
@@ -78,11 +74,11 @@ mod testing_harness {
}
}
- pub fn read_env(s: &'static str) -> Result<String, VarNameErr> {
+ pub(crate) fn read_env(s: &'static str) -> Result<String, VarNameErr> {
read_env_with(s, get_env)
}
- pub fn maybe_read_env(s: &'static str) -> Option<String> {
+ pub(crate) fn maybe_read_env(s: &'static str) -> Option<String> {
maybe_read_env_with(s, get_env)
}
@@ -98,9 +94,9 @@ mod testing_harness {
}
#[cfg(test)]
-pub use testing_harness::maybe_read_env;
+pub(crate) use testing_harness::maybe_read_env;
#[cfg(test)]
-pub use testing_harness::read_env;
+pub(crate) use testing_harness::read_env;
#[cfg(not(test))]
pub fn read_env(s: &'static str) -> Result<String, VarNameErr> {
diff --git a/rust/cloud-storage/notification_service/Cargo.toml b/rust/cloud-storage/notification_service/Cargo.toml
index 2155504661..106bcf3f27 100644
--- a/rust/cloud-storage/notification_service/Cargo.toml
+++ b/rust/cloud-storage/notification_service/Cargo.toml
@@ -26,6 +26,7 @@ aws-sdk-sns = { workspace = true }
aws-sdk-sqs = { workspace = true }
axum = { workspace = true }
chrono = { workspace = true }
+database_env_vars = { path = "../macro_env_vars/database_env_vars" }
decode_jwt = { path = "../decode_jwt" }
email_formatting = { path = "../email_formatting" }
hmac = { workspace = true }
@@ -34,6 +35,7 @@ itertools = { workspace = true }
last_online_tracker = { path = "../last_online_tracker" }
macro_auth = { path = "../macro_auth" }
macro_aws_config = { path = "../macro_aws_config" }
+macro_config = { path = "../macro_config" }
macro_cors = { path = "../macro_cors" }
macro_entrypoint = { path = "../macro_entrypoint" }
macro_env = { path = "../macro_env" }
diff --git a/rust/cloud-storage/notification_service/src/config.rs b/rust/cloud-storage/notification_service/src/config.rs
index 40e8fc8ef2..3c8dcd3934 100644
--- a/rust/cloud-storage/notification_service/src/config.rs
+++ b/rust/cloud-storage/notification_service/src/config.rs
@@ -1,133 +1,128 @@
use anyhow::Context;
+use database_env_vars::{DatabaseUrl, RedisUri};
use macro_env::Environment;
-use macro_env_var::env_var;
+use macro_env_var::{env_var, env_vars, maybe_env_var};
+use macro_middleware::auth::internal_access::InternalApiSecretKey;
use std::sync::LazyLock;
-// We have a check for this env var in the config creation so we can safely unwrap here
-pub static BASE_URL: LazyLock<String> = LazyLock::new(|| std::env::var("BASE_URL").unwrap());
+// We load this through `macro_config` at startup as part of [`Config`]. This lazy is retained for
+// older notification template code paths that do not receive `Config` directly.
+pub static BASE_URL: LazyLock<String> = LazyLock::new(|| {
+ BaseUrl::new()
+ .expect("BASE_URL must be provided via APP_SECRETS_JSON or env")
+ .as_ref()
+ .to_string()
+});
+
+env_vars! {
+ #[derive(Debug, Clone)]
+ pub(crate) struct BaseUrl;
+ #[derive(Debug, Clone)]
+ pub(crate) struct NotificationQueue;
+ #[derive(Debug, Clone)]
+ pub(crate) struct NotificationIngressQueue;
+ #[derive(Debug, Clone)]
+ pub(crate) struct AppleBundleId;
+ #[derive(Debug, Clone)]
+ pub(crate) struct SnsApnsPlatformArn;
+ #[derive(Debug, Clone)]
+ pub(crate) struct SnsFcmPlatformArn;
+ #[derive(Debug, Clone)]
+ pub(crate) struct SenderBaseAddress;
+ #[derive(Debug, Clone)]
+ pub(crate) struct PushNotificationEventHandlerQueue;
+ #[derive(Debug, Clone)]
+ pub(crate) struct LastOnlineRedisUri;
+}
-env_var!(
- pub(super) struct Vars {
- pub(crate) NotificationQueue,
- pub(crate) NotificationIngressQueue,
- pub(crate) RedisUri,
- pub(crate) AppleBundleId
- }
-);
+maybe_env_var! {
+ #[derive(Debug, Clone)]
+ pub(crate) struct SnsApnsVoipPlatformArn;
+}
env_var!(
- #[derive(Clone)]
+ #[derive(Debug, Clone)]
pub(crate) struct UrlSigningHmac;
);
-#[derive(Debug)]
+/// The configuration parameters for the application.
+///
+/// These are loaded from `APP_SECRETS_JSON` when present, otherwise from environment variables.
+#[derive(macro_config::MacroConfig)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct Config {
- /// The services base url including the scheme.
- pub base_url: String,
+ /// The service's base url including the scheme.
+ #[allow(dead_code)]
+ pub(crate) base_url: BaseUrl,
/// The connection URL for the Postgres database this application should use.
- pub database_url: String,
+ pub(crate) database_url: DatabaseUrl,
+
+ /// Internal API secret key name/value.
+ pub(crate) internal_api_secret_key: InternalApiSecretKey,
- /// Internal API secret key
- pub internal_api_secret_key: String,
+ /// Secret name/value for digest unsubscribe URL signing.
+ pub(crate) url_signing_hmac: UrlSigningHmac,
/// The port to listen for HTTP requests on.
- pub port: usize,
+ #[macro_config_default(8080)]
+ pub(crate) port: usize,
+
+ /// The environment we are in.
+ #[macro_config_default(Environment::new_or_prod())]
+ pub(crate) environment: Environment,
+
+ /// The notification queue max messages per poll.
+ #[macro_config_default(9)]
+ pub(crate) notification_queue_max_messages: i32,
- /// The environment we are in
- pub environment: Environment,
+ /// The notification queue wait time seconds.
+ #[macro_config_default(4)]
+ pub(crate) notification_queue_wait_time_seconds: i32,
- /// The notification queue max messages per poll
- pub notification_queue_max_messages: i32,
- /// The notification queue wait time seconds
- pub notification_queue_wait_time_seconds: i32,
+ /// The SQS queue for egress notification delivery.
+ pub(crate) notification_queue: NotificationQueue,
- /// The sns ios platform arn
- pub sns_apns_platform_arn: String,
+ /// The SQS queue for ingress notification creation.
+ pub(crate) notification_ingress_queue: NotificationIngressQueue,
- /// The sns android platform arn
- pub sns_fcm_platform_arn: String,
+ /// Redis used by notification-service for digest batching, rate limiting, etc.
+ pub(crate) redis_uri: RedisUri,
- /// The sns ios VoIP platform arn (APNS_VOIP).
- pub sns_apns_voip_platform_arn: String,
+ /// Redis used by connection-gateway for last-online state.
+ pub(crate) last_online_redis_uri: LastOnlineRedisUri,
- /// The sender base address
- // Explicitly allowed as it's used to ensure we have a correct sender base address in the lazy env var above
- pub sender_base_address: String,
+ /// Apple app bundle id for APNS pushes.
+ pub(crate) apple_bundle_id: AppleBundleId,
- /// The push notification event handler queue
- pub push_notification_event_handler_queue: String,
+ /// The SNS iOS platform ARN.
+ pub(crate) sns_apns_platform_arn: SnsApnsPlatformArn,
+
+ /// The SNS Android platform ARN.
+ pub(crate) sns_fcm_platform_arn: SnsFcmPlatformArn,
+
+ /// The SNS iOS VoIP platform ARN (APNS_VOIP). Optional locally.
+ pub(crate) sns_apns_voip_platform_arn: SnsApnsVoipPlatformArn,
+
+ /// The push notification event handler queue.
+ pub(crate) push_notification_event_handler_queue: PushNotificationEventHandlerQueue,
}
impl Config {
pub fn from_env() -> anyhow::Result<Self> {
- let base_url = std::env::var("BASE_URL").context("BASE_URL must be provided")?;
-
- let database_url =
- std::env::var("DATABASE_URL").context("DATABASE_URL must be provided")?;
-
- let port: usize = std::env::var("PORT")
- .unwrap_or("8080".to_string())
- .parse::<usize>()
- .context("should be valid port number")?;
-
- let internal_api_secret_key = std::env::var("INTERNAL_API_SECRET_KEY")
- .context("INTERNAL_API_SECRET_KEY must be provided")?;
-
- let environment = Environment::new_or_prod();
-
- let notification_queue_max_messages: i32 = std::env::var("NOTIFICATION_QUEUE_MAX_MESSAGES")
- .unwrap_or("9".to_string())
- .parse::<i32>()
- .unwrap();
-
- let notification_queue_wait_time_seconds: i32 =
- std::env::var("NOTIFICATION_QUEUE_WAIT_TIME_SECONDS")
- .unwrap_or("4".to_string())
- .parse::<i32>()
- .unwrap();
-
- let sns_apns_platform_arn = std::env::var("SNS_APNS_PLATFORM_ARN")
- .context("SNS_APNS_PLATFORM_ARN must be provided")?;
-
- let sns_fcm_platform_arn = std::env::var("SNS_FCM_PLATFORM_ARN")
- .context("SNS_FCM_PLATFORM_ARN must be provided")?;
-
- let sns_apns_voip_platform_arn = match std::env::var("SNS_APNS_VOIP_PLATFORM_ARN") {
- Ok(value) => value,
- // Local `run_local` does not provision SNS platform applications. Keep
- // VoIP push disabled locally instead of requiring a dummy ARN in .env.
- Err(std::env::VarError::NotPresent) if matches!(environment, Environment::Local) => {
- String::new()
- }
- Err(error) => return Err(error).context("SNS_APNS_VOIP_PLATFORM_ARN must be provided"),
- };
-
- let sender_base_address =
- std::env::var("SENDER_BASE_ADDRESS").context("SENDER_BASE_ADDRESS must be provided")?;
-
- let push_notification_event_handler_queue =
- std::env::var("PUSH_NOTIFICATION_EVENT_HANDLER_QUEUE")
- .context("PUSH_NOTIFICATION_EVENT_HANDLER_QUEUE must be provided")?;
-
- println!(
- "push_notification_event_handler_queue: {}",
- push_notification_event_handler_queue
- );
-
- Ok(Config {
- base_url,
- database_url,
- internal_api_secret_key,
- port,
- environment,
- notification_queue_max_messages,
- notification_queue_wait_time_seconds,
- sns_apns_platform_arn,
- sns_fcm_platform_arn,
- sns_apns_voip_platform_arn,
- sender_base_address,
- push_notification_event_handler_queue,
- })
+ let config = macro_config::ConfigLoader::load::<Config>()
+ .context("failed to load notification service config")?;
+
+ if !matches!(config.environment, Environment::Local)
+ && !config.sns_apns_voip_platform_arn.is_set()
+ {
+ anyhow::bail!("SNS_APNS_VOIP_PLATFORM_ARN must be provided");
+ }
+
+ Ok(config)
+ }
+
+ pub fn sns_apns_voip_platform_arn(&self) -> &str {
+ self.sns_apns_voip_platform_arn.value().unwrap_or("")
}
}
diff --git a/rust/cloud-storage/notification_service/src/env.rs b/rust/cloud-storage/notification_service/src/env.rs
index 0a093851e1..3bb9e9f848 100644
--- a/rust/cloud-storage/notification_service/src/env.rs
+++ b/rust/cloud-storage/notification_service/src/env.rs
@@ -1,3 +1,4 @@
+use crate::config::SenderBaseAddress;
use macro_env::Environment;
use std::sync::LazyLock;
@@ -9,8 +10,9 @@ pub static SENDER_ADDRESS: LazyLock<String> = LazyLock::new(|| {
};
// The SENDER_BASE_ADDRESS is part of the config so the service will fail without it, we can
- // safely unwrap here
- let sender_base_address = std::env::var("SENDER_BASE_ADDRESS").unwrap();
+ // safely expect it here. Use macro_config so APP_SECRETS_JSON is supported too.
+ let sender_base_address = SenderBaseAddress::new()
+ .expect("SENDER_BASE_ADDRESS must be provided via APP_SECRETS_JSON or env");
- format!("no-reply{}@{}", prefix, sender_base_address)
+ format!("no-reply{}@{}", prefix, sender_base_address.as_ref())
});
diff --git a/rust/cloud-storage/notification_service/src/main.rs b/rust/cloud-storage/notification_service/src/main.rs
index 26860de8de..687f7d725d 100644
--- a/rust/cloud-storage/notification_service/src/main.rs
+++ b/rust/cloud-storage/notification_service/src/main.rs
@@ -18,7 +18,6 @@ use hmac::{Hmac, Mac};
use macro_auth::middleware::decode_jwt::JwtValidationArgs;
use macro_entrypoint::MacroEntrypoint;
use macro_env::Environment;
-use macro_middleware::auth::internal_access::InternalApiSecretKey;
use macro_service_urls::ConnectionGatewayUrl;
use secretsmanager_client::SecretManager;
use sha2::Sha256;
@@ -49,7 +48,7 @@ pub async fn main() -> anyhow::Result<()> {
let db = PgPoolOptions::new()
.min_connections(min_connections)
.max_connections(max_connections)
- .connect(&config.database_url)
+ .connect(config.database_url.as_ref())
.await
.context("could not connect to db")?;
@@ -66,21 +65,20 @@ pub async fn main() -> anyhow::Result<()> {
);
let internal_secret_key = secretsmanager_client
- .get_maybe_secret_value(config.environment, InternalApiSecretKey::new()?)
+ .get_maybe_secret_value(config.environment, config.internal_api_secret_key.clone())
.await?;
let unsubscribe_hmac_secret = secretsmanager_client
- .get_maybe_secret_value(config.environment, config::UrlSigningHmac::new()?)
+ .get_maybe_secret_value(config.environment, config.url_signing_hmac.clone())
.await?;
- let vars = config::Vars::new()?;
let connection_gateway_url = ConnectionGatewayUrl::new()?.to_string();
let hmac_key = Hmac::<Sha256>::new_from_slice(unsubscribe_hmac_secret.as_ref().as_bytes())
.expect("HMAC accepts any key size");
let redis_client =
- redis::Client::open(vars.redis_uri.as_ref()).expect("failed to create redis client");
+ redis::Client::open(config.redis_uri.as_ref()).expect("failed to create redis client");
#[cfg(feature = "push_notification_event_handler")]
{
@@ -118,7 +116,7 @@ pub async fn main() -> anyhow::Result<()> {
let event_queue =
::notification::outbound::push_notification_event_queue::SqsPushNotificationEventQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- config.push_notification_event_handler_queue.clone(),
+ config.push_notification_event_handler_queue.as_ref().to_string(),
config.notification_queue_max_messages,
config.notification_queue_wait_time_seconds,
);
@@ -141,16 +139,16 @@ pub async fn main() -> anyhow::Result<()> {
let notification_queue = ::notification::outbound::queue::SqsQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- vars.notification_queue.as_ref().to_string(),
+ config.notification_queue.as_ref().to_string(),
);
let sns_endpoint_manager =
::notification::outbound::sns_endpoint::SnsEndpointManagerAdapter::new(
aws_sdk_sns::Client::new(&aws_config),
);
let platform_config = ::notification::domain::service::PlatformArnConfig {
- apns_platform_arn: config.sns_apns_platform_arn.clone(),
- fcm_platform_arn: config.sns_fcm_platform_arn.clone(),
- apns_voip_platform_arn: config.sns_apns_voip_platform_arn.clone(),
+ apns_platform_arn: config.sns_apns_platform_arn.as_ref().to_string(),
+ fcm_platform_arn: config.sns_fcm_platform_arn.as_ref().to_string(),
+ apns_voip_platform_arn: config.sns_apns_voip_platform_arn().to_string(),
};
let reader_realtime_adapter = WebSocketGatewayAdapter::new(ConnectionGatewayClient::new(
internal_secret_key.as_ref().to_string(),
@@ -196,7 +194,7 @@ pub async fn main() -> anyhow::Result<()> {
let mobile_adapter = MobilePushAdapter {
push_service: aws_sdk_sns::Client::new(&aws_config),
- apns_bundle_id: vars.apple_bundle_id.as_ref().to_string(),
+ apns_bundle_id: config.apple_bundle_id.as_ref().to_string(),
voip_bundle_id: None,
};
@@ -257,13 +255,21 @@ pub async fn main() -> anyhow::Result<()> {
worker.run_digests(digest_batch_to_email).await
});
- // Set up ingress worker for processing notification requests from the ingress queue
- let ingress_redis_conn = redis::Client::open(vars.redis_uri.as_ref())
+ // Set up ingress worker for processing notification requests from the ingress queue.
+ // Keep digest/rate-limit Redis usage on REDIS_URI, but read last-online state from the
+ // connection-gateway Redis because that is where websocket presence is recorded.
+ let ingress_redis_conn = redis::Client::open(config.redis_uri.as_ref())
.expect("failed to create redis client for ingress")
.get_multiplexed_async_connection()
.await
.context("failed to get redis connection for ingress state machine")?;
+ let last_online_redis_conn = redis::Client::open(config.last_online_redis_uri.as_ref())
+ .expect("failed to create redis client for last online checker")
+ .get_multiplexed_async_connection()
+ .await
+ .context("failed to get redis connection for last online checker")?;
+
let ingress_state_machine =
::notification::domain::models::email_notification_digest::StateMachineDriverA::new_with_defaults(
::notification::outbound::user_existence_checker::DbUserExistenceChecker::new(
@@ -276,7 +282,7 @@ pub async fn main() -> anyhow::Result<()> {
last_online_tracker::domain::services::LastOnlineService::new(
last_online_tracker::outbound::time::DefaultTime,
last_online_tracker::outbound::redis::RedisLastOnlineRepo::new(
- ingress_redis_conn.clone(),
+ last_online_redis_conn,
),
),
),
@@ -288,7 +294,7 @@ pub async fn main() -> anyhow::Result<()> {
::notification::outbound::repository::DbNotificationRepository::new(db.clone());
let ingress_delivery_queue = ::notification::outbound::queue::SqsQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- vars.notification_queue.as_ref().to_string(),
+ config.notification_queue.as_ref().to_string(),
);
let ingress_service = ::notification::domain::service::NotificationIngressService::new(
ingress_repository,
@@ -298,7 +304,7 @@ pub async fn main() -> anyhow::Result<()> {
let ingress_queue = ::notification::outbound::queue::SqsQueue::new(
aws_sdk_sqs::Client::new(&aws_config),
- vars.notification_ingress_queue.as_ref().to_string(),
+ config.notification_ingress_queue.as_ref().to_string(),
);
let ingress_worker =
::notification::inbound::ingress_worker::IngressWorker::new(ingress_service, ingress_queue);