ASIMOV module for NATS, the cloud-native messaging system.
- Publish JSONL payloads from stdin to any NATS subject
- Subscribe to subjects and render messages as JSON lines or pretty JSON
- Honors
.env/ environment configuration via ASIMOV Module helpers - CLI UX aligned with other ASIMOV modules
- Distributed as static binaries with zero runtime dependencies
- Rust 1.85+ (2024 edition) if building from source code
- Running NATS server (default:
nats://127.0.0.1:4222)
Installation with the ASIMOV CLI
asimov module install nats -vcargo install asimov-nats-module# Publish JSON objects
echo '{"@id":"https://example.com/r/1","k":"v"}' \
| asimov-nats-writer --subject asimov.events
# Publish and also echo to stdout
echo '{"msg":"test"}' \
| asimov-nats-writer --subject asimov.events --union# Output messages as JSON lines (default)
asimov-nats-reader --subject asimov.events --output jsonl
# Output pretty-printed JSON
asimov-nats-reader --subject asimov.events --output jsonConfigure the NATS endpoint via environment variable or .env.
ASIMOV_NATS_URL=nats://127.0.0.1:4222| Binary | Description |
|---|---|
asimov-nats-reader |
Subscribes to NATS subjects and prints messages |
asimov-nats-writer |
Publishes messages from stdin to NATS subjects |
Usage: asimov-nats-reader [OPTIONS]
Options:
-d, --debug Enable debugging output
--license Show license information
-v, --verbose... Enable verbose output (may be repeated for more verbosity)
-V, --version Print version information
--url <URL> NATS url [default: nats://127.0.0.1:4222]
--subject <STRING> Subject to subscribe to [default: asimov.test]
-o, --output <FORMAT> Specify the output format [jsonl, json] [default: jsonl]
-h, --help Print help
Usage: asimov-nats-writer [OPTIONS]
Options:
-U, --union Copy stdin to stdout
-d, --debug Enable debugging output
--license Show license information
-v, --verbose... Enable verbose output (repeat for more verbosity)
-V, --version Print version information
--url <URL> NATS url [default: nats://127.0.0.1:4222]
--subject <STRING> Subject to publish to [default: asimov.test]
-h, --help Print help
git clone https://github.com/asimov-modules/asimov-nats-module.git
cd asimov-nats-module
cargo build --bins