huskies: merge 1033
This commit is contained in:
@@ -295,6 +295,34 @@ pub async fn run_bot(
|
||||
);
|
||||
}
|
||||
|
||||
// Subscribe to pipeline stage transitions and buffer compact audit lines
|
||||
// between Timmy's turns. Replay events (before == after stage label) are
|
||||
// silently dropped — only real transitions are recorded.
|
||||
let pending_pipeline_events: Arc<TokioMutex<Vec<String>>> =
|
||||
Arc::new(TokioMutex::new(Vec::new()));
|
||||
{
|
||||
use crate::pipeline_state::{format_audit_entry, stage_label, subscribe_transitions};
|
||||
let mut rx = subscribe_transitions();
|
||||
let buf = Arc::clone(&pending_pipeline_events);
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(fired) => {
|
||||
if stage_label(&fired.before) == stage_label(&fired.after) {
|
||||
continue;
|
||||
}
|
||||
let line = format_audit_entry(&fired);
|
||||
buf.lock().await.push(line);
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(n)) => {
|
||||
slog!("[matrix-bot] pipeline event buffer lagged by {n} events");
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Closed) => break,
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let ctx = BotContext {
|
||||
services,
|
||||
matrix_user_id: bot_user_id,
|
||||
@@ -309,6 +337,7 @@ pub async fn run_bot(
|
||||
gateway_active_project,
|
||||
gateway_projects,
|
||||
gateway_project_urls,
|
||||
pending_pipeline_events,
|
||||
};
|
||||
|
||||
slog!(
|
||||
|
||||
Reference in New Issue
Block a user