Toxiproxy Node Client
Toxiproxy makes it easy and trivial to test network conditions, for example low-bandwidth and high-latency situations. toxiproxy-node-client
includes everything needed to get started with configuring Toxiproxy upstream connection and listen endpoints.
Installing via NPM
The recommended way to install toxiproxy-node-client
is through NPM.
Once that is installed and you have added toxiproxy-node-client
to your package.json
configuration, you can require the package and start using the library.
JavaScript (ES6) Usage
Here is an example for creating a proxy that limits a Redis connection to 1000KB/s.
// index.js"use strict";const toxiproxyClient = ; const getToxic = { return { const toxiproxy = "http://localhost:8474"; const proxyBody = listen: "localhost:0" name: "ihsw_test_redis_master" upstream: "localhost:6379" ; toxiproxy ; };}; // { attributes: { rate: 1000 },// name: 'bandwidth_downstream',// stream: 'downstream',// toxicity: 1,// type: 'bandwidth' } ;
TypeScript Usage
Here is an example for creating a proxy that limits a Redis connection to 1000KB/s.
// index.ts; ; // { attributes: { rate: 1000 },// name: 'bandwidth_downstream',// stream: 'downstream',// toxicity: 1,// type: 'bandwidth' }getToxic"bandwidth", Bandwidth .thenconsole.logtoxic.toJson .catchconsole.error;
Documentation
Additional examples can be found in the examples
directory for expected usage.