Skip to content

kookman/nats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nats

A basic Nats client library for Dlang, built on vibe.d

Aims to allow high-performance zero copy message processing, and minimal GC allocation generated by the library itself in the "hot loop" (ie normal message receipt and processing).

For this reason, the NatsHandlers receive the Msg struct as a scope parameter, and currently all message processing is handled synchronously in the eventloop (main) thread, to avoid unnecessary copying of Msg structs onto the GC heap. This also matches with (my) typical deployment profile of small, single purpose processes with a single message processing thread, optimized for minimal latency message processing.

If necessary for blocking IO or more computate intensive tasks that might otherwise block the event/message processing loop, you can copy the data required from the Msg struct, and send it to a task(fibre) or another thread. See example in the query_responder in the test app (src/app.d).

Current features supported:

  • Implement SUB api
  • Implement PUB api
  • Implement flush logic
  • Implement request-response subscriptions
  • Support proper connect options
  • Support reconnect logic
  • Support large messages
  • Support distributed queues (subscriber groups)
  • Disconnect/clean shutdown
  • Support Nats 2.0 Nkey-based authentication
  • Support HPUB/HMSG (Nats message headers)
  • ? Add support for Jetstream (perhaps belongs in a separate module from the basic client)
  • ? Support (de)serialisation protocols: msgpack, cerealed, none (passthru ubyte[])

For example usage, see the test app (src/app.d).

About

Nats client library built on vibe.d

Resources

License

Stars

Watchers

Forks

Packages

No packages published