/** * Feature-flag config for the Phase 1 async notifications path (RFC-004 / GOO-173). * * When NOTIFICATIONS_ASYNC_ENABLED is `true`, producers route through * `NotificationsPublisher` → outbox → Redis Streams → BullMQ consumer. * When `false` (default until parity is confirmed in production), producers * continue to execute `SendNotificationCommand` directly in-process. * * Kept as a tiny injectable so: * - callers don't read process.env directly (testability) * - we have one place to evolve the flag shape (per-category rollout, * percentage shadowing, etc.) without ripping through listeners again */ import { Injectable } from '@nestjs/common'; const FLAG_ENV = 'NOTIFICATIONS_ASYNC_ENABLED'; @Injectable() export class NotificationsAsyncConfig { /** True when the async outbox path should be used for new notifications. */ get asyncEnabled(): boolean { const raw = process.env[FLAG_ENV]; if (raw === undefined) return false; const v = raw.trim().toLowerCase(); return v === '1' || v === 'true' || v === 'yes' || v === 'on'; } /** Exposed for observability / startup logs. */ describe(): string { return `${FLAG_ENV}=${this.asyncEnabled ? 'enabled' : 'disabled'}`; } }