We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d9f3f9f commit f61369fCopy full SHA for f61369f
sgl-model-gateway/src/workflow/event.rs
@@ -74,12 +74,11 @@ impl EventBus {
74
self.subscribers.write().await.push(subscriber);
75
}
76
77
- /// Publish an event to all subscribers
+ /// Publish an event to all subscribers concurrently
78
pub async fn publish(&self, event: WorkflowEvent) {
79
let subscribers = self.subscribers.read().await;
80
- for subscriber in subscribers.iter() {
81
- subscriber.on_event(&event).await;
82
- }
+ let futures: Vec<_> = subscribers.iter().map(|s| s.on_event(&event)).collect();
+ futures::future::join_all(futures).await;
83
84
85
0 commit comments