runtime: route notifications through worker inbox

This commit is contained in:
2026-08-05 01:44:57 +09:00
parent dd2ca54874
commit f98a123e40
15 changed files with 614 additions and 811 deletions
+23 -3
View File
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
#[serde(rename_all = "snake_case")]
pub enum WorkerInputKind {
User,
System,
Notify,
Compact,
ListRewindTargets,
RegisterPeer,
@@ -38,15 +38,35 @@ impl WorkerInput {
}
}
pub fn system(content: impl Into<String>) -> Self {
pub fn notify(content: impl Into<String>) -> Self {
Self {
kind: WorkerInputKind::System,
kind: WorkerInputKind::Notify,
content: content.into(),
segments: None,
}
}
}
#[cfg(test)]
mod tests {
use super::WorkerInput;
#[test]
fn notify_is_an_operation_and_legacy_system_kind_is_rejected() {
assert_eq!(
serde_json::to_value(WorkerInput::notify("message")).unwrap(),
serde_json::json!({ "kind": "notify", "content": "message" })
);
assert!(
serde_json::from_value::<WorkerInput>(serde_json::json!({
"kind": "system",
"content": "message"
}))
.is_err()
);
}
}
/// Acknowledgement returned after input is accepted into the Worker.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct WorkerInteractionAck {