X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=README.md;h=3099709bd3bc41327776d1c89fde26771c455486;hb=a0a2a08e118210a0e6667669b88deeb1f981f8e9;hp=c708c73e5bec44ba9474f6c5587c5f3ec452f83a;hpb=cea8e6b15a8b0ba8fc60769787fdab708844c9bf;p=poolifier.git diff --git a/README.md b/README.md index c708c73e..3099709b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -
@@ -32,20 +32,25 @@
Poolifier is used to perform CPU and/or I/O intensive tasks on Node.js servers, it implements worker pools using [worker_threads](https://nodejs.org/api/worker_threads.html) and [cluster](https://nodejs.org/api/cluster.html) Node.js modules.
With poolifier you can improve your **performance** and resolve problems related to the event loop.
Moreover you can execute your tasks using an API designed to improve the **developer experience**.
-Please consult our [general guidelines](#general-guidance).
+Please consult our [general guidelines](#general-guidelines).
- Easy to use :white_check_mark:
-- Performance [benchmarks](./benchmarks/README.md) :white_check_mark:
- Fixed and dynamic pool size :white_check_mark:
- Easy switch from a pool type to another :white_check_mark:
+- Performance [benchmarks](./benchmarks/README.md) :white_check_mark:
- No runtime dependencies :white_check_mark:
-- Proper integration with node [async_hooks](https://nodejs.org/api/async_hooks.html) :white_check_mark:
-- Support CommonJS, ESM, and TypeScript :white_check_mark:
+- Proper integration with Node.js [async_hooks](https://nodejs.org/api/async_hooks.html) :white_check_mark:
+- Support for CommonJS, ESM, and TypeScript :white_check_mark:
- Support for [worker_threads](https://nodejs.org/api/worker_threads.html) and [cluster](https://nodejs.org/api/cluster.html) Node.js modules :white_check_mark:
-- Support multiple task functions :white_check_mark:
-- Support sync and async task functions :white_check_mark:
+- Support for multiple task functions :white_check_mark:
+- Support for sync and async task functions :white_check_mark:
- Tasks distribution strategies :white_check_mark:
-- General guidance on pool choice :white_check_mark:
+- Lockless tasks queueing :white_check_mark:
+- Queued tasks rescheduling:
+ - Task stealing :white_check_mark:
+ - Tasks stealing under back pressure :white_check_mark:
+ - Tasks redistribution on worker error :white_check_mark:
+- General guidelines on pool choice :white_check_mark:
- Error handling out of the box :white_check_mark:
- Widely tested :white_check_mark:
- Active community :white_check_mark:
@@ -57,27 +62,18 @@ Please consult our [general guidelines](#general-guidance).
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=sqale_index)](https://sonarcloud.io/dashboard?id=pioardi_poolifier)
- Code security [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=security_rating)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=pioardi_poolifier)
-## Contents
-
-
- Overview
- ·
- Installation
- ·
- Usage
- ·
- Node versions
- ·
- API
- ·
- General guidance
- ·
- Contribute
- ·
- Team
- ·
- License
-
+## Table of contents
+
+- [Overview](#overview)
+- [Installation](#installation)
+- [Usage](#usage)
+- [Node.js versions](#nodejs-versions)
+- [API](#api)
+- [General guidelines](#general-guidelines)
+- [Worker choice strategies](#worker-choice-strategies)
+- [Contribute](#contribute)
+- [Team](#team)
+- [License](#license)
## Overview
@@ -119,7 +115,7 @@ const { DynamicThreadPool, FixedThreadPool, PoolEvents, availableParallelism } =
// a fixed worker_threads pool
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
+ errorHandler: (e) => console.error(e),
onlineHandler: () => console.info('worker is online')
})
@@ -128,7 +124,7 @@ pool.emitter.on(PoolEvents.busy, () => console.info('Pool is busy'))
// or a dynamic worker_threads pool
const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
+ errorHandler: (e) => console.error(e),
onlineHandler: () => console.info('worker is online')
})
@@ -137,34 +133,48 @@ pool.emitter.on(PoolEvents.ready, () => console.info('Pool is ready'))
pool.emitter.on(PoolEvents.busy, () => console.info('Pool is busy'))
// the execute method signature is the same for both implementations,
-// so you can easy switch from one to another
+// so you can easily switch from one to another
pool
.execute()
- .then(res => {
+ .then((res) => {
console.info(res)
})
- .catch(err => {
+ .catch((err) => {
console.error(err)
})
```
You can do the same with the classes _ClusterWorker_, _FixedClusterPool_ and _DynamicClusterPool_.
-**See [examples](./examples/) folder for more details (in particular if you want to use a pool with [multiple task functions](./examples/multiFunctionExample.js))**.
+**See [examples](./examples/) for more details**:
+
+- [Javascript](./examples/javascript/)
+- [Typescript](./examples/typescript/)
+ - [HTTP client pool](./examples/typescript/http-client-pool/)
+ - [SMTP client pool](./examples/typescript/smtp-client-pool/)
+ - [HTTP server pool](./examples/typescript/http-server-pool/)
+ - [Express worker_threads pool](./examples/typescript/http-server-pool/express-worker_threads/)
+ - [Express cluster pool](./examples/typescript/http-server-pool/express-cluster/)
+ - [Express hybrid pool](./examples/typescript/http-server-pool/express-hybrid/)
+ - [Fastify worker_threads pool](./examples/typescript/http-server-pool/fastify-worker_threads/)
+ - [Fastify cluster pool](./examples/typescript/http-server-pool/fastify-cluster/)
+ - [Fastify hybrid pool](./examples/typescript/http-server-pool/fastify-hybrid/)
+ - [WebSocket server pool](./examples/typescript/websocket-server-pool/)
+ - [ws worker_threads pool](./examples/typescript/websocket-server-pool/ws-worker_threads/)
+ - [ws cluster pool](./examples/typescript/websocket-server-pool/ws-cluster/)
+ - [ws hybrid pool](./examples/typescript/websocket-server-pool/ws-hybrid/)
Remember that workers can only send and receive structured-cloneable data.
-## Node versions
-
-Node versions >= 16.14.x are supported.
+## Node.js versions
-## [API](https://poolifier.github.io/poolifier/)
+Node.js versions >= 16.14.x are supported.
-[**API Details**](./docs/api-details.md)
+## [API](./docs/api.md)
-## General Guideline
+## [General guidelines](./docs/general-guidelines.md)
-For general guidelines, please refer to [this document](./docs/general-guidelines.md)
+## [Worker choice strategies](./docs/worker-choice-strategies.md)
## Contribute
@@ -178,11 +188,14 @@ See [CONTRIBUTING](CONTRIBUTING.md) guidelines.
- [**Alessandro Pio Ardizio**](https://github.com/pioardi)
-**_Contributors_**
+**Maintainers:**
-- [**Shinigami92**](https://github.com/Shinigami92)
- [**Jérôme Benoit**](https://github.com/jerome-benoit)
+**Contributors:**
+
+- [**Shinigami92**](https://github.com/Shinigami92)
+
## License
[MIT](./LICENSE)