feat(swift): add Swift SDK with TCP and TLS transport - #4112
Closed
RustToMetal wants to merge 2 commits into
Closed
RustToMetal wants to merge 2 commits into
RustToMetal wants to merge 2 commits into
Conversation
Adds a native Swift client for the VSR wire protocol so Swift applications on Apple platforms and Linux can talk to Iggy without a bridge. The SDK matches the Rust client's surface: every stream, topic, partition, message, consumer-group, offset, user, personal-access-token, and system command, a producer with direct and background batching modes, and a consumer that is an AsyncSequence with the same auto-commit modes. Reconnection restores the session and replays only requests that provably never reached the log; leader redirection and roster failover follow the cluster like the Rust TcpClient. The wire layer is proven byte-identical to the Rust crates through golden vectors emitted by a small Rust generator, and the client's reconnection, replay, eviction, and timeout paths run against an in-process VSR server over real sockets. The end-to-end suite runs against iggy-server with and without TLS, the examples run through the shared README runner, and the BDD scenarios run through a Swift Gherkin interpreter in Docker. SwiftPM cannot fetch a package from a repository subdirectory, so the release flow tags foreign/swift/v<version> here and the README points at the package mirror for consumers. Closes apache#4001
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Contributor
|
@RustToMetal it would be better to split this into multiple PRs since reviewing 23k loc, even wih agents, is not possible. The first PR should wire in the CI with a little swift code to check that the wiring works, and then you can work from there. |
Contributor
|
@slbotbm agreed. @RustToMetal max 3k LoC per PR, please. (5k is hard limit 😄) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4112 +/- ##
============================================
- Coverage 86.03% 86.03% -0.01%
Complexity 1449 1449
============================================
Files 1248 1248
Lines 195841 195841
Branches 161139 161140 +1
============================================
- Hits 168501 168500 -1
- Misses 23206 23208 +2
+ Partials 4134 4133 -1
🚀 New features to boost your workflow:
|
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a native Swift client for the VSR wire protocol so Swift applications on Apple platforms and Linux can talk to Iggy without a bridge. The SDK matches the Rust client's surface: every stream, topic, partition, message, consumer-group, offset, user, personal-access-token, and system command, a producer with direct and background batching modes, and a consumer that is an
AsyncSequencewith the same auto-commit modes. Reconnection restores the session and replays only requests that provably never reached the log; leader redirection and roster failover follow the cluster like the RustTcpClient.The wire layer is proven byte-identical to the Rust crates through golden vectors emitted by a small Rust generator, and the client's reconnection, replay, eviction, and timeout paths run against an in-process VSR server over real sockets. The end-to-end suite runs against
iggy-serverwith and without TLS, the examples run through the shared README runner, and the BDD scenarios run through a Swift Gherkin interpreter in Docker.SwiftPM cannot fetch a package from a repository subdirectory, so the release flow tags
foreign/swift/v<version>here and the README points at the package mirror for consumers.Which issue does this PR address?
Closes #4001
Rationale
Iggy has no first-class client for Swift, so apps on iOS, macOS, and server-side Swift cannot use it without wrapping another SDK. #4001 asks for a native, idiomatic Swift SDK; this is Phase 1 of that issue (TCP and TLS over the VSR protocol), with QUIC, HTTP, and WebSocket left for later phases.
What changed?
Before, a Swift application had no way to speak the VSR wire protocol: no frame encoder, no session handling, and no typed models for the server's commands and replies.
This adds
foreign/swift, a SwiftPM package built on SwiftNIO and NIOSSL in Swift 6 strict-concurrency mode. It implements the consensus framing, sessions, result-framed replies, batch layout, and XXH3/XXH32 natively, exposesIggyClientwith the full command set plusIggyProducerandIggyConsumer, and ships with examples inexamples/swift, a BDD runner inbdd/swift, CI lanes (lint, test, build, e2e plain and TLS, BDD, examples), and tag-only release wiring mirroring the Go SDK.Local Execution
prekis not installed here;shellcheck,markdownlint,swift format lint --strict,swift build -Xswiftc -warnings-as-errors, license-header, trailing-whitespace, and trailing-newline checks were run by hand and are clean)Everything below was run locally against a fresh
iggy-serverbuilt from this branch:core/certs), 8 runsscripts/run-examples-from-readme.sh --language swift(plain and TLS)The Linux container run caught one real bug during verification (TCP_NODELAY was being set at the socket level, which Linux refuses without
CAP_NET_ADMIN); the fix is included.Not verifiable on this machine: the GitHub workflows have not run on GitHub yet, and the compose-driven BDD flow needs a Linux server binary, so the container was run directly against a host server instead.
AI Usage
core/binary_protocolas the reference, and reviewed and directed by me.iggy-serverwith and without TLS, plus the examples runner, the BDD suite on macOS and Linux, and a live server-restart probe (table above). All suites were run repeatedly to shake out flakiness.