huskies: merge 1126 story Gateway event aggregator with per-session scope filters (Timmy=All, Sally=single sled)
This commit is contained in:
@@ -613,6 +613,12 @@ pub async fn init_project(
|
||||
|
||||
/// Broadcast a status event received from a project node to all local subscribers.
|
||||
///
|
||||
/// For [`crate::service::events::StoredEvent::StageTransition`] events the
|
||||
/// transition is also appended to the gateway's CRDT event log using the
|
||||
/// project name as the `sled_id`. This builds the live tail-merged aggregate
|
||||
/// view that [`crate::crdt_state::assemble_and_advance_session`] reads when a
|
||||
/// session's [`crate::crdt_state::ScopeFilter`] is set to `All`.
|
||||
///
|
||||
/// Returns the number of active receivers that received the event.
|
||||
/// A return value of zero means no subscribers are currently connected.
|
||||
pub fn broadcast_status_event(
|
||||
@@ -620,6 +626,26 @@ pub fn broadcast_status_event(
|
||||
project: String,
|
||||
event: crate::service::events::StoredEvent,
|
||||
) -> usize {
|
||||
// Append StageTransition events to the gateway CRDT so the session
|
||||
// assembler can deliver a unified cross-sled event stream.
|
||||
if let crate::service::events::StoredEvent::StageTransition {
|
||||
ref story_id,
|
||||
ref from_stage,
|
||||
ref to_stage,
|
||||
timestamp_ms,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
let timestamp_secs = timestamp_ms as f64 / 1_000.0_f64;
|
||||
crate::crdt_state::append_event_log_entry(
|
||||
&project,
|
||||
timestamp_secs,
|
||||
story_id,
|
||||
from_stage,
|
||||
to_stage,
|
||||
"StageTransition",
|
||||
);
|
||||
}
|
||||
let msg = GatewayStatusEvent { project, event };
|
||||
state.event_tx.send(msg).unwrap_or(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user