https://github.com/jhkim31/http-connection-pool
HTTP connection pool that can be used when limiting the number of connections and sending multiple requests at the same time.
https://github.com/jhkim31/http-connection-pool
connection-pool http http-connection-pool https
Last synced: 17 days ago
JSON representation
HTTP connection pool that can be used when limiting the number of connections and sending multiple requests at the same time.
- Host: GitHub
- URL: https://github.com/jhkim31/http-connection-pool
- Owner: jhkim31
- License: mit
- Created: 2023-12-12T14:33:47.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-21T09:14:18.000Z (almost 2 years ago)
- Last Synced: 2025-08-30T21:38:17.185Z (5 months ago)
- Topics: connection-pool, http, http-connection-pool, https
- Language: TypeScript
- Homepage:
- Size: 8.75 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-connection-pool
| [npm](https://www.npmjs.com/package/http-connection-pool) |
**http-connection-pool** quickly performs many HTTP requests in concurrently that cannot be processed at once.
## Table of contents
* [Docs](#docs)
* [Installation](#installation)
* [Usage](#usage)
* [CJS (js)](#cjs-js)
* [ESM (js)](#esm-js)
* [Typescript](#typescript)
* [Use External HTTP Library](#use-external-http-library)
* [axios](#axios)
* [node-fetch](#node-fetch)
## Docs
* [Getting Started](./docs/1-GettingStarted.md)
* [API](./docs/2-API.md)
* [Types](./docs/3-Types.md)
## Installation
```bash
npm install http-connection-pool
```
## Usage
### CJS (js)
```javascript
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)
```javascript
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
```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](./example/other-agent/)
### [axios](./example//other-agent/axios.ts);
```typescript
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(axios.get, `http://localhost:${PORT}/test`)
.then(d => console.log(d.data, i));
}
```
### [node-fetch](./example//other-agent/node-fetch.ts);
```typescript
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(fetch, `http://localhost:${PORT}/test`)
.then(d => d.text())
.then(d => console.log(d, i));
}
```