Skip to content

Commit

Permalink
Merge pull request #49 from ordo-one/fix-logs
Browse files Browse the repository at this point in the history
fix(patch): Make description for RDKafkaTopicPartitionList shorter.
  • Loading branch information
ser-0xff authored Oct 11, 2024
2 parents d7d6ce0 + 18b2dbb commit 5d20c7f
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 5d20c7f

Please sign in to comment.