Socket
Socket
Sign inDemoInstall

anger

Package Overview
Dependencies
6
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    anger

pub-sub tester for Nes


Version published
Weekly downloads
7
increased by133.33%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

anger

A pub-sub load tester for Nes. Designed to be used to write custom "realworld" like scenarios.

Status: Experimental

Install

npm install --save anger

Usage

To use anger, simply require it, and supply it some test scenario configuration.

const anger = require('anger')

const instance = anger({
  url: 'http://localhost:3000',
  subscription: '/greet', // the 'topic' to pub/sub test
  connections: 1000, // 1000 clients connect
  senders: 2, // 2 clients send messages
  requests: 1000, // 2 clients send 1000 requests
  responses: 10000, // expected number of responses (1000 connections responding to 1000 individual requests)
  identifier: (payload) => payload.meta.id, // used to apply an id to messages in, which matches it to the corresponding request
  trigger: (sender) => { // a function used to send a message to the server
    sender.request({
      method: 'POST',
      path: '/h',
      payload: {
        id: ++uid // this is used to map the responses to the requests
      }
    })
    return uid // must return the uid of the message sent
  }
})

instance.on('end', (result) => {
  // some stats are in result
})

API

anger(opts)

Start an anger instance against a given target.

  • opts: An Object with configuration information. Can contain the following attributes:
    • url: The base url of the hapi/nes server you want to test.
    • subscription: A topic to test.
    • connections: The number of connections to maintain to server. Each is an individual nes client.
    • senders: The number of connections that should be senders.
    • responses: The number of overall expected responses to be recieved during this run.
    • auth: A Function or Object passed to the nes client for authentication. If a Function, it is passed the client and index of that client as params. Must return the auth object options. If an Object, it must be passed the auth object options. auth object reference.
    • identifier: A function used to map some payload response data to a requests uid.
    • trigger: A function which is passed a nes client to emit a message to the server for testing. Must return some uid of a message sent.
    • retryOpts: An object which is passed to try-again to achieve exponential backoff for retries. Check the try-again docs for reference on how to use it.. Default values below:
      • retries: 8
      • max: 10000
      • jitter: 0.2
      • factor: 2
      • min: 100

Returns an instance/event emitter for tracking progress, etc.

anger events

Because an anger instance is an EventEmitter, it emits several events. these are below:

  • error: emitted on a error. The callback function will receive the error as the first parameter.
  • connect: emitted when all clients are connected to the server.
  • subscribe: emitted when all clients are subscribed to the server.
  • trigger: emitted when a sender is sending a 'request' message. The callback function will receive the requests uid as the first parameter.
  • publish-events-recieved: emitted when all connections receive the message 'response' sent from the server, in response to some triggered 'request'. The callback should receive the uid for the event that triggered it.
  • end: emmited when testing finishes, with the result passed as the first parameter to the callback.

Sample

Check out the examples folder for a simple sample.

License

MIT. Copyright (c) Matteo Collina and David Mark Clements 2016.

Keywords

FAQs

Last updated on 22 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc