Skip to content

Commit a84f1c0

Browse files
committed
Use @available for NaiveQueueExecutor
Can't use the current implementation before Swift 6.
1 parent 46a04c7 commit a84f1c0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Sources/Kafka/KafkaConsumer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public struct KafkaConsumerMessages: Sendable, AsyncSequence {
7373
public struct AsyncIterator: AsyncIteratorProtocol {
7474
private let stateMachineHolder: MachineHolder
7575
let pollInterval: Duration
76+
#if swift(>=6.0)
7677
let queue: NaiveQueueExecutor
78+
#endif
7779

7880
private final class MachineHolder: Sendable { // only for deinit
7981
let stateMachine: LockedMachine
@@ -90,7 +92,9 @@ public struct KafkaConsumerMessages: Sendable, AsyncSequence {
9092
init(stateMachine: LockedMachine, pollInterval: Duration) {
9193
self.stateMachineHolder = .init(stateMachine: stateMachine)
9294
self.pollInterval = pollInterval
95+
#if swift(>=6.0)
9396
self.queue = NaiveQueueExecutor(DispatchQueue(label: "com.swift-server.swift-kafka.message-consumer"))
97+
#endif
9498
}
9599

96100
public func next() async throws -> Element? {

Sources/Kafka/Utilities/NaiveQueueExecutor.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if swift(>=6.0)
1516
import Dispatch
1617

1718
final class NaiveQueueExecutor: TaskExecutor {
@@ -35,3 +36,4 @@ final class NaiveQueueExecutor: TaskExecutor {
3536
UnownedTaskExecutor(ordinary: self)
3637
}
3738
}
39+
#endif

0 commit comments

Comments
 (0)