Add record and partition EOF #275
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
FranzBusch
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.enablePartitionEofis enabledModifications:
KafkaConsumer.Messageand enum with the associative casesrecordandpartitionEOF, whererecordcontains the previous contained information ofMessage.partitionEOFcontains 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, andoffsets_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
}