Skip to content

Latest commit

 

History

History
87 lines (59 loc) · 2.14 KB

readme.md

File metadata and controls

87 lines (59 loc) · 2.14 KB

nats.zig - Zig client for the NATS messaging system

About

Minimal synchronous NATS Zig client.

Features:

  • subject subscription
  • message publishing
  • tls connections
  • nkey authentication
  • connecting to the ngs
  • non allocating protocol parser

Try

Build project:

git clone --recurse-submodules [email protected]:ianic/nats.zig.git
cd nats.zig
zig build

Tested only using latest master 0.10-dev release.

You should have installed nats-server. Start it locally:

nats-server

Start subscriber in one terminal:

./zig-out/bin/sub

and publisher to send few messages to the foo subject on which subscriber is listening:

./zig-out/bin/pub

ngs example

To 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 subject

LibreSSL

Project depends on libressl for handling tls connections. Can be built using libressl from project or system.

To install libressl on macos:

brew install libressl

and 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 install

After that project can be build using system libressl:

zig build -Duse-system-libressl 

References