Minimal synchronous NATS Zig client.
Features:
- subject subscription
- message publishing
- tls connections
- nkey authentication
- connecting to the ngs
- non allocating protocol parser
Build project:
git clone --recurse-submodules git@github.com:ianic/nats.zig.git
cd nats.zig
zig buildTested only using latest master 0.10-dev release.
You should have installed nats-server. Start it locally:
nats-serverStart subscriber in one terminal:
./zig-out/bin/suband publisher to send few messages to the foo subject on which subscriber is listening:
./zig-out/bin/pubTo connect and publish/subscribe to the ngs network you need valid credentials file. Start the ngs example and point it to the credentials file and specify a subject name. Example will both subscribe and publish few messages.
./zig-out/bin/ngs credentials_file.creds subjectProject depends on libressl for handling tls connections. Can be built using libressl from project or system.
To install libressl on macos:
brew install libressland on linux:
wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.6.0.tar.gz
tar -xf libressl-3.6.0.tar.gz
ls -al
cd libressl-3.6.0/
./configure
sudo make installAfter that project can be build using system libressl:
zig build -Duse-system-libressl - zig-libressl
- nats protocol documentation (that page is referencing also Derek's talk about zero allocation parser)
- zig-nats and zig-nkeys by Rutger Broekhoff
- Twitter conversLation