Skip to content

Commit f61369f

Browse files
slin1237Prozac614
authored andcommitted
[model-gateway] Run workflow event subscribers concurrently (sgl-project#15504)
1 parent d9f3f9f commit f61369f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sgl-model-gateway/src/workflow/event.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ impl EventBus {
7474
self.subscribers.write().await.push(subscriber);
7575
}
7676

77-
/// Publish an event to all subscribers
77+
/// Publish an event to all subscribers concurrently
7878
pub async fn publish(&self, event: WorkflowEvent) {
7979
let subscribers = self.subscribers.read().await;
80-
for subscriber in subscribers.iter() {
81-
subscriber.on_event(&event).await;
82-
}
80+
let futures: Vec<_> = subscribers.iter().map(|s| s.on_event(&event)).collect();
81+
futures::future::join_all(futures).await;
8382
}
8483
}
8584

0 commit comments

Comments
 (0)