Skip to content

feat: KafkaTransportOptions for configurable Kafka outbox transport#426

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-kafka-transport-options
Open

feat: KafkaTransportOptions for configurable Kafka outbox transport#426
Copilot wants to merge 2 commits intomainfrom
copilot/add-kafka-transport-options

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

Kafka was the only Pulse transport without a dedicated options class — topic creation used hard-coded partition count and replication factor with no way to configure retention or disable auto-creation.

Changes

New: KafkaTransportOptions

public sealed class KafkaTransportOptions
{
    public int DefaultPartitionCount { get; set; } = 1;
    public short DefaultReplicationFactor { get; set; } = 1;
    public bool AutoCreateTopics { get; set; } = true;
    public TimeSpan? MessageRetention { get; set; }
}

KafkaMessageTransport

  • Injects IOptions<KafkaTransportOptions>
  • Adds EnsureTopicAsync(): creates the topic before first produce to a given topic name, cached via ConcurrentDictionary to avoid redundant admin calls
  • Skips topic creation entirely when AutoCreateTopics = false
  • Applies retention.ms to topic config when MessageRetention is set
  • Handles TopicAlreadyExists errors gracefully

UseKafkaTransport() extension

  • Accepts optional Action<KafkaTransportOptions>? configureOptions = null
  • Registers IOptions<KafkaTransportOptions> via AddOptions/Configure
  • Fully backward-compatible — omitting the delegate preserves existing default behavior
services.AddPulse(config =>
    config.UseKafkaTransport(opt =>
    {
        opt.DefaultPartitionCount = 3;
        opt.DefaultReplicationFactor = 2;
        opt.MessageRetention = TimeSpan.FromDays(7);
    })
);

Tests

  • FakeAdminClient updated to track CreateTopicsAsync calls (CreatedTopics, CreateTopicsCallCount)
  • New tests covering: auto-create enabled/disabled, deduplication of topic creation, custom partition count, custom replication factor, custom retention, no retention config when unset, UseKafkaTransport with and without options delegate, constructor null guard

Copilot AI linked an issue Apr 18, 2026 that may be closed by this pull request
6 tasks
Copilot AI changed the title [WIP] Add KafkaTransportOptions for configurable Kafka outbox transport feat: KafkaTransportOptions for configurable Kafka outbox transport Apr 18, 2026
Copilot AI requested a review from samtrion April 18, 2026 06:08
@samtrion samtrion marked this pull request as ready for review April 18, 2026 10:53
@samtrion samtrion requested a review from a team as a code owner April 18, 2026 10:53
@samtrion samtrion force-pushed the copilot/add-kafka-transport-options branch from 85262ad to 8dbdfce Compare April 18, 2026 10:53
Copilot AI and others added 2 commits April 19, 2026 21:32
- Add KafkaTransportOptions with DefaultPartitionCount, DefaultReplicationFactor, AutoCreateTopics, MessageRetention
- Update KafkaMessageTransport to inject IOptions<KafkaTransportOptions> and auto-create topics
- Update UseKafkaTransport() to accept Action<KafkaTransportOptions>? configureOptions parameter
- Add unit tests for all new options (partition count, replication factor, AutoCreateTopics=false, retention, constructor null check)"

Agent-Logs-Url: https://github.com/dailydevops/pulse/sessions/6dda0741-f9e5-4596-9ad2-028cc33d0cbc

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
…essage justification

Agent-Logs-Url: https://github.com/dailydevops/pulse/sessions/6dda0741-f9e5-4596-9ad2-028cc33d0cbc

Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
@samtrion samtrion force-pushed the copilot/add-kafka-transport-options branch from 8dbdfce to b9ad6cb Compare April 19, 2026 19:32
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.19%. Comparing base (890cdb6) to head (b9ad6cb).

Files with missing lines Patch % Lines
...Evolve.Pulse.Kafka/Outbox/KafkaMessageTransport.cs 90.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #426      +/-   ##
==========================================
+ Coverage   92.13%   92.19%   +0.06%     
==========================================
  Files         151      152       +1     
  Lines        5591     5626      +35     
  Branches      524      529       +5     
==========================================
+ Hits         5151     5187      +36     
+ Misses        292      291       -1     
  Partials      148      148              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: KafkaTransportOptions for configurable Kafka outbox transport

2 participants