https://github.com/dimensional-fun/nats.kt
🛰️ kotlin multi-platform NATS client
https://github.com/dimensional-fun/nats.kt
jetstream kotlin ktor microservices nats nats-io
Last synced: 5 months ago
JSON representation
🛰️ kotlin multi-platform NATS client
- Host: GitHub
- URL: https://github.com/dimensional-fun/nats.kt
- Owner: dimensional-fun
- License: apache-2.0
- Created: 2023-07-21T14:49:44.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-23T08:28:19.000Z (about 2 years ago)
- Last Synced: 2025-02-19T16:51:58.148Z (over 1 year ago)
- Topics: jetstream, kotlin, ktor, microservices, nats, nats-io
- Language: Kotlin
- Homepage: https://dimensional-fun.github.io/knats
- Size: 389 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NATS - Kotlin Client
An idiomatic & multi-platform [Kotlin](http://java.com) client for the [NATS messaging system](https://nats.io).
> [!WARNING]
> nats.kt is currently in active development!
- [Discord Server](https://discord.gg/8R4d8RydT4)
## Installation
Requires **Kotlin 1.9** and **Java 19** if you're using the JVM artifact.
- **Latest Version:** None
### 🐘 Gradle
```kotlin
repositories {
maven("https://maven.dimensional.fun/releases") // or snapshots
}
dependencies {
implementation("fun.dimensional:knats-core:{VERSION}")
implementation("fun.dimensional:knats-jetstream:{VERSION}")
implementation("fun.dimensional:knats-micro:{VERSION}")
}
```
## Example
### Creating a Client
```kt
// create and connect a new NATS client.
val client = Client("nats://127.0.0.1:4222") {
// use the TCP transport, you could also use the WebSocket transport.
transport = TcpTransport
}
```
### Subscriptions
```kt
// create a subscription listening on all subjects.
val all = client.subscribe(">")
all.on {
println("Subscription was ${if (auto) "auto-" else ""}unsubscribed.")
}
all.on {
println("Received message $id on \"${delivery.subject}\"!")
}
```
_more coming soon_
---
Unless specified otherwise, all files are licensed under the [Apache Version 2.0](/LICENSE) license.