Skip to content

feat: KafkaTransportOptions for configurable Kafka outbox transport#426

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

feat: KafkaTransportOptions for configurable Kafka outbox transport#426
Copilot wants to merge 3 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 2 times, most recently 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.54%. Comparing base (4ffc7d8) to head (6ce24e9).
⚠️ Report is 1 commits behind head on main.

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.43%   92.54%   +0.11%     
==========================================
  Files         159      160       +1     
  Lines        5960     5995      +35     
  Branches      539      544       +5     
==========================================
+ Hits         5509     5548      +39     
+ Misses        298      294       -4     
  Partials      153      153              

☔ 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.

@samtrion samtrion force-pushed the copilot/add-kafka-transport-options branch from b9ad6cb to 5b940d1 Compare April 20, 2026 09:37
Copilot AI and others added 2 commits April 20, 2026 17:35
- 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 5b940d1 to 5f8c8e8 Compare April 20, 2026 15:35
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