← Back to Pull requests

Add record and partition EOF #275

Closed
unknown closed this pull request without merging on Nov 13, 2026 23:26 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 21:29 UTC
Author

Handle PartitionEOF event on Consumer messages

Motivation:

Sometimes, you may wish to consume the events of a topic until the EOF event partition and then stop consuming. This is useful when you want to restart a service or an event-sourced entity, and only make it available once it has caught up with the last known EOF event.

This tackles https://github.com/swift-server/swift-kafka-client/issues/124 by adding an enumeration to the Messages sequence with the partition EOF event. The consumer decides what to do with this message.

The partition EOF event is only available when KafkaConsumerConfig.enablePartitionEof is enabled

Modifications:

  • Makes KafkaConsumer.Message and enum with the associative cases record and partitionEOF, where record contains the previous contained information of Message. partitionEOF contains the partition, topic and offset of the EOF event.
  • This PR has also the changes of https://github.com/swift-server/swift-kafka-client/pull/274 which wraps offsets functionality of librdkafka (get_watermark_offsets , query_watermark_offsets , and offsets_for_times)

    Result:

    We can do the following for a one-shot read messages until the last tracked EOF and quit:

    ```swift
    let consumed = try await KafkaConsumer.withConsumer(config: consumerConfig) { _, messages, _ in
    var received = [KafkaConsumer.Message.Record]()
    messageStream: for try await message in messages {
    switch message {
    case .record(let record):
    received.append(record)
    case .partitionEOF(let eof):
    // Partition, topic and eof offset information,
    // e.g. KafkaTopicPartitionEOF(topic: "user-sessions", partition: 0, offset: 10)
    print(eof)
    break messageStream
    }
    }
    return received
    }

    Diff: 218 lines (+163 / -55) across 2 files Reviewer: FranzBusch Review duration: 1556m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 218 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.322
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #275"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.7% (MEDIUM) · Higher = larger blast radius
    36.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.5% · Safe to merge
    14.5%