fix osx error
A swift client for interacting with a nats server.
Only uses SPM to install. Add the dependencies like below.
// swift-tools-version:4.0 import PackageDescription let package = Package( name: "YourApp", products: [ .library(name: "YourApp", targets: ["YourApp"]) ], dependencies: [ .package(url: "https://github.com/raykrow/swifty-nats.git", from: "1.0.0") ], targets: [ .target( name: "YourApp", dependencies: ["SwiftyClient"] ), ] )
import SwiftyNats let client = NatsClient("http://nats.server:4222") client.on(.connect) { _ in print("Client connected") } try? client.connect() client.subscribe("foo.bar") { message in print("payload: \(message.payload)") print("size: \(message.byteCount)") print("reply subject: \(message.replySubject.subject)") } client.publish("this event happened", to: "foo.bar")
connect_urls
publish
PUB swift.test 0\r\n\r\n
SUB swift.test G1 11\r\n
reconnecting
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
SwiftyNats
A swift client for interacting with a nats server.
Installation
Only uses SPM to install. Add the dependencies like below.
Basic Usage
TODO
Saveconnect_urls
property from INFO response and use it later when attempting to reconnectIn(just pass “” as payload)publish
method make the payload optional. Its ok to send 0 count and no payloadPUB swift.test 0\r\n\r\n
Support subscribing to a queue groupSUB swift.test G1 11\r\n
Configurable max queue size, default 100When trying to reconnect to the server, wait 5 seconds between retries, configurableAdd areconnecting
event