This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
60 additions
and
44 deletions.
There are no files selected for viewing
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
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,13 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::api::CaptureError; | ||
use crate::event::ProcessedEvent; | ||
|
||
pub mod kafka; | ||
pub mod print; | ||
|
||
#[async_trait] | ||
pub trait EventSink { | ||
async fn send(&self, event: ProcessedEvent) -> Result<(), CaptureError>; | ||
async fn send_batch(&self, events: Vec<ProcessedEvent>) -> Result<(), CaptureError>; | ||
} |
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,31 @@ | ||
use async_trait::async_trait; | ||
use metrics::{counter, histogram}; | ||
use tracing::log::info; | ||
|
||
use crate::api::CaptureError; | ||
use crate::event::ProcessedEvent; | ||
use crate::sinks::EventSink; | ||
|
||
pub struct PrintSink {} | ||
|
||
#[async_trait] | ||
impl EventSink for PrintSink { | ||
async fn send(&self, event: ProcessedEvent) -> Result<(), CaptureError> { | ||
info!("single event: {:?}", event); | ||
counter!("capture_events_ingested_total", 1); | ||
|
||
Ok(()) | ||
} | ||
async fn send_batch(&self, events: Vec<ProcessedEvent>) -> Result<(), CaptureError> { | ||
let span = tracing::span!(tracing::Level::INFO, "batch of events"); | ||
let _enter = span.enter(); | ||
|
||
histogram!("capture_event_batch_size", events.len() as f64); | ||
counter!("capture_events_ingested_total", events.len() as u64); | ||
for event in events { | ||
info!("event: {:?}", event); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
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