pulsar-client-swift is a native Swift wrapper library for the Apache Pulsar™ C++ client library. It provides an idiomatic Swift API (Client, Producer, Consumer, Message, etc.) while calling into the upstream C++ client.
Example (synchronous send):
import Pulsar
let client = Client(serviceURL: URL(string: "pulsar://localhost:6650")!)
do {
let producer = try client.createProducer(topic: "my-topic")
let message = Message(content: "Hello Apache Pulsar")
try producer.send(message)
try client.close()
} catch {
print("Pulsar error: \(error)")
}The full documentation is provided via DocC on Swift Package Manager.
To integrate pulsar-client-swift into your project using Swift Package Manager, follow these steps:
- Open your project in Xcode.
- Select
File>Swift Packages>Add Package Dependency.... - Enter the package repository URL:
https://github.com/flexlixrup/pulsar-client-swift-cpp. - Choose the latest release or specify a version range.
- Add the package to your target.
Alternatively, you can add the following dependency to your Package.swift file:
dependencies: [
.package(url: "https://github.com/flexlixrup/pulsar-client-swift-cpp", from: "0.0.1")
]Then, include Pulsar as a dependency in your target:
.target(
name: "YourTargetName",
dependencies: [
"Pulsar"
]),This project includes and links against the Apache Pulsar™ C++ client library. The included C++ client is distributed under the Apache License 2.0. Please review the license files:
pulsar-client-swift/LICENSE— license for the Swift wrapperpulsar-client-cpp-bundle/resources/LICENSES/— license/NOTICE files for the bundled Apache Pulsar C++ client
Warning
This package uses Conventional Commits to detect the semantic versioning. Commits not following this format will not be accepted.
If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.