Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Abstract confluent builders into factories #624

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robertcoltheart
Copy link
Contributor

Description

Fixes #623

Moves the Confluent producer/consumer builder logic into abstractions that can provide an integration point for an in-memory broker, for use in unit and integration testing.

Currently we need to run a real Kafka server (or docker container) to run our testing suite, but it would be nicer (and faster) if we could control the broker configuration in such a way to move messages around in memory without needing a live Kafka server.

A follow up change to this could be an in-memory broker Nuget package that can be used for testing purposes.

The use case for this would be something like this:

var services = new ServiceCollection()
    .AddKafka(...);

services.AddSingleton<IProducerBuilderFactory, InMemoryProducerBuilderFactory>(); // Replaces the default factory

public class InMemoryProducerBuilderFactory : IProducerBuilderFactory
{
    public IProducerBuilder CreateProducerBuilder(ProducerConfig config)
    {
        return new InMemoryProducerBuilder();
    }
}

public class InMemoryProducerBuilder : IProducerBuilder
{
    public IProducer<byte[], byte[]> Build()
    {
        return new InMemoryProducer();
    }
}

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have made corresponding changes to the documentation

Disclaimer

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement

@robertcoltheart robertcoltheart changed the title feat: abstract confluent builders into factories feat: Abstract confluent builders into factories Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Abstract Kafka configuration builders so that consumers can insert custom logic
1 participant