Merge nucleic/sleek-thistle-egret-fyej into dev
This commit is contained in:
@@ -82,6 +82,18 @@ enum Event {
|
||||
hash: String,
|
||||
preview_b64: String,
|
||||
},
|
||||
#[serde(rename = "pipe", rename_all = "camelCase")]
|
||||
Pipe {
|
||||
seq: u64,
|
||||
ts: u64,
|
||||
pipeline_id: u64,
|
||||
from_index: u64,
|
||||
to_index: u64,
|
||||
bytes: u64,
|
||||
truncated: bool,
|
||||
hash: String,
|
||||
preview_b64: String,
|
||||
},
|
||||
#[serde(rename = "dropped", rename_all = "camelCase")]
|
||||
Dropped { seq: u64, ts: u64, count: u64 },
|
||||
}
|
||||
@@ -460,6 +472,25 @@ impl brush_core::gate::Gate for RecordingGate {
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
fn on_pipe(&self, ev: brush_core::gate::PipeEvent) {
|
||||
let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
let Some(obs) = OBSERVER.get() else { return };
|
||||
let capped = ev.captured.len().min(PREVIEW_CAP);
|
||||
obs.send(Event::Pipe {
|
||||
seq: obs.seq(),
|
||||
ts: now_millis(),
|
||||
pipeline_id: ev.pipeline_id,
|
||||
from_index: ev.from_index as u64,
|
||||
to_index: ev.to_index as u64,
|
||||
bytes: ev.total_bytes,
|
||||
truncated: ev.truncated || ev.captured.len() > capped,
|
||||
// Hash over the captured prefix (the full stream isn't buffered).
|
||||
hash: fnv1a_hex(&ev.captured),
|
||||
preview_b64: preview_b64(&ev.captured[..capped]),
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user