X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=README.md;h=ad01a6eea95c36911ca02150f4c7fa6f032e471d;hb=e901162fa610e2af305aac504549580b2de48cab;hp=e42597d7289efcbb638ac802edc5d041b070fce7;hpb=f2b5671a88c97214b62698d3a02b1021646b1839;p=poolifier.git diff --git a/README.md b/README.md index e42597d7..ad01a6ee 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,30 @@ -# Node Thread Pool :arrow_double_up: :on: - -[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) -[![Dependabot](https://badgen.net/dependabot/dependabot/dependabot-core/?icon=dependabot)](https://badgen.net/dependabot/dependabot/dependabot-core/?icon=dependabot) -[![npm w](https://img.shields.io/npm/dw/poolifier)](https://www.npmjs.com/package/poolifier) -[![Actions Status](https://github.com/pioardi/node-pool/workflows/NodeCI/badge.svg)](https://github.com/pioardi/node-pool/actions) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=alert_status)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) - [![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=pioardi_poolifier) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -[![NODEP](https://img.shields.io/static/v1?label=dependencies&message=no%20dependencies&color=brightgreen)](https://img.shields.io/static/v1?label=dependencies&message=no%20dependencies&color=brightgreen) -[![Gitter](https://badges.gitter.im/poolifier/community.svg)](https://gitter.im/poolifier/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -
- +
+

Node Thread Pool :arrow_double_up: :on:

+ +

+ + Weekly Downloads + + Actions Status + + Quality Gate Status + + Code coverage + + Javascript Standard Style Guide + + Gitter chat + + Dependabot + + PR Welcome + + No dependencies +

+ ## Why Poolifier? Poolifier is used to perform heavy CPU bound tasks on nodejs servers, it implements thread pools (yes, more thread pool implementations, so you can choose which one fit better for you) using [worker-threads](https://nodejs.org/api/worker_threads.html#worker_threads_worker_threads). @@ -22,23 +33,23 @@ Moreover you can execute your CPU tasks using an API designed to improve the **d - Performance :racehorse: - Security :bank: :cop: [![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) - -- No runtime dependencies :heavy_check_mark: (until now we don't have any expectations to add some)- Easy to use :couple: +- Easy to use :couple: +- Easy switch from a pool to another, easy to tune :heavy_check_mark: +- Dynamic pool size :heavy_check_mark: +- No runtime dependencies :heavy_check_mark: +- Proper async integration with node async hooks :heavy_check_mark: +- Support for worker threads and cluster node modules :heavy_check_mark: +- Support sync and async tasks :heavy_check_mark: +- General guidance on pools to use :heavy_check_mark: +- Widely tested :heavy_check_mark: +- Error handling out of the box :heavy_check_mark: +- Active community :heavy_check_mark: - Code quality :octocat: [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=bugs)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=code_smells)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=sqale_index)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) -- Easy switch from a pool to another, easy to tune -- Dynamic pool size -- Proper async integration with node async hooks -- Support for worker threads and cluster node modules -- Active community -- Support sync and async tasks -- General guidance on pools to use -- Widely tested -- Error handling out of the box + [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=code_smells)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) + [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) + [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) + [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) + [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=pioardi_poolifier&metric=sqale_index)](https://sonarcloud.io/dashboard?id=pioardi_poolifier) ## Contents @@ -163,8 +174,18 @@ This method will call the terminate method on each worker. `fn` (mandatory) The function that you want to execute on the worker thread `opts` (optional) An object with these properties: -- `maxInactiveTime` - Max time to wait tasks to work on ( in ms) , after this period the new worker threads will die. +- `maxInactiveTime` - Max time to wait tasks to work on (in ms), after this period the new worker threads will die. +The last active time of your worker unit will be updated when a task is submitted to a worker or when a worker terminate a task. +If `killBehavior` is set to `KillBehaviors.HARD` this value represents also the timeout for the tasks that you submit to the pool, when this timeout expires your tasks is interrupted and the worker is killed if is not part of the minimum size of the pool. +If `killBehavior` is set to `KillBehaviors.SOFT` your tasks have no timeout and your workers will not be terminated until your task is completed. +Default: 60.000 ms + - `async` - true/false, true if your function contains async pieces else false +- `killBehavior` - Dictates if your async unit (worker/process) will be deleted in case that a task is active on it. +**SOFT**: If `currentTime - lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker **wont** be deleted. +**HARD**: If `lastActiveTime` is greater than `maxInactiveTime` but a task is still running, then the worker will be deleted. +This option only apply to the newly created workers. +Default: `SOFT` ## Choose your pool