[Bug Report]: OnStarted is not aggregating handlers
shlomiassaf opened this issue · comments
Prerequisites
- I have searched issues to ensure it has not already been reported
Description
IClusterConfigurationBuilder.OnStarted
accepts an delegate to execute after the cluster manager loaded all consumers and their workers are starting.
It is a public API so it is available for use for both user customization and external libraries.
For example, KafkaFlow.Admin
is using it to start the ITelemetryScheduler
to periodically send telemetry to the admin.
This will not work if the user opted-in to the startup as well, or if 2 extensions require this hook. Only 1 will work.
Expected behavior
I belive this should behave like an event as it's misleading and hard to reason about.
As a side not, we should also consider:
- Making it asyncable (via
ValueTask
?) - Add resolution by introducing
OnStarted
in the builder for consumer creation so in the consumer builder we can handle the consumer creation and get theIConsumer
.
KafkaFlow version
3.0.8
Thank you!
Please check the following PR with the fix: #573
Regarding the other 2 points:
- Making the call async would cause a breaking change, we can evaluate this for version 4.0. Nevertheless, the invocation in these events should be brief, do you have any particular use case to make async calls here?
- The Action already has a reference to the DependencyResolver, but the IConsumer instance is not available here, can you give an example why you need IConsumer here?