fix(usage): preserve full bodies before queue truncation

This commit is contained in:
ZheFox
2026-09-16 13:10:40 +08:00
parent 72a4bf3408
commit 5842c7232e
6 changed files with 216 additions and 4 deletions
+11 -1
View File
@@ -104,6 +104,13 @@ impl UsageQueue {
pub async fn enqueue(&self, event: &UsageEvent) -> Result<String, DataLayerError> {
let encoded = self.encode_event(event)?;
self.enqueue_encoded(encoded).await
}
pub(crate) async fn enqueue_encoded(
&self,
encoded: EncodedUsageEvent,
) -> Result<String, DataLayerError> {
self.runner
.append_fields_with_maxlen(
&self.stream,
@@ -117,7 +124,10 @@ impl UsageQueue {
self.encode_event(event).map(|_| ())
}
fn encode_event(&self, event: &UsageEvent) -> Result<EncodedUsageEvent, DataLayerError> {
pub(crate) fn encode_event(
&self,
event: &UsageEvent,
) -> Result<EncodedUsageEvent, DataLayerError> {
let encoded = match event.to_bounded_stream_fields(self.config.queue_payload_max_bytes) {
Ok(encoded) => encoded,
Err(error) => {