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
//! Error notification handlers using the pluggable notification system.
//!
//! This module provides a global [`NotificationManager`] that can be configured
//! at application startup to send error notifications to multiple providers.
//!
//! ## Usage
//!
//! ```rust,ignore
//! use axtra::notifier::NotificationManager;
//! use axtra::errors::notifiers::init_notification_manager;
//!
//! // Option 1: Auto-configure from environment variables
//! init_notification_manager(NotificationManager::from_env());
//!
//! // Option 2: Manual configuration
//! let manager = NotificationManager::builder()
//! .with_slack("https://hooks.slack.com/services/...")
//! .build();
//! init_notification_manager(manager);
//! ```
use crateNotificationManager;
use OnceLock;
static NOTIFICATION_MANAGER: = new;
/// Initialize the global notification manager.
///
/// This should be called once at application startup. If called multiple times,
/// subsequent calls are ignored and the original manager is retained.
///
/// # Example
///
/// ```rust,ignore
/// use axtra::notifier::NotificationManager;
/// use axtra::errors::notifiers::init_notification_manager;
///
/// init_notification_manager(NotificationManager::from_env());
/// ```
/// Get a reference to the global notification manager.
///
/// Returns `None` if the manager hasn't been initialized. In that case,
/// a default manager will be created from environment variables on first
/// notification attempt.