diff --git a/sgl-model-gateway/src/workflow/event.rs b/sgl-model-gateway/src/workflow/event.rs index a21aaad75..84522841e 100644 --- a/sgl-model-gateway/src/workflow/event.rs +++ b/sgl-model-gateway/src/workflow/event.rs @@ -74,12 +74,11 @@ impl EventBus { self.subscribers.write().await.push(subscriber); } - /// Publish an event to all subscribers + /// Publish an event to all subscribers concurrently pub async fn publish(&self, event: WorkflowEvent) { let subscribers = self.subscribers.read().await; - for subscriber in subscribers.iter() { - subscriber.on_event(&event).await; - } + let futures: Vec<_> = subscribers.iter().map(|s| s.on_event(&event)).collect(); + futures::future::join_all(futures).await; } }