Farfetch / kafkaflow

Apache Kafka .NET Framework to create applications simple to use and extend.
https://farfetch.github.io/kafkaflow/
MIT License
634 stars 110 forks source link

[Bug Report]: OnStarted is not aggregating handlers #569

Closed shlomiassaf closed 2 months ago

shlomiassaf commented 3 months ago

Prerequisites

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:

1) Making it asyncable (via ValueTask ?) 2) Add resolution by introducing OnStarted in the builder for consumer creation so in the consumer builder we can handle the consumer creation and get the IConsumer.

KafkaFlow version

3.0.8

Thank you!

joelfoliveira commented 2 months ago

Please check the following PR with the fix: https://github.com/Farfetch/kafkaflow/pull/573/

Regarding the other 2 points: