@joemccann/flood

1.0.0Β β€’Β PublicΒ β€’Β Published

Flood

🌊 Flood a network with requests in batches with retries.

Usage

npm i -S @joemccann/flood
const flood = require('@joemccann/flood')

const data = {
  batchSize: 50, // The number of simultaneous requests...
  done: (data) => {
    // write to file or console.dir(data)
    // Data is an array of objects of type {data: [...], url: 'http://...'}
  },
  errorHandler: (e, results) => { 
    console.error(e) 
    // do something with the results maybe?
  },
  sleepTime: 100, // sleep in between batches, not each request; in milliseconds
  url: `http://localhost:8080/api/foo?id={iteration}`, // {iteration} is REQUIRED
  values: ['a','b','c'] // the value to update on the query string
}

try{
  const { data, err } = await flood(data)
  console.dir(data) // data is the same data passed into done()
} catch(e) {
  console.error(e)
}

NOTE: The retries will go on forever so be wise about how you handle the errors.

Tests

npm i -D
npm test

Authors

LICENSE

MIT

Readme

Keywords

Package Sidebar

Install

npm i @joemccann/flood

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.8 kB

Total Files

8

Last publish

Collaborators

  • joemccann