nats-io/nats.ex
69.0
Adequate · 18 September 2026
6.1k
lines of production code
Elixir
primary language
1
measurement over time
What this system is
Gnat is a comprehensive NATS client library for Elixir that provides robust connection management, including TLS, authentication, and supervised processes with automatic reconnection. It offers full support for NATS JetStream features, such as stream and consumer management, Key-Value and Object Stores, and pull-based consumption with heartbeat monitoring. The library also implements the NATS Service Protocol for service discovery and includes a high-performance parser for handling message headers and wire formats.
How it got here
2017 — Rebranding to Gnat and API expansion
7 changes.
The project was rebranded from Neato to Gnat, requiring an upgrade to Elixir 1.16 and the removal of legacy configuration mechanisms. This period introduced a comprehensive NATS client API with support for headers, TLS, NKey authentication, and supervised connection management. Comprehensive test suites were added to validate the new features and ensure robustness across various connection and authentication scenarios.
2018–2026 — JetStream and Service Protocol implementation
13 changes.
This period focused on implementing comprehensive support for the NATS Service Protocol and JetStream API, including modules for streams, consumers, Key-Value stores, and object storage. The work introduced robust pull-based consumer behaviors with heartbeat monitoring and failover testing, alongside extensive test coverage and benchmarking suites to validate performance and reliability.
Features
Add benchmark suite for client, parsing, and JetStream operations
Added a new set of benchmark scripts in the \bench/\ directory to measure performance across various client operations. These include benchmarks for raw publishing and request/response latency (\publish.exs\, \request.exs\, \request\_multi.exs\), service endpoint performance (\service\_bench.exs\), and message parsing with headers using the new Parsec library (\parse.exs\). Additionally, comprehensive benchmarks for JetStream Key-Value consumption strategies were added (\kv\_consume.exs\), comparing Pager, Pull + ack\_next, KV.watch, and PullConsumer batch modes.
bench · high confidence
Add support for NATS Service Protocol
Introduces a new \Gnat.Services\ module that allows the library to act as a NATS service, enabling service discovery and monitoring according to the NATS service protocol. This includes a new \Gnat.Services.Server\ behavior for defining request handlers, automatic tracking of request counts, errors, and processing latency, and the ability to respond to \$SRV\ protocol messages for ping, info, and stats queries.
lib/gnat/services · high confidence
Added local 3-node NATS cluster management and failover testing scripts
New scripts have been added to \scripts/cluster/\ to facilitate manual testing of PullConsumer failover behavior. This includes a Bash utility (\cluster.sh\) to start, stop, kill, and clean a local 3-node NATS cluster (n1, n2, n3) with JetStream enabled, along with corresponding configuration files (\n1.conf\, \n2.conf\, \n3.conf\). Additionally, an Elixir driver (\driver.exs\) is provided to connect to the cluster, create a test stream and durable consumer, and run a PullConsumer alongside a publisher to verify message delivery resilience during node failures.
scripts · high confidence
Introduce JetStream API modules for Streams, Consumers, KV, and Object Store
This change adds the \Gnat.Jetstream.API\ modules (\Stream\, \Consumer\, \KV\, \Object\, and \Message\) to the library, providing a structured interface for managing NATS JetStream resources. Users can now create and configure streams with advanced options like compression, message TTLs, and mirror direct access, as well as manage durable and ephemeral consumers with support for multiple filter subjects and flow control. The update also introduces full Key/Value store and Object Store APIs, allowing users to create buckets, put/get/delete keys and objects, and list available stores, along with a helper to parse JetStream message metadata from acknowledgment replies.
lib/gnat/jetstream/api · high confidence
New JetStream API modules for object metadata, acknowledgements, paging, and pull consumers
This change introduces several new modules to the \lib/gnat/jetstream\ area to support NATS JetStream features. It adds \Gnat.Jetstream.API.Object.Meta\ for handling object store metadata structures and encoding. The \Gnat.Jetstream\ module is added to provide functions for sending various message acknowledgements (Ack, AckNext, NAK, Progress, Term) to the server, including checks for missing reply-to subjects. A new \Gnat.Jetstream.Pager\ module allows synchronous iteration and reduction over all messages in a stream, supporting options like batching, domain specification, and filtering by sequence or datetime. Finally, \Gnat.Jetstream.PullConsumer\ is introduced as a behavior for implementing pull-based consumers, supporting both durable and ephemeral consumers with features like batch mode, idle heartbeats, and automatic cleanup.
lib/gnat/jetstream · high confidence
New KV Entry parser and Watcher server for Key/Value buckets
Added \Gnat.Jetstream.API.KV.Entry\ to parse raw NATS messages from a Key/Value bucket's underlying stream into structured records, handling operation detection (put, delete, purge) via headers and stripping the bucket subject prefix. Introduced \Gnat.Jetstream.API.KV.Watcher\, a GenServer that subscribes to these changes and notifies user-supplied handlers with \:key\_added\, \:key\_deleted\, or \:key\_purged\ events, including flow-control handling to manage backpressure from the server.
lib/gnat/jetstream/api/kv · high confidence
New PullConsumer module with heartbeat monitoring and ephemeral consumer support
This change introduces the PullConsumer module for JetStream, enabling users to pull messages from NATS streams with built-in connection management and reliability features. The implementation adds automatic heartbeat checks to detect stale connections and ensure timely message delivery. It supports both traditional durable consumers (specified by stream and consumer names) and ephemeral consumers (passed as a struct), with automatic cleanup logic for the latter. Connection options now include configurable retry policies, request expiration, and heartbeat intervals, with validation ensuring that idle heartbeat settings respect server constraints.
_lib/gnat/jetstream/pull\consumer · high confidence
New supervised connection and consumer processes with header support
This release introduces Gnat.ConnectionSupervisor and Gnat.ConsumerSupervisor to manage NATS connections and subscriptions within your application's supervision tree, providing automatic reconnection and graceful shutdown capabilities. It adds support for NATS headers via the Gnat.Command module (using HPUB) and the Gnat.Parsec parser, enabling message headers and service-style request/response patterns through the new Gnat.Server behavior.
lib/gnat · high confidence
Behavioural changes
Release 1.16: Elixir 1.16+ requirement and connection name support
The library now requires Elixir 1.16 or later, dropping support for Elixir 1.14 and 1.15. Additionally, clients can now specify a \name\ in the connection settings, which is reported to NATS monitoring endpoints to help identify the client in server logs and metrics.
(repo-wide) · high confidence
Removal of deprecated Mix.Config usage
The project has removed the deprecated Mix.Config module and its associated configuration file (config/config.exs). This change eliminates the legacy configuration mechanism, aligning the codebase with modern Elixir standards that no longer rely on Mix.Config for application setup.
config · high confidence
Rename library from Neato to Gnat and expand connection API
The NATS client library has been renamed from Neato to Gnat, replacing the previous minimal implementation with a comprehensive client. This change introduces support for configurable connection timeouts, custom inbox prefixes, TLS/SSL connections, and client naming. The message format has been enhanced to include subscription IDs, reply-to topics, and headers, while the API now supports synchronous requests, request multi-casting, and graceful shutdowns.
lib · high confidence
Test coverage
Added test coverage for ConsumerSupervisor, Handshake, and Parsec; Added test coverage for Jetstream API components; Added test fixtures for TLS and NKey authentication; Added test support infrastructure for Jetstream and protocol generation; Added tests for JetStream PullConsumer features; Added tests for Jetstream message metadata and Pager functionality; Added tests for KV entry parsing and watcher status handling; Added unit, property, and integration tests for Gnat.
Dependencies
Release 1.16.0 with dependency updates and project rebranding
This release updates the project to version 1.16.0 and renames the application from Neato to Gnat. It enforces a minimum Elixir version of 1.16 and adds the :ssl application to the OTP application list. The dependency manifest is refreshed, introducing jason as the JSON library (replacing poison), adding nkeys for authentication support, and updating telemetry, nimble\_parsec, and development tools like dialyxir and ex\_doc.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 69.
Lenses
- Code Health 99
- Architecture 81
- Maturity 50
- Readiness 83
- Security 100
Changes since last survey
- 300 commits — 286 feature/other, 14 fixes
By area
- (root) — 116 commits
- lib/gnat — 72 commits
- (repo) — 39 commits
- lib/gnat.ex — 31 commits
- .circleci/config.yml — 16 commits
- .github/workflows — 6 commits
- test/gnat_property_test.exs — 4 commits
- test/gnat_test.exs — 4 commits
- test/gnat — 3 commits
- test/fixtures — 2 commits
- test/support — 2 commits
- bench/client.exs — 1 commit
- bench/parse.exs — 1 commit
- bench/request_multi.exs — 1 commit
- config/config.exs — 1 commit
- test/jetstream — 1 commit
Notable commits
- fix: Fix incorrect useage of charlist (#179)
- fix: Fix large payload parsing performance (#225)
- fix: Misc. HTML doc generation fixes and changes
- fix: fix CircleCI config
- fix: fix Gnat.ConsumerSupervisor crash when no queue group is specified
- fix: fix conflict
- fix: fix dialyzer, return {:stop, error} from genserver
- fix: fix hexpm badge and image
- fix: fix property auto-unsub property test to expect the correct number of active subscriptions
- fix: fix readme
- fix: fix reference to parameters.version
- fix: fix: add stream fields allow_direct and mirror_direct
- fix: fix: deliver policy (#196)
- fix: fix: unknown field domain in Stream.create (#194)
- change: 1.14.0 Release Candidate (#219)
- change: Add a test and some documentation for IPv6 support
- change: Add client name to NATS CONNECT settings (#227)
- change: Add list_buckets function and tests to Object API (#169)
- change: Add notification based on SubjectDeleteMarkerTTL (#215)
- change: Add stream field discard_new_per_subject (#163)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
nats-io/nats.ex was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 18 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 4c8f25671b0cf483d0cbf8b8f772f8e323398d0c — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-5d04157a340d.