inspector-nats
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

inspector-nats

Typescript Metrics Reporter for NATS.

NPM Version License Build Status Dependencies Status

This library is made for inspector-metrics node module and is meant to be used with typescript / nodejs.

It uses node-nats-streaming as NATS client.

Install

npm install --save inspector-nats

Basic usage

If no subject is given as parameter for the reportX methods (reportEvent in the following example), it will default to "DEFAULT_NATS_SUBJECT"

import { Event } from "inspector-metrics";
import { NatsMetricReporter } from "../metrics";
 
// instanciate the Nats reporter
const reporter: NatsMetricReporter = new NatsMetricReporter({
  clientId: "test",
  clusterId: "test-cluster",
});
 
// start reporter
reporter.start()
  .then((connectedReporter) => { // "start()" returns the same reporter instance, after the connection was made
    const event = new Event<{}>("test")
      .setValue({
        int: 123,
        string: "toto",
      });
 
    // send event
    connectedReporter.reportEvent(event)
      .then((event) => {
        
        // perhaps do more things here
 
        // stop reporter
        connectedReporter.stop().catch((reason) => {
          // stop connection error handling
        });
      })
      .catch((reason) => {
        // report error handling
      });
  })
  .catch((reason) => {
    // start connection error handling
  });
 

Running NATS Streaming Server locally

Refer to the Official NATS Streaming Server documentation (you can also directly go to the installing part).

Releasing / publish docs / publish package

# check functionality
npm i
npm run build
 
# release
git commit -am "release of a.b.c"
git push
git tag va.b.c
git push --tags
 
# publish docs
rm -fr docs/
git branch -D gh-pages
git worktree prune
git worktree list
git worktree add -b gh-pages docs origin/gh-pages
npm run publishDocs
 
# publish package
npm publish

License

MIT

Dependents (0)

Package Sidebar

Install

npm i inspector-nats

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

45.3 kB

Total Files

36

Last publish

Collaborators

  • ttous