1.0.0 • Published 3 months ago

http-connection-pool v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

http-connection-pool

| npm |

http-connection-pool quickly performs many HTTP requests in concurrently that cannot be processed at once.

Table of contents

Docs

Installation

npm install http-connection-pool

Usage

CJS (js)

const { ConnectionPool } = require("http-connection-pool");

const connectionPool = new ConnectionPool({size: 1000});
for (let i = 0; i <= 100_000; i++) {
  connectionPool.add({
    url: "http://localhost:3000/get"
  })
  .then(d => {
    console.log(d)
  })
  .catch(e => {
    console.log(e)
  })
}

ESM (js)

import ConnectionPool from "http-connection-pool";

const connectionPool = new ConnectionPool({size: 1000});
for (let i = 0; i <= 100_000; i++) {
  connectionPool.add({
    url: "http://localhost:3000/get"
  })
  .then(d => {
    console.log(d)
  })
  .catch(e => {
    console.log(e)
  })
}

Typescript

import ConnectionPool from "http-connection-pool";

const connectionPool = new ConnectionPool({size: 1000});
for (let i = 0; i <= 100_000; i++) {
  connectionPool.add({
    url: "http://localhost:3000/get"
  })
  .then(d => {
    console.log(d)
  })
  .catch(e => {
    console.log(e)
  })
}

Use External HTTP Library

axios;

import ConnectionPool from "http-connection-pool";
import axios, { AxiosResponse } from "axios";

const connectionPool = new ConnectionPool({size: 1000});
for (let i = 0; i <= 100_000; i++) {
  connectionPool.addExternalHttpClient<AxiosResponse>(axios.get, `http://localhost:${PORT}/test`)
    .then(d => console.log(d.data, i));
}

node-fetch;

import ConnectionPool from 'http-connection-pool';
import fetch, {Response} from "node-fetch";

const connectionPool = new ConnectionPool({size: 1000});
for (let i = 0; i <= 100_000; i++) {
  connectionPool.addExternalHttpClient<Response>(fetch, `http://localhost:${PORT}/test`)
    .then(d => d.text())
    .then(d => console.log(d, i));
}
1.0.0

3 months ago

0.4.0

3 months ago

0.3.2

3 months ago

0.3.1

3 months ago

0.2.0

3 months ago

0.1.1-alpha

3 months ago

0.1.0

3 months ago

0.1.1

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.1

5 months ago