MCPcopy Index your code
hub / github.com/66Origin/nitox

github.com/66Origin/nitox @v0.1.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.8 ↗ · + Follow
110 symbols 209 edges 21 files 18 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Nitox - Tokio-based async NATS client

Crates.io docs.rs

Description

Nitox is a tokio-based client for NATS. We wrote it because the existing library is sync and does not fit our needs.

A lot of features are currently missing, so feel free to contribute and help us building the best Async NATS client ever!

Missing features:

  • [x] Find a way to integration test the reconnection mechanism - but it has actually been hand-tested and works
  • [x] Auto-pruning of subscriptions being unsubscribed after X messages - It's actually a bug, since a stream stays open albeit sleeping
  • [ ] Handle verbose mode
  • [x] Handle pedantic mode - Should work OOB since we're closely following the protocol (Edit: it does)
  • [ ] Switch parsing to using nom - We're not sure we can handle very weird clients; we're fine talking to official ones right now
  • [ ] Add support for NATS Streaming Server - Should be pretty easy with prost since we already have the async architecture going on

There's a small extra in the tests/ folder, some of our integration tests rely on a custom NATS server implemented with tokio that only implements a subset of the protocol to fit our needs for the integration testing.

Documentation

Here: http://docs.rs/nitox

Installation

[dependencies]
nitox = "0.1"

Usage

extern crate nitox;
extern crate futures;
use futures::{prelude::*, future};
use nitox::{NatsClient, NatsClientOptions, NatsError, commands::*};

fn connect_to_nats() -> impl Future<Item = NatsClient, Error = NatsError> {
    // Defaults as recommended per-spec, but you can customize them
    let connect_cmd = ConnectCommand::builder().build().unwrap();
    let options = NatsClientOptions::builder()
        .connect_command(connect_cmd)
        .cluster_uri("127.0.0.1:4222")
        .build()
        .unwrap();

    NatsClient::from_options(options)
        .and_then(|client| {
            // Makes the client send the CONNECT command to the server, but it's usable as-is if needed
            client.connect()
        })
        .and_then(|client| {
            // Client has sent its CONNECT command and is ready for usage
            future::ok(client)
        })
}

License

Licensed under either of these:

Why "Nitox"

Standing for Nitric Oxide, an important chemical involved in communication between neurons; It's highly related to the acronym behind NATS, and you should ask the team behind it for the meaning! (or look in the git history of gnatsd's repo)

What is NATS

NATS Server is a simple, high performance open source messaging system for cloud native applications, IoT messaging, and microservices architectures.

More details at NATS.io

Yellow Innovation

Yellow Innovation is the innovation laboratory of the French postal service: La Poste.

We create innovative user experiences and journeys through services with a focus on IoT lately.

Yellow Innovation's website and works

Extension points exported contracts — how you extend this code

Command (Interface)
Trait used to implement a common interface for implementing new commands [6 implementers]
src/protocol/mod.rs

Core symbols most depended-on inside this repo

send
called by 18
src/client.rs
into_vec
called by 13
src/protocol/server/info.rs
connect
called by 10
src/client.rs
subscribe
called by 4
src/client.rs
publish
called by 3
src/client.rs
request
called by 3
src/client.rs
check_command_arg
called by 3
src/protocol/mod.rs
for_sid
called by 2
src/client.rs

Shape

Method 60
Function 29
Class 14
Enum 6
Interface 1

Languages

Rust100%

Modules by API surface

src/client.rs19 symbols
tests/all.rs10 symbols
src/protocol/client/pub_cmd.rs9 symbols
src/protocol/client/connect.rs9 symbols
src/protocol/client/sub_cmd.rs8 symbols
src/protocol/server/message.rs7 symbols
src/protocol/client/unsub_cmd.rs7 symbols
src/net/connection_inner.rs7 symbols
src/protocol/server/info.rs6 symbols
src/net/connection.rs6 symbols
src/protocol/mod.rs5 symbols
src/codec.rs4 symbols

For agents

$ claude mcp add nitox \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact