X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=README.md;h=98afab20652c43e742ebfa80140925ae21ec28e3;hb=a13e50c30dd0e0714ace0e1ea4ea1b36cdd18ab7;hp=ea23397fdf2f3f9a0a5fe2a40ad4035a639b370a;hpb=b492f20e3619b6fbb83bff2f33a6d027b2a758be;p=poolifier.git diff --git a/README.md b/README.md index ea23397f..98afab20 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -
@@ -57,27 +57,18 @@ Please consult our [general guidelines](#general-guidelines).
[![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 guidelines
- ·
- Contribute
- ·
- Team
- ·
- License
-
+## Table of contents
+
+- [Overview](#overview)
+- [Installation](#installation)
+- [Usage](#usage)
+- [Node versions](#node-versions)
+- [API](#api)
+- [General guidelines](#general-guidelines)
+- [Worker choice strategies](#worker-choice-strategies)
+- [Contribute](#contribute)
+- [Team](#team)
+- [License](#license)
## Overview
@@ -119,7 +110,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 +119,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')
})
@@ -140,17 +131,31 @@ pool.emitter.on(PoolEvents.busy, () => console.info('Pool is busy'))
// so you can easy 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/) folder 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/)
+ - [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.
@@ -160,7 +165,9 @@ Node versions >= 16.14.x are supported.
## [API](./docs/api.md)
-## [General Guidelines](./docs/general-guidelines.md)
+## [General guidelines](./docs/general-guidelines.md)
+
+## [Worker choice strategies](./docs/worker-choice-strategies.md)
## Contribute