-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from pipeless-ai/add_redis_event_exporter
feat: Add redis event exporter
- Loading branch information
Showing
10 changed files
with
267 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::fmt; | ||
use log::warn; | ||
|
||
pub enum EventType { | ||
StreamStartError, | ||
StreamFinished, | ||
} | ||
impl fmt::Display for EventType { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
EventType::StreamStartError => write!(f, "StreamStartError"), | ||
EventType::StreamFinished => write!(f, "StreamFinished"), | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* Exports a stream finished event to the external event exporter when it is enabled | ||
*/ | ||
pub async fn export_stream_finished_event(stream_uuid: uuid::Uuid, stream_end_state: &str) { | ||
let ext_event: serde_json::Value = serde_json::json!({ | ||
"type": EventType::StreamFinished.to_string(), | ||
"end_state": stream_end_state, | ||
"stream_uuid": stream_uuid.to_string(), | ||
}); | ||
let ext_event_json_str = serde_json::to_string(&ext_event); | ||
if let Ok(json_str) = ext_event_json_str { | ||
super::EVENT_EXPORTER.lock().await.publish(&json_str).await; | ||
} else { | ||
warn!("Error serializing event to JSON string, skipping external publishing"); | ||
} | ||
} | ||
|
||
/* | ||
* Exports a stream start error event to the external event exporter when it is enabled | ||
*/ | ||
pub async fn export_stream_start_error_event(stream_uuid: uuid::Uuid) { | ||
let ext_event: serde_json::Value = serde_json::json!({ | ||
"type": EventType::StreamStartError.to_string(), | ||
"end_state": "error", | ||
"stream_uuid": stream_uuid.to_string(), | ||
}); | ||
let ext_event_json_str = serde_json::to_string(&ext_event); | ||
if let Ok(json_str) = ext_event_json_str { | ||
super::EVENT_EXPORTER.lock().await.publish(&json_str).await; | ||
} else { | ||
warn!("Error serializing event to JSON string, skipping external publishing"); | ||
} | ||
} |
Oops, something went wrong.