Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

locust-node

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

locust-node

## Links

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-locust

  • Locust Website: locust.io
  • Locust Documentation: docs.locust.io

Description

node-locust is a load generator for locust written in JavaScript

Usage:

# Start locust master
locust --master \
       --master-bind-port 5557 \
       --host <test-server> \
       --locustfile ./locust-node/dummy.py

# Start node client
node-locust --locustfile ./examples/basic.js \
            --master-host 127.0.0.1
            --master-port 5557

Locust file:

const { Locust, TaskSet, HTTPClient } = require('node-locust');

class UserTasks extends TaskSet {
  constructor() {
    super();

    this.http = new HTTPClient({
      baseURL: <test-server>,
      timeout: 2000
    },  this.recordSuccess.bind(this),
        this.recordFailure.bind(this));

    this.tasks = [{
      task: () => this.getUserInfo(),
      weight: 2
    }, {
      task: () => this.updateUserInfo(),
      weight: 1
    }];
  }

  async getUserInfo() {
    await this.http.request({
      method: 'GET',
      url: '/users/1'
    });
  }

  async updateUserInfo() {
    await this.http.request({
      method: 'PUT',
      url: '/users/1',
      body: {
        name: 'user-name'
      }
    });
  }
}

class MyLocust extends Locust {
  constructor() {
    super();

    this.taskSet = new UserTasks();
  }
}

module.exports = { MyLocust };

License

Open source licensed under the MIT license (see LICENSE file for details).

FAQs

Package last updated on 04 Feb 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc