Skip to content

adopt swift6 #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/Kafka/KafkaAcknowledgedMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ public struct KafkaAcknowledgedMessage {
throw KafkaError.rdKafkaError(wrapping: rdKafkaMessage.err)
}

#if swift(>=6.0)
guard let topic = String(validatingCString: rd_kafka_topic_name(rdKafkaMessage.rkt)) else {
fatalError("Received topic name that is non-valid UTF-8")
}
#else
guard let topic = String(validatingUTF8: rd_kafka_topic_name(rdKafkaMessage.rkt)) else {
fatalError("Received topic name that is non-valid UTF-8")
}
#endif

self.topic = topic

self.partition = KafkaPartition(rawValue: Int(rdKafkaMessage.partition))
Expand Down
6 changes: 6 additions & 0 deletions Sources/Kafka/KafkaConsumerMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ public struct KafkaConsumerMessage {
}
}

#if swift(>=6.0)
guard let topic = String(validatingCString: rd_kafka_topic_name(rdKafkaMessage.rkt)) else {
fatalError("Received topic name that is non-valid UTF-8")
}
#else
guard let topic = String(validatingUTF8: rd_kafka_topic_name(rdKafkaMessage.rkt)) else {
fatalError("Received topic name that is non-valid UTF-8")
}
#endif
self.topic = topic

self.partition = KafkaPartition(rawValue: Int(rdKafkaMessage.partition))
Expand Down
2 changes: 1 addition & 1 deletion Sources/Kafka/RDKafka/RDKafkaClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Logging
/// Base class for ``KafkaProducer`` and ``KafkaConsumer``,
/// which is used to handle the connection to the Kafka ecosystem.
@_spi(Internal)
public final class RDKafkaClient: Sendable {
public final class RDKafkaClient: @unchecked Sendable {
// Default size for Strings returned from C API
static let stringSize = 1024

Expand Down
2 changes: 1 addition & 1 deletion Sources/Kafka/RDKafka/RDKafkaTopicHandles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Crdkafka
import NIOConcurrencyHelpers

/// Swift class that matches topic names with their respective `rd_kafka_topic_t` handles.
internal final class RDKafkaTopicHandles: Sendable {
internal final class RDKafkaTopicHandles: @unchecked Sendable {
private let _internal: NIOLockedValueBox<[String: OpaquePointer]>

// Note: we retain the client to ensure it does not get
Expand Down
3 changes: 2 additions & 1 deletion docker/docker-compose.2204.510.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ services:
image: swift-kafka-client:22.04-5.10
build:
args:
base_image: "swiftlang/swift:nightly-5.10-jammy"
ubuntu_version: "jammy"
swift_version: "5.10"

build:
image: swift-kafka-client:22.04-5.10
Expand Down