Skip to content

[WIP] [Host.Kafka] Add configurable client builder factories with logging support#467

Open
saneks222 wants to merge 1 commit into
zarusz:masterfrom
saneks222:master
Open

[WIP] [Host.Kafka] Add configurable client builder factories with logging support#467
saneks222 wants to merge 1 commit into
zarusz:masterfrom
saneks222:master

Conversation

@saneks222
Copy link
Copy Markdown

Summary
Enhances the Kafka transport provider by adding a KafkaClientConfig wrapper to the producer and consumer builder factories. This allows custom factories to access both the Confluent client configuration and an ILogger instance, enabling more flexible client.

What's included

  • New KafkaClientConfig class — wraps ConfluentConfig (of type T : ClientConfig) and an ILogger to provide full context for builder factories

  • Updated factory — ProducerBuilderFactory and ConsumerBuilderFactory now accept KafkaClientConfig and KafkaClientConfig respectively, instead of raw ProducerConfig/ConsumerConfig

  • Logger propagation — passes the SMB logger through to custom factories so consumers/producers can be instrumented consistently

  • Backward compatibility preserved — default factories continue to work using the ConfluentConfig property internally

  • Refactored internal creation — CreateConsumer() and CreateProducerInternal() now construct KafkaClientConfig with the appropriate config and logger

wip
Signed-off-by: Aleksandr Kiselev <saneks222@yandex.ru>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@zarusz
Copy link
Copy Markdown
Owner

zarusz commented May 13, 2026

@saneks222 you’re definitely on the right track here. Also, to get the DCO gate passing, please follow the sign-off requirement.

I was wondering whether we should go beyond just ILogger and make this a bit more flexible for cases where people need additional dependencies in the factory. For example, we could:

  • pass IServiceProvider, allowing additional dependencies to be resolved
  • if ProducerBuilder / ConsumerBuilder is registered in MSDI, try resolving it first before falling back to the factory Func

That said, this might not be worth it if it adds too much complexity.

What do you think?

@saneks222
Copy link
Copy Markdown
Author

@saneks222 you’re definitely on the right track here. Also, to get the DCO gate passing, please follow the sign-off requirement.

I was wondering whether we should go beyond just ILogger and make this a bit more flexible for cases where people need additional dependencies in the factory. For example, we could:

  • pass IServiceProvider, allowing additional dependencies to be resolved
  • if ProducerBuilder / ConsumerBuilder is registered in MSDI, try resolving it first before falling back to the factory Func

That said, this might not be worth it if it adds too much complexity.

What do you think?

I like the idea of passing IServiceProvider - it will give users more flexibility when configuring things. I could pass it into KafkaMessageBusSettings, taking it from MessageBusBuilder.Settings when creating an instance in the WithProviderKafka method. What do you think about this?

Regarding ProducerBuilder / ConsumerBuilder - I didn't see them being registered anywhere in MSDI, so I don't really understand how we could try to resolve them from there.

Regarding the sign-off requirement - the first time I really did commit without a signature, but later I fixed it according to the instructions. The signature is now visible in the commit description. I don't quite understand why the CI/CD is still not happy with this. Maybe I missed something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants