Skip to content

Commit

Permalink
fix(patch): Make description for RDKafkaTopicPartitionList shorter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ser-0xff committed Oct 11, 2024
1 parent d7d6ce0 commit 18b2dbb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Sources/Kafka/RDKafka/RDKafkaTopicPartitionList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,12 @@ public final class RDKafkaTopicPartitionList {

extension RDKafkaTopicPartitionList: Sendable {}
extension RDKafkaTopicPartitionList: Hashable {

public func hash(into hasher: inout Hasher) {
for idx in 0..<self.count {
hasher.combine(self.getByIdx(idx: idx))
}
}

public static func == (lhs: RDKafkaTopicPartitionList, rhs: RDKafkaTopicPartitionList) -> Bool {
if lhs.count != rhs.count {
return false
Expand All @@ -126,9 +125,15 @@ extension RDKafkaTopicPartitionList: Hashable {
extension RDKafkaTopicPartitionList: CustomStringConvertible {
public var description: String {
var str = "RDKafkaTopicPartitionList {"
var topics: [String: [(KafkaPartition, KafkaOffset)]] = [:]
for idx in 0..<count {
str += "\(getByIdx(idx: idx)!)"
let topicPartition = getByIdx(idx: idx)!
topics[topicPartition.topic, default: []].append((topicPartition.partition, topicPartition.offset))
}
str += topics.map {
let partitions = $0.value.map { "(\($0.0): \($0.1))" }.joined(separator: ", ")
return "\"\($0.key)\": [\(partitions)]"
}.joined(separator: ", ")
str += "}"
return str
}
Expand Down

0 comments on commit 18b2dbb

Please sign in to comment.