NATS Streaming Buffered Client
![Travis](https://travis-ci.com/SpringTree/node-nats-streaming-buffered-client.svg?branch=master)
This is a client for the NATS streaming server built for clients that may have an intermittent connection to the server.
The need for this client arose for IoT devices with 4G connections and to ensure no messages are lost on server upgrades, reboots or mishaps.
Features
- Reconnect logic
- Ring buffer to store messages to publish
- Retry to publish messages
Usage
npm install node-nats-streaming-buffered-client
You can import the buffered client class after installing it with npm:
import { NatsBufferedClient } from 'node-nats-streaming-buffered-client'
const bufferSize = 2000;
const reconnectTimeout = 30000;
const waitForInitialConnect = false;
const logger = console;
const client = new NatsBufferedClient( bufferSize, reconnectTimeout, waitForInitialConnect, logger );
const natsOptions = { ... };
client.connect( 'test-cluster', 'test', natsOptions );
client.publish( 'my-channel', { content: 'stuff' } );
const subsription = client.stan.subscribe( 'topic', ... );
NPM scripts
npm run test
: Run test suitenpm run build
: Generate bundles and typings, create docs