Skip to content

Commit c137480

Browse files
committed
Bump version to v3.0.2: README and docs refinements
1 parent a0fac8e commit c137480

7 files changed

+23
-21
lines changed

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2 align="middle">Zero Backpressure Semaphore Typescript</h2>
1+
<h3 align="middle">Zero Backpressure Semaphore Typescript</h2>
22

33
The `ZeroBackpressureSemaphore` class implements a semaphore for Node.js projects, allowing users to limit the number of concurrently executing jobs.
44
This implementation does not queue pending jobs, thereby eliminating backpressure. As a result, users have better control over memory footprint, which enhances performance by reducing garbage-collector overhead.
@@ -30,15 +30,7 @@ In contrast, `ZeroBackpressureSemaphore` manages job execution, abstracting away
3030

3131
Method names are chosen to clearly convey their functionality.
3232

33-
## Breaking Change in Version 3.0.0
34-
35-
In version 3.0.0, the target compatibility has been upgraded from ES6 to ES2020. This change was made to leverage the widespread adoption of ES2020, its native support for async/await, and the use of `Promise.allSettled` within the semaphore.
36-
37-
## Breaking Change in Version 2.0.0
38-
39-
The only breaking change in this release is the renaming of the method `waitTillAllExecutingJobsAreSettled` to `waitForAllExecutingJobsToComplete` for improved readability. No other changes have been introduced.
40-
41-
## 1st use-case: Multiple Jobs Execution
33+
## 1st use-case: Multiple Jobs Execution :man_technologist:
4234

4335
This semaphore variant excels in eliminating backpressure when dispatching multiple concurrent jobs from the same caller. This pattern is typically observed in **background job services**, such as:
4436
- Log File analysis.
@@ -246,7 +238,7 @@ On the other hand, given that the timeout is 30 seconds and a typical job durati
246238

247239
As a general rule, `waitForAvailability` is advisable whenever a timeout mechanism is involved, and the timeout period begins **before** the job starts execution. Note that the same effect can be achieved with `startExecution` alone, if the timeout-triggering logic is included in the job itself (such as, consuming a message). Both approaches are valid.
248240

249-
## 2nd use-case: Single Job Execution
241+
## 2nd use-case: Single Job Execution :man_technologist:
250242

251243
The `waitForCompletion` method is useful for executing a sub-procedure, for which the caller must wait before proceeding with its work.
252244

@@ -319,6 +311,14 @@ To improve readability and maintainability, it is highly recommended to assign a
319311
- tokenGenerationSemaphore
320312
- azureStorageSemaphore
321313

314+
## Breaking Change in Version 3.0.0 :boom:
315+
316+
In version 3.0.0, the target compatibility has been upgraded from ES6 to ES2020. This change was made to leverage the widespread adoption of ES2020, its native support for async/await, and the use of `Promise.allSettled` within the semaphore.
317+
318+
## Breaking Change in Version 2.0.0 :boom:
319+
320+
The only breaking change in this release is the renaming of the method `waitTillAllExecutingJobsAreSettled` to `waitForAllExecutingJobsToComplete` for improved readability. No other changes have been introduced.
321+
322322
## License :scroll:
323323

324324
[MIT](LICENSE)

dist/zero-backpressure-semaphore.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
9292
* `extractUncaughtError` method. Users are encouraged to specify a custom `UncaughtErrorType`
9393
* generic parameter to the class if jobs may throw errors.
9494
*
95-
* @param job - The job to be executed once the semaphore is available.
95+
* @param backgroundJob - The job to be executed once the semaphore is available.
9696
* @returns A promise that resolves when the job starts execution.
9797
*/
9898
startExecution(backgroundJob: SemaphoreJob<T>): Promise<void>;

dist/zero-backpressure-semaphore.js

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zero-backpressure-semaphore.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zero-backpressure-semaphore-typescript",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "A classic semaphore with modern API, inspired by the RAII idiom. Offering backpressure control for enhanced efficiency, utilizing a communicative API that signals availability. Additionally, it incorporates mechanisms for graceful termination and error handling, making it suitable for complex scenarios.",
55
"repository": {
66
"type": "git",

src/zero-backpressure-semaphore.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ export class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
137137
* `extractUncaughtError` method. Users are encouraged to specify a custom `UncaughtErrorType`
138138
* generic parameter to the class if jobs may throw errors.
139139
*
140-
* @param job - The job to be executed once the semaphore is available.
140+
* @param backgroundJob - The job to be executed once the semaphore is available.
141141
* @returns A promise that resolves when the job starts execution.
142-
*/
142+
*/
143143
public async startExecution(backgroundJob: SemaphoreJob<T>): Promise<void> {
144144
const availableSlot = await this._getAvailableSlot();
145145
this._slots[availableSlot] = this._handleJobExecution(backgroundJob, availableSlot, true);
@@ -300,7 +300,8 @@ export class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
300300
throw err;
301301
}
302302

303-
// Triggered by `startExecution`: A background job.
303+
// Triggered by `startExecution`:
304+
// A background job, the caller does not await for its return value to proceed.
304305
this._uncaughtErrors.push(err);
305306
} finally {
306307
this._slots[allottedSlot] = undefined;

0 commit comments

Comments
 (0)