1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Statics and resolve-once knobs for the native `NotificationService`: entity
//! message ids, the delivery batch/interval + provider-config env keys, the stable
//! machine-readable error reasons, the test-only sentinel/gate, the versioned
//! sent/delivery dot-topics, and the pure derivations over them
//! (`notification_delivery_interval`, `delivery_event_topic`). Extracted verbatim
//! from the former god file.
use OnceLock;
use Duration;
pub const LOG_MSG: &str = "udb.core.notification.entity.v1.NotificationLog";
pub const TEMPLATE_MSG: &str = "udb.core.notification.entity.v1.NotificationTemplate";
pub const PREFERENCE_MSG: &str = "udb.core.notification.entity.v1.NotificationPreference";
/// Native message id for the master-plan 9.13 delivery-status record.
pub const DELIVERY_ATTEMPT_MSG: &str =
"udb.core.notification.entity.v1.NotificationDeliveryAttempt";
pub const TEMPLATE_LOCALE_MAX_CHARS: usize = 10;
pub const NOTIFICATION_DELIVERY_BATCH: i64 = 200;
pub const DEFAULT_NOTIFICATION_DELIVERY_INTERVAL_SECS: u64 = 30;
pub const NOTIFICATION_DELIVERY_INTERVAL_ENV: &str =
"UDB_NOTIFICATION_DELIVERY_INTERVAL_SECS";
pub const NOTIFICATION_DELIVERY_PROVIDERS_ENV: &str =
"UDB_NOTIFICATION_DELIVERY_PROVIDERS_JSON";
// Stable machine-readable error reasons (google.rpc.ErrorInfo-style `reason`),
// attached to the returned `Status` metadata under `error-reason` so SDK clients
// can branch on a fixed code instead of free-text messages. Only reasons with a
// LIVE failure path are fired here. `TEMPLATE_INACTIVE`/`PROVIDER_UNAVAILABLE`
// have no reachable site and are intentionally NOT defined.
/// No template matched the (event_type, channel, locale, tenant) scope on send.
pub const TEMPLATE_NOT_FOUND: &str = "TEMPLATE_NOT_FOUND";
/// A `{{placeholder}}` in the matched template had no value in `req.variables`.
pub const VARIABLE_MISSING: &str = "VARIABLE_MISSING";
/// Reserved: recipient opted out of the (channel, event) — currently handled as a
/// SUPPRESSED log row, not an error, so no live site fires this reason yet.
pub const RECIPIENT_OPTED_OUT: &str = "RECIPIENT_OPTED_OUT";
/// Retry was requested for a notification that is not in a retryable state.
pub const NOT_RETRYABLE_STATE: &str = "NOT_RETRYABLE_STATE";
/// Test-only sentinel (TODO 04.4.2.2): when `test_mode_enabled()` is true AND a
/// `SendNotification` request carries this exact value in `resource_type`, each
/// per-channel log is written as FAILED so `retry_notification` has a real
/// retryable row to exercise. Unreachable in production: the env gate defaults
/// false, so production sends ignore this value entirely.
pub const TEST_FORCE_FAILED_SENTINEL: &str = "__perf_force_failed__";
/// Kafka topic for the "notification sent" domain event.
pub const NOTIFICATION_SENT_TOPIC: &str = "udb.notification.sent.v1";
/// Whether the notification test harness is enabled (resolved once). Fail-closed
/// default: production never sets `UDB_NOTIFICATION_TEST_MODE`, so the test-only
/// forced-FAILED send path below is unreachable in production. Mirrors the exact
/// shape of `auth_service::authn::webauthn_softauth::test_mode_enabled`.
pub
pub
/// The versioned dot-topic a terminal delivery outcome is published on
/// (master-plan 9.13): `udb.notification.delivery.<status>.v1`, e.g.
/// `udb.notification.delivery.delivered.v1`. Pure + unit-tested.
pub