Skip to content

ianic/nats.zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

zig client lib for nats-server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages