fc-common: add AlertConfig and AlertManager for error tracking

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iaf2f52f6e0cf33e3275528ac13cd92046a6a6964
This commit is contained in:
raf 2026-02-14 01:37:09 +03:00
commit ec5fbb453d
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 108 additions and 2 deletions

View file

@ -118,6 +118,25 @@ pub struct NotificationsConfig {
pub gitlab_url: Option<String>,
pub gitlab_token: Option<String>,
pub email: Option<EmailConfig>,
pub alerts: Option<AlertConfig>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct AlertConfig {
pub enabled: bool,
pub error_threshold: f64,
pub time_window_minutes: i64,
}
impl Default for AlertConfig {
fn default() -> Self {
Self {
enabled: false,
error_threshold: 20.0,
time_window_minutes: 60,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
@ -220,8 +239,8 @@ pub struct DeclarativeProject {
/// Declarative notification configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeclarativeNotification {
/// Notification type: `github_status`, email, `gitlab_status`, `gitea_status`,
/// `run_command`
/// Notification type: `github_status`, email, `gitlab_status`,
/// `gitea_status`, `run_command`
pub notification_type: String,
/// Type-specific configuration (JSON object)
pub config: serde_json::Value,