npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

godot2

v1.9.999999999999999

Published

A streaming real-time event processor based on Riemann -- Streams2/3 edition

Downloads

6

Readme

godot2

Build Status Coverage Status Dependency Status devDependency Status Downloads

A streaming real-time event processor based on Riemann written in Node.js

NPM

Godot2 is a major rewrite for Node 6 and Streams2/Streams3 syntax, similar to as suggested in nodejitsu/godot#64. The async patterns and inheritance are simplified with Iced CoffeeScript.

Many thanks and much credit to the original authors at Nodejitsu, @indexzero and @jcrugzz.

Usage

Here is a simple example of a Reactor server that will send an email to [email protected] if the Producer server for app.server fails to send a heartbeat after 60 seconds.

  var godot = require('godot');

  //
  // Reactor server which will email `[email protected]`
  // whenever any service matching /.*\/health\/heartbeat/
  // fails to check in after 60 seconds.
  //
  godot.createServer({
    //
    // Defaults to UDP
    //
    type: 'udp',
    reactors: [
      function (socket) {
        return socket
          .pipe(godot.where('service', '*/health/heartbeat'))
          .pipe(godot.expire(1000 * 60))
          .pipe(godot.email({ to: '[email protected]' }))
      }
    ]
  }).listen(1337);

  //
  // Producer client which sends events for the service
  // `app.server/health/heartbeat` every 15 seconds.
  //
  godot.createClient({
    //
    // Defaults to UDP
    //
    type: 'udp',
    producers: [
      godot.producer({
        host: 'app.server.com',
        service: 'app.server/health/heartbeat',
        ttl: 1000 * 15
      })
    ],
    //
    // Add Reconnect logic that uses `back`
    //
    reconnect: {
      retries: 2,
      minDelay: 100,
      maxDelay: 300
    }
  }).connect(1337);

Events

Similar to Riemann, events in godot are simply JSON sent over UDP or TCP. Each event has these optional fields:

  {
    host:         "A hostname, e.g. 'api1', 'foo.com'"
    service:      "e.g. 'API port 8000 reqs/sec'",
    state:        "Any string less than 255 bytes, e.g. 'ok', 'warning', 'critical'",
    time:         "The time of the event, in unix epoch seconds",
    description:  "Freeform text",
    tags:         "Freeform list of strings, e.g. ['rate', 'fooproduct', 'transient']",
    meta:         "Freeform set of key:value pairs e.g. { 'ewma': 12345 }",
    metric:       "A number associated with this event, e.g. the number of reqs/sec.",
    ttl:          "A floating-point time, in seconds, that this event is considered valid for."
  }

Reactors

Reactors in Godot are readable and writable Stream instances which consume Events and produce actions or aggregate data flow. In the example above you may see that when we define the array of reactors by wrapping it with a simple function. This function has a single argument that represents the data coming over the wire. This data can be piped to any godot stream or any Transform stream you find on NPM!

~~Note Reactors are currently still streams1 streams (so they do not handle backpressure) but this will begin to change in the near future for node 0.12.x. (Performance reasons)~~ I'm about halfway through this. -@doublerebel

Primitives

There are several core Reactor primitives available in godot which can be composed to create more complex behavior:

  • .aggregate(): Aggregates metric property on events
  • .change(key {from: x, to: y}): Emits events when the key is changed, accepts optional from and to options for more specific changes.
  • .email(options): Sends an email to the specified options.
  • .expire(ttl): Emits an event when no data is received after ttl milliseconds.
  • .forward(options): Forwards all events to a remote server located at options.host and options.port.
  • .sms(options): Sends an sms to the specified options.
  • .where(key, value)|.where(filters): Filters events based on a single key:value pair or a set of key:value filters.
  • .rollup(interval, limit)|.rollup(options): Rollup a limit amount of events to emit every interval. interval can also be a function to allow you to create varying intervals (see below).

Rollup

Here are two possible rollup examples:


var godot = require('godot');

//
// Rolls up 10,0000 events every 5 minute interval
// then sends them in an email
//
var rollup = function (socket) {
  return socket
    .pipe(godot.rollup(1000 * 60 * 5, 10000))
    .pipe(godot.email({ to: '[email protected]' }))
}

//
// Scaling Rollup, rolls up 10,000 events every 5min interval for 1 hour,
// then rolls up 10,000 events every 30mins and emails them out
//

var scalingRollup = function (socket) {
  return socket
    .pipe(godot.rollup(function (period) {
      if(period < 12) {
        return 1000 * 60 * 5;
      }
      return 1000 * 60 * 30;
    }, 10000))
    .pipe(godot.email({ to: '[email protected]' }))
}

Producers

Producers in Godot are readable Stream instances which produce Events. Events will be emitted by a given Producer every ttl milliseconds.

Tests

All tests are written in vows and can be run with npm:

  npm test

Copyright (C) 2012. Charlie Robbins, Jarrett Cruger, and the Contributors.

License: MIT

Sound Wave designed by Alessandro Suraci from the thenounproject.com