Publish alert event to a CDC topic.
(state: &SharedState, tenant_id: u64, topic_name: &str, event: &AlertEvent)
| 66 | |
| 67 | /// Publish alert event to a CDC topic. |
| 68 | fn notify_topic(state: &SharedState, tenant_id: u64, topic_name: &str, event: &AlertEvent) { |
| 69 | let payload = match sonic_rs::to_string(event) { |
| 70 | Ok(p) => p, |
| 71 | Err(e) => { |
| 72 | warn!(alert = event.alert_name, error = %e, "failed to serialize alert event"); |
| 73 | return; |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | match crate::event::topic::publish::publish_to_topic(state, tenant_id, topic_name, &payload) { |
| 78 | Ok(seq) => { |
| 79 | info!( |
| 80 | alert = event.alert_name, |
| 81 | topic = topic_name, |
| 82 | seq, |
| 83 | status = event.status, |
| 84 | "alert event published to topic" |
| 85 | ); |
| 86 | } |
| 87 | Err(e) => { |
| 88 | warn!( |
| 89 | alert = event.alert_name, |
| 90 | topic = topic_name, |
| 91 | error = %e, |
| 92 | "failed to publish alert event to topic" |
| 93 | ); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// HTTP POST alert event to a webhook URL using a shared `reqwest::Client`. |
| 99 | /// |
no test coverage detected