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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! # Notifier
//!
//! Pluggable notification system for error alerts and incident tracking.
//!
//! ## Feature Flags
//!
//! This module requires the `notifier` feature to be enabled. Individual providers
//! are gated by their own features:
//!
//! - `notify-error-slack` - Slack webhook notifications
//! - `notify-error-discord` - Discord webhook notifications
//! - `notify-error-ntfy` - ntfy push notifications
//! - `notify-error-cmdline` - cmdline.io error tracking
//!
//! ## Architecture
//!
//! The notification system uses a trait-based approach where providers implement
//! [`ErrorNotifier`] to handle error events. The [`NotificationManager`] coordinates
//! multiple providers, sending events to all of them concurrently.
//!
//! ## Usage
//!
//! ### Simple setup with environment variables
//!
//! ```rust,ignore
//! use axtra::notifier::NotificationManager;
//! use axtra::errors::notifiers::init_notification_manager;
//!
//! // Auto-detects providers from env vars:
//! // - SLACK_ERROR_WEBHOOK_URL (+ optional SLACK_ERROR_MENTION)
//! // - DISCORD_ERROR_WEBHOOK_URL (+ optional DISCORD_ERROR_MENTION)
//! // - NTFY_TOPIC (+ optional NTFY_SERVER_URL, NTFY_ACCESS_TOKEN)
//! // - CMDLINE_API_KEY (+ optional ENVIRONMENT/ENV, SERVICE/APP_NAME, RELEASE/VERSION)
//! init_notification_manager(NotificationManager::from_env());
//! ```
//!
//! ### Builder pattern (recommended)
//!
//! ```rust,ignore
//! use axtra::notifier::{NotificationManager, SlackConfig, NtfyConfig, CmdlineConfig};
//! use axtra::errors::notifiers::init_notification_manager;
//!
//! let manager = NotificationManager::builder()
//! .with_slack(SlackConfig::new("https://hooks.slack.com/services/...")
//! .with_mention("@oncall"))
//! .with_ntfy(NtfyConfig::new("my-app-errors"))
//! .with_cmdline(CmdlineConfig::new(std::env::var("CMDLINE_API_KEY").unwrap())
//! .with_environment("production")
//! .with_service("my-app"))
//! .build();
//!
//! init_notification_manager(manager);
//! ```
//!
//! ### Custom provider
//!
//! ```rust,ignore
//! use axtra::notifier::{ErrorNotifier, ErrorEvent, NotifyError, NotifyFuture, NotificationManager};
//! use reqwest::Client;
//! use std::sync::Arc;
//!
//! struct PagerDutyProvider {
//! api_key: String,
//! }
//!
//! impl ErrorNotifier for PagerDutyProvider {
//! fn notify<'a>(&'a self, client: &'a Client, event: &'a ErrorEvent) -> NotifyFuture<'a> {
//! Box::pin(async move {
//! // POST to PagerDuty API
//! Ok(())
//! })
//! }
//!
//! fn name(&self) -> &'static str {
//! "pagerduty"
//! }
//! }
//!
//! let manager = NotificationManager::builder()
//! .with_provider(Arc::new(PagerDutyProvider { api_key: "...".into() }))
//! .build();
//! ```
//!
//! ## See Also
//! - [README](https://github.com/imothee-io/axtra)
//! - [docs.rs/axtra](https://docs.rs/axtra)
pub use ErrorEvent;
pub use ;
pub use ;
// Re-export provider configs at top level for convenience
pub use ;
pub use ;
pub use ;
pub use ;