Skip to content

asimov-modules/asimov-nats-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ASIMOV NATS Module

License

ASIMOV module for NATS, the cloud-native messaging system.

✨ Features

  • 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

πŸ› οΈ Prerequisites

  • Rust 1.85+ (2024 edition) if building from source code
  • Running NATS server (default: nats://127.0.0.1:4222)

⬇️ Installation

Installation with the ASIMOV CLI

asimov module install nats -v

Installation from Source Code

cargo install asimov-nats-module

πŸ‘‰ Examples

✏️ Publishing Messages (Writer)

# 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

πŸ“‘ Subscribing to Subjects (Reader)

# 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 json

βš™ Configuration

Connection URL

Configure the NATS endpoint via environment variable or .env.

Example .env

ASIMOV_NATS_URL=nats://127.0.0.1:4222

πŸ“š Reference

Installed Binaries

Binary Description
asimov-nats-reader Subscribes to NATS subjects and prints messages
asimov-nats-writer Publishes messages from stdin to NATS subjects

asimov-nats-reader

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

asimov-nats-writer

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

πŸ‘¨β€πŸ’» Development

git clone https://github.com/asimov-modules/asimov-nats-module.git
cd asimov-nats-module
cargo build --bins

About

🚧 ASIMOV Platform extension module bridging to the NATS messaging system.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors