An open API service indexing awesome lists of open source software.

https://github.com/c-cube/micronats.ml

Small NATS client for OCaml + Eio
https://github.com/c-cube/micronats.ml

eio nats ocaml pubsub

Last synced: 6 days ago
JSON representation

Small NATS client for OCaml + Eio

Awesome Lists containing this project

README

          

# micronats: minimal NATS client for OCaml/Eio

[![build](https://github.com/c-cube/micronats.ml/actions/workflows/main.yml/badge.svg)](https://github.com/c-cube/micronats.ml/actions/workflows/main.yml)

A lightweight [NATS](https://nats.io) client library for OCaml >= 5.1 built on [Eio](https://github.com/ocaml-multicore/eio).

## Example

```ocaml
open Eio.Std

let () =
Eio_main.run @@ fun env ->
let net = Eio.Stdenv.net env in
Eio.Switch.run @@ fun sw ->
let@ nats = Micronats.with_connect ~sw ~net () in
let _sub = Micronats.sub nats ~sw ~subject:["greetings"]
(fun msg -> traceln "received: %s" msg.payload)
in
Micronats.pub nats ~subject:["greetings"] "hello, world!"
```

## Install

(once released)
```sh
opam install micronats
```

## License

MIT