Skip to content

Commit afad9b2

Browse files
authored
Update to librdkafka 2.8.0 (#187)
Updates `librdkafka` to the latest release 2.8.0. ### Motivation: The `librdkafka` version shipped by this client has gotten fairly old, and there's been a few releases with bug fixes. ### Modifications: A recent commit [1] added a function call that is not available in BoringSSL. This requires us moving away from BoringSSL again. [1] https://github.com/confluentinc/librdkafka/blame/93877617709eb071a0f4ec7038c54e2764abefc9/src/rdkafka_ssl.c#L1533 ### Result: * Updated `librdkafka` to 2.8.0. * Removed BoringSSL from project (introduced in #135) * `libssl-dev` now needs to be available during build time again. Closes #186
1 parent a6195a5 commit afad9b2

File tree

15 files changed

+33
-136
lines changed

15 files changed

+33
-136
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: Soundness
1010
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
1111
with:
12-
linux_pre_build_command: "apt-get update -y -q && apt-get install -y -q libsasl2-dev"
12+
linux_pre_build_command: "apt-get update -y -q && apt-get install -y -q libsasl2-dev libssl-dev"
1313
license_header_check_project_name: "swift-kafka-client"
1414

1515
unit-tests:
@@ -36,7 +36,7 @@ jobs:
3636
run: echo "cxx-interop-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT"
3737
env:
3838
MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash"
39-
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q curl jq libsasl2-dev"
39+
MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q curl jq libsasl2-dev libssl-dev"
4040

4141
cxx-interop:
4242
name: Cxx interop

.github/workflows/unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
COMMAND_OVERRIDE_NIGHTLY_6_1: "swift test ${{ inputs.linux_nightly_6_1_arguments_override }}"
9191
COMMAND_OVERRIDE_NIGHTLY_MAIN: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
9292
run: |
93-
apt-get -qq update && apt-get -qq -y install curl && apt-get -y install libsasl2-dev
93+
apt-get -qq update && apt-get -qq -y install curl && apt-get -y install libsasl2-dev libssl-dev
9494
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
9595
container:
9696
image: ${{ matrix.swift.image }}

Package.swift

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import PackageDescription
1818
let rdkafkaExclude = [
1919
"./librdkafka/src/CMakeLists.txt",
2020
"./librdkafka/src/Makefile",
21+
"./librdkafka/src/README.lz4.md",
2122
"./librdkafka/src/generate_proto.sh",
2223
"./librdkafka/src/librdkafka_cgrp_synch.png",
23-
"./librdkafka/src/statistics_schema.json",
24+
"./librdkafka/src/opentelemetry/metrics.options",
2425
"./librdkafka/src/rdkafka_sasl_win32.c",
2526
"./librdkafka/src/rdwin32.h",
27+
"./librdkafka/src/statistics_schema.json",
2628
"./librdkafka/src/win32_config.h",
2729
// Remove dependency on cURL. Disabling `ENABLE_CURL` and `WITH_CURL` does
2830
// not appear to prevent processing of the below files, so we have to exclude
@@ -52,7 +54,6 @@ let package = Package(
5254
],
5355
dependencies: [
5456
.package(url: "https://github.com/apple/swift-nio.git", from: "2.55.0"),
55-
.package(url: "https://github.com/apple/swift-nio-ssl", from: "2.25.0"),
5657
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.1.0"),
5758
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
5859
.package(url: "https://github.com/apple/swift-metrics", from: "2.4.1"),
@@ -64,7 +65,7 @@ let package = Package(
6465
.target(
6566
name: "Crdkafka",
6667
dependencies: [
67-
.product(name: "NIOSSL", package: "swift-nio-ssl"),
68+
"COpenSSL",
6869
.product(name: "libzstd", package: "zstd"),
6970
],
7071
exclude: rdkafkaExclude,
@@ -73,7 +74,6 @@ let package = Package(
7374
cSettings: [
7475
// dummy folder, because config.h is included as "../config.h" in librdkafka
7576
.headerSearchPath("./custom/config/dummy"),
76-
.headerSearchPath("./custom/include"),
7777
.headerSearchPath("./librdkafka/src"),
7878
.define("_GNU_SOURCE", to: "1"), // Fix build error for Swift 5.9 onwards
7979
],
@@ -98,6 +98,14 @@ let package = Package(
9898
"Kafka"
9999
]
100100
),
101+
.systemLibrary(
102+
name: "COpenSSL",
103+
pkgConfig: "openssl",
104+
providers: [
105+
.brew(["libressl"]),
106+
.apt(["libssl-dev"]),
107+
]
108+
),
101109
.testTarget(
102110
name: "KafkaTests",
103111
dependencies: [
@@ -113,14 +121,21 @@ let package = Package(
113121
)
114122

115123
for target in package.targets {
116-
var settings = target.swiftSettings ?? []
117-
settings.append(.enableExperimentalFeature("StrictConcurrency=complete"))
118-
target.swiftSettings = settings
124+
switch target.type {
125+
case .regular, .test, .executable:
126+
var settings = target.swiftSettings ?? []
127+
settings.append(.enableExperimentalFeature("StrictConcurrency=complete"))
128+
target.swiftSettings = settings
129+
case .macro, .plugin, .system, .binary:
130+
break // These targets do not support settings
131+
@unknown default:
132+
fatalError("Update to handle new target type \(target.type)")
133+
}
119134
}
120135

121136
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
122137
for target in package.targets {
123-
if target.type != .plugin {
138+
if target.type != .plugin && target.type != .system {
124139
var settings = target.swiftSettings ?? []
125140
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
126141
settings.append(.enableUpcomingFeature("MemberImportVisibility"))

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,13 @@ config.securityProtocol = .saslTLS(
237237

238238
## librdkafka
239239

240-
The Package depends on [the librdkafka library](https://github.com/confluentinc/librdkafka), which is included as a git submodule.
240+
The Package depends on [the `librdkafka` library](https://github.com/confluentinc/librdkafka), which is included as a git submodule.
241241
It has source files that are excluded in `Package.swift`.
242242

243+
### Dependencies
244+
245+
`librdkafka` depends on `openssl`, meaning that `libssl-dev` must be present at build time.
246+
243247
## Development Setup
244248

245249
We provide a Docker environment for this package. This will automatically start a local Kafka server and run the package tests.

Sources/COpenSSL/module.modulemap

Whitespace-only changes.

Sources/Crdkafka/custom/include/openssl/err.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Crdkafka/custom/include/openssl/evp.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Crdkafka/custom/include/openssl/hmac.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Crdkafka/custom/include/openssl/pkcs12.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Crdkafka/custom/include/openssl/sha.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)