Jackall
async/await for optimistic concurrency control. (Last in wins.)
Install
npm install jackall
Usage
Please refer to tests.
; // async tasks.;; // jackall.acquire. (resource name is `tiger`); // last in wins.// act1 => { ok: false, code: JACKALL_ERROR_CODE.NOMATCH_VERSION, value: new Error(`Jackall Error: ${JACKALL_ERROR_CODE.NOMATCH_VERSION}`) }// act2 => { ok: true, value: "ping2" }
If you want to specify a resource name.
; ; // jackall.acquire("tiger", task1()) => OK// jackall.acquire("bear", task1()) => NG
Error Codes
;
option | description |
---|---|
FAILED_ASYNCTASK | Failed to Async task. |
NOMATCH_VERSION | Lost in the race conditions.(Last in Wins.) |
License
Jackall is MIT licensed.