Skip to content

Commit

Permalink
Concurrent execution of event handlers in dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
zaychenko-sergei committed Nov 23, 2023
1 parent 7611215 commit bbe8ed0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/utils/event-bus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ doctest = false
[dependencies]
internal-error = { workspace = true }
dill = "0.7"
futures = "0.3"

[dev-dependencies]
12 changes: 6 additions & 6 deletions src/utils/event-bus/src/event_bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ impl EventBus {
}
};

// TODO: concurrent launch
for handler in handlers.iter() {
(*handler)
.call((self.catalog.clone(), event.clone()))
.await?;
}
let handler_futures: Vec<_> = handlers
.iter()
.map(|handler| (*handler).call((self.catalog.clone(), event.clone())))
.collect();

futures::future::try_join_all(handler_futures).await?;

Ok(())
}
Expand Down

0 comments on commit bbe8ed0

Please sign in to comment.