From 1958672d7ac6b54f2a8d1215fa0241adf248015f Mon Sep 17 00:00:00 2001 From: Jarema Date: Wed, 18 Oct 2023 12:29:41 +0200 Subject: [PATCH] Update README.md Signed-off-by: Jarema --- README.md | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 0f7cd7e..11c93c1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ -# SwiftyNats -A maintained swift client for interacting with a [nats](http://nats.io) server based on NIO2. +

+ +

-![SwiftyNats Logo](./Resources/Logo@256.png) +

+ A Swift client for the NATS messaging system. +

+ +**:warning: WARNING: THIS REPOSITORY IS UNDER REWORK AND SHOULD NOT BE USED AT THE MOMENT :warning: ** Tested with Swift 5.4 on [![macos](https://github.com/aus-der-Technik/swifty-nats/actions/workflows/macos.yml/badge.svg?branch=main)](https://github.com/aus-der-Technik/swifty-nats/actions/workflows/macos.yml) and [![Linux](https://github.com/aus-der-Technik/swifty-nats/actions/workflows/linux.yml/badge.svg?branch=main)](https://github.com/aus-der-Technik/swifty-nats/actions/workflows/linux.yml) @@ -10,8 +15,8 @@ Swift Version Compatibility: [![](https://img.shields.io/endpoint?url=https%3A%2 Platform Compatibility: [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Faus-der-Technik%2Fswifty-nats%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/aus-der-Technik/swifty-nats) ## Support -Join the [#swift](https://natsio.slack.com/archives/C02D41BU0PQ) channel on nats.io Slack. -We'll do our best to help quickly. You can also just drop by and say hello. We're looking forward to developing the community. +Join the [#swift](https://natsio.slack.com/archives/C02D41BU0PQ) channel on nats.io Slack. +We'll do our best to help quickly. You can also just drop by and say hello. We're looking forward to developing the community. ## Installation via Swift Package Manager ### In Package.swift @@ -40,8 +45,8 @@ let package = Package( ``` ### In an .xcodeproj -Open the project inspector in XCode and select your project. It is importent to select the **project** and not a target! -Klick on the third tab `Package Dependencies` and add the git url `https://github.com/aus-der-technik/SwiftyNats.git` by selecting the litte `+`-sign at the end of the package list. +Open the project inspector in XCode and select your project. It is importent to select the **project** and not a target! +Klick on the third tab `Package Dependencies` and add the git url `https://github.com/aus-der-technik/SwiftyNats.git` by selecting the litte `+`-sign at the end of the package list. ## Basic Usage @@ -57,10 +62,10 @@ client.on(.connect) { _ in print("Client connected") } -// try to connect to the server +// try to connect to the server try? client.connect() -// subscribe to a channel with a inline message handler. +// subscribe to a channel with a inline message handler. client.subscribe("foo.bar") { message in print("payload: \(message.payload)") print("size: \(message.byteCount)") @@ -83,8 +88,8 @@ client.config.loglevel = .info ``` ### Reconnection is up to you -Reconnection is not part of this package, because if a server diconnects your application have to be sure that -subscribtions are made up again correctly. +Reconnection is not part of this package, because if a server diconnects your application have to be sure that +subscribtions are made up again correctly. With SwiftyNats this is a very easy step: @@ -93,7 +98,7 @@ With SwiftyNats this is a very easy step: // register a new client let client = NatsClient(url) -// listen to the .disconnected event to try a reconnect +// listen to the .disconnected event to try a reconnect client.on(.disconnected) { [self] _ in sleep(5); try? client.reconnect() @@ -116,11 +121,11 @@ The public class `NatsEvent` contains all events you can subscribt to. | event | description | | ------------ | ---------------------------------------------------------------------- | -| connected | The client is conected to the server. | -| disconnected | The client disconnects and was connectd before. | +| connected | The client is conected to the server. | +| disconnected | The client disconnects and was connectd before. | | response | The client gets an response from the server (internal). | | error | The server sends an error that can't be handled. | -| dropped | The clients droped a message. Mostly because of queue length to short. | +| dropped | The clients droped a message. Mostly because of queue length to short. | | reconnecting | The client reconencts to the server, (Because of a called reconnect()).| | informed | The server sends his information data successfully to the client. | @@ -138,7 +143,6 @@ print("\(client.serverInformation.serverName) has Version: \(client.serverInform ## Contribution Contribution is always welcome. Just send me a pull request. - # Changelog ## 2.2.0 @@ -152,32 +156,33 @@ Contribution is always welcome. Just send me a pull request. - Subscription queue is an optional property of NatsSubject ## 2.1.1 -- rewrite the ChannelHandler: remove a bug that could lead into dropped messages. +- rewrite the ChannelHandler: remove a bug that could lead into dropped messages. ## 2.1.0 -- uses NIO2 +- uses NIO2 - works with Vapor, now! - + ## 2.0.3 - supports iOS anf tvOS ## 2.0.2 - Get information from the connected Server (Version, name, id, ...) -## 2.0.1 -- Test with GitHub Actions +## 2.0.1 +- Test with GitHub Actions - Update Dockerfile to build and test on Swift 5.4 (Linux) - Test with a real NATS-Server on macos - Cleanup unused definitions - Update Informations, do project care -## 2.0.0 +## 2.0.0 - Tested with NATS 2.3.4 - Introduced logging -- Updated depricated functions +- Updated depricated functions # Roadmap -See: Contribution ;) +See: Contribution ;) - Propper function description is needed - +# Attribution +This library is based on excellent work in https://github.com/aus-der-Technik/SwiftyNats