arb / good-squeeze

Simple transform stream for event filtering with good.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

good-squeeze

A simple transform stream for filtering events from good.

Build Status Current Version

Lead Maintainer: Adam Bretz

Usage

good-squeeze is a transform stream useful in custom good reporter clients. It should generally be used as the first step in a custom pipeline to filter out events that the current reporter isn't subscribed to.

Methods

GoodSqueeze(events, [options])

Creates a new GoodSqueeze object where:

  • events an object where each key is a valid good event, and the value is a string or array of strings representing event tags. "*" indicates no filtering. null and undefined are assumed to be "*".
  • options an optional configuration object that gets passed to the Node Stream.Transform constructor. Note objectMode is always true for all GoodSqueeze objects.

GoodSqueeze.subscription(events)

A static method on GoodSqueeze that creates a new event subscription map where:

  • events an object where each key is a valid good event, and the value is a string or array of strings representing event tags. "" indicates no filtering. null and undefined are assumed to be "".
var GoodSqueeze = require('good-squeeze');

GoodSqueeze.subscription({ log: 'user', ops: '*', request: ['hapi', 'foo'] });

// Results in
// {
//     log: [ 'user' ],
//     ops: [],
//     request: [ 'hapi', 'foo', 'hapi', 'foo' ]
// }

Useful for creating an event subscription to be used with GoodSqueeze.filter if you do not plan on creating a pipeline coming from good and instead want to manage event filtering manually.

GoodSqueeze.filter(subscription, data)

Returns true if the supplied data.event + data.tags should be reported based on subscription where:

  • subscription - a subscription map created by GoodSqueeze.subscription().
  • data - event object emitted from good/hapi which should contain the following keys:
    • event - a string representing the event name of data
    • tags - an array of strings representing tags associated with this event.

About

Simple transform stream for event filtering with good.

License:Other


Languages

Language:JavaScript 100.0%