better-lock 2.0.2-beta → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.idea/prettier.xml +1 -0
  2. package/README.md +64 -45
  3. package/dist/better_lock.d.ts +7 -4
  4. package/dist/better_lock.js +17 -14
  5. package/dist/better_lock.js.map +1 -1
  6. package/dist/errors.d.ts +3 -1
  7. package/dist/errors.js +11 -12
  8. package/dist/errors.js.map +1 -1
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/internals.js +2 -2
  12. package/dist/internals.js.map +1 -1
  13. package/dist/options.d.ts +5 -0
  14. package/dist/types.d.ts +1 -1
  15. package/docs/.nojekyll +1 -0
  16. package/docs/assets/highlight.css +92 -0
  17. package/docs/assets/main.js +54 -0
  18. package/docs/assets/search.js +1 -0
  19. package/docs/assets/style.css +1300 -0
  20. package/docs/assets/widgets.png +0 -0
  21. package/docs/assets/widgets@2x.png +0 -0
  22. package/docs/classes/BetterLockError.html +109 -0
  23. package/docs/classes/BetterLockExecutionTimeoutError.html +122 -0
  24. package/docs/classes/BetterLockInternalError.html +101 -0
  25. package/docs/classes/BetterLockInvalidArgumentError.html +112 -0
  26. package/docs/classes/BetterLockJobAbortedError.html +115 -0
  27. package/docs/classes/BetterLockQueueOverflowError.html +142 -0
  28. package/docs/classes/BetterLockWaitTimeoutError.html +122 -0
  29. package/docs/classes/_internal_.BetterLock.html +324 -0
  30. package/docs/classes/_internal_.KeyQueue.html +127 -0
  31. package/docs/classes/_internal_.LockJob.html +226 -0
  32. package/docs/index.html +281 -0
  33. package/docs/interfaces/BetterLockJobOptions.html +89 -0
  34. package/docs/interfaces/BetterLockOptions.html +153 -0
  35. package/docs/modules/_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html +80 -0
  36. package/docs/modules/_internal_.html +68 -0
  37. package/docs/modules.html +96 -0
  38. package/docs/types/BetterLockErrorName.html +61 -0
  39. package/docs/types/BetterLockExecutor.html +63 -0
  40. package/docs/types/BetterLockKey.html +61 -0
  41. package/docs/types/BetterLockQueueEjectionStrategy.html +59 -0
  42. package/docs/types/_internal_.ICallback.html +59 -0
  43. package/docs/types/_internal_.ICallbackExecutor.html +73 -0
  44. package/docs/types/_internal_.IErrorExports.html +52 -0
  45. package/docs/types/_internal_.IPromiseExecutor.html +65 -0
  46. package/docs/variables/BetterLock.html +59 -0
  47. package/package.json +8 -5
  48. package/spec/better_lock.spec.ts +37 -1
  49. package/src/better_lock.ts +14 -9
  50. package/src/errors.ts +5 -2
  51. package/src/index.ts +2 -1
  52. package/src/options.ts +7 -0
  53. package/src/types.ts +2 -2
@@ -0,0 +1,281 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container">
3
+ <div class="table-cell" id="tsd-search" data-base=".">
4
+ <div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
5
+ <ul class="results">
6
+ <li class="state loading">Preparing search index...</li>
7
+ <li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">better-lock</a></div>
8
+ <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
9
+ <div class="container container-main">
10
+ <div class="col-8 col-content">
11
+ <div class="tsd-page-title">
12
+ <h2>better-lock</h2></div>
13
+ <div class="tsd-panel tsd-typography">
14
+ <a href="#better-lock" id="better-lock" style="color: inherit; text-decoration: none;">
15
+ <h1>Better Lock</h1>
16
+ </a>
17
+ <p>A (better) node.js lock library.</p>
18
+
19
+ <a href="#features" id="features" style="color: inherit; text-decoration: none;">
20
+ <h3>Features</h3>
21
+ </a>
22
+ <ul>
23
+ <li>Typescript-ready</li>
24
+ <li>Named and keyed locks</li>
25
+ <li>Queue and execution timeouts</li>
26
+ <li>Queue size limit</li>
27
+ <li>Lock on multiple keys</li>
28
+ <li>Extended stack traces</li>
29
+ <li>Promise and callback interface</li>
30
+ <li>JSDoc annotations</li>
31
+ <li>Good error messages</li>
32
+ <li>Unit tests, good code coverage</li>
33
+ <li>No dependencies</li>
34
+ </ul>
35
+
36
+ <a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
37
+ <h3>Installation</h3>
38
+ </a>
39
+ <pre><code class="language-bash"><span class="hl-0">npm install --save better-lock</span><br/><span class="hl-1"># or</span><br/><span class="hl-0">yarn add better-lock</span>
40
+ </code></pre>
41
+
42
+ <a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;">
43
+ <h3>Documentation</h3>
44
+ </a>
45
+ <p>Full docs: <a href="https://panta82.github.io/better-lock/">https://panta82.github.io/better-lock/</a></p>
46
+
47
+ <a href="#minimal-example" id="minimal-example" style="color: inherit; text-decoration: none;">
48
+ <h5>Minimal example</h5>
49
+ </a>
50
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">();</span><br/><br/><span class="hl-5">try</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">res</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-2">async</span><span class="hl-0"> () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Inside the lock. It will stay closed until the promise you return resolves or rejects.</span><br/><span class="hl-0"> </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-4">doSomeAsyncTask</span><span class="hl-0">();</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-7">&#39;my result&#39;</span><span class="hl-0">;</span><br/><span class="hl-0"> });</span><br/><br/><span class="hl-0"> </span><span class="hl-1">// Outside the lock. You will get whatever the promise chain has returned.</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-6">res</span><span class="hl-0">); </span><span class="hl-1">// &quot;my result&quot;</span><br/><span class="hl-0">} </span><span class="hl-5">catch</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// Either your or BetterLock&#39;s error</span><br/><span class="hl-0">}</span>
51
+ </code></pre>
52
+
53
+ <a href="#advanced-example" id="advanced-example" style="color: inherit; text-decoration: none;">
54
+ <h5>Advanced example</h5>
55
+ </a>
56
+ <pre><code class="language-typescript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">({</span><br/><span class="hl-0"> </span><span class="hl-6">name:</span><span class="hl-0"> </span><span class="hl-7">&#39;FileLock&#39;</span><span class="hl-0">, </span><span class="hl-1">// To be used in error reporting and logging</span><br/><span class="hl-0"> </span><span class="hl-6">log:</span><span class="hl-0"> </span><span class="hl-6">winstonLogger</span><span class="hl-0">.</span><span class="hl-6">debug</span><span class="hl-0">, </span><span class="hl-1">// Give it your logger with appropeiate level</span><br/><span class="hl-0"> </span><span class="hl-6">wait_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">30</span><span class="hl-0">, </span><span class="hl-1">// Max 30 sec wait in queue</span><br/><span class="hl-0"> </span><span class="hl-6">execution_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0"> * </span><span class="hl-8">5</span><span class="hl-0">, </span><span class="hl-1">// Time out after 5 minutes</span><br/><span class="hl-0"> </span><span class="hl-6">queue_size:</span><span class="hl-0"> </span><span class="hl-8">1</span><span class="hl-0">, </span><span class="hl-1">// At most one pending job</span><br/><span class="hl-0">});</span><br/><br/><span class="hl-2">async</span><span class="hl-0"> </span><span class="hl-2">function</span><span class="hl-0"> </span><span class="hl-4">processFile</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-5">try</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">result</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">, </span><span class="hl-2">async</span><span class="hl-0"> () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">appended</span><span class="hl-0"> = </span><span class="hl-5">await</span><span class="hl-0"> </span><span class="hl-4">appendToFile</span><span class="hl-0">(</span><span class="hl-6">filename</span><span class="hl-0">);</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-4">updateDb</span><span class="hl-0">(</span><span class="hl-6">appended</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">status:</span><span class="hl-0"> </span><span class="hl-2">true</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-6">result</span><span class="hl-0">,</span><br/><span class="hl-0"> };</span><br/><span class="hl-0"> } </span><span class="hl-5">catch</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0"> </span><span class="hl-2">instanceof</span><span class="hl-0"> </span><span class="hl-9">BetterLock</span><span class="hl-0">.</span><span class="hl-9">QueueOverflowError</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// The job was discarded</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">status:</span><span class="hl-0"> </span><span class="hl-2">false</span><span class="hl-0">,</span><br/><span class="hl-0"> };</span><br/><span class="hl-0"> }</span><br/><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0"> </span><span class="hl-2">instanceof</span><span class="hl-0"> </span><span class="hl-9">BetterLock</span><span class="hl-0">.</span><span class="hl-9">ExecutionTimeoutError</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-6">winstonLogger</span><span class="hl-0">.</span><span class="hl-4">warn</span><span class="hl-0">(</span><span class="hl-7">&#39;Potential swallowed callback! Stack trace to the entry site:&#39;</span><span class="hl-0">, </span><span class="hl-6">err</span><span class="hl-0">.</span><span class="hl-6">stack</span><span class="hl-0">);</span><br/><span class="hl-0"> }</span><br/><span class="hl-0"> </span><span class="hl-5">throw</span><span class="hl-0"> </span><span class="hl-6">err</span><span class="hl-0">;</span><br/><span class="hl-0"> }</span><br/><span class="hl-0">}</span>
57
+ </code></pre>
58
+
59
+ <a href="#locking-on-multiple-keys" id="locking-on-multiple-keys" style="color: inherit; text-decoration: none;">
60
+ <h5>Locking on multiple keys</h5>
61
+ </a>
62
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">userLock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">({</span><br/><span class="hl-0"> </span><span class="hl-6">name:</span><span class="hl-0"> </span><span class="hl-7">&#39;User lock&#39;</span><span class="hl-0">,</span><br/><span class="hl-0"> </span><span class="hl-6">executionTimeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0"> * </span><span class="hl-8">60</span><span class="hl-0">, </span><span class="hl-1">// Note you can also use camelCase</span><br/><span class="hl-0">});</span><br/><br/><span class="hl-2">function</span><span class="hl-0"> </span><span class="hl-4">transferBetweenUsers</span><span class="hl-0">(</span><span class="hl-6">fromId</span><span class="hl-0">, </span><span class="hl-6">toId</span><span class="hl-0">, </span><span class="hl-6">amount</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-6">userLock</span><br/><span class="hl-0"> .</span><span class="hl-4">acquire</span><span class="hl-0">([</span><span class="hl-6">fromId</span><span class="hl-0">, </span><span class="hl-6">toId</span><span class="hl-0">], () </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-9">Promise</span><span class="hl-0">.</span><span class="hl-4">all</span><span class="hl-0">([</span><span class="hl-6">User</span><span class="hl-0">.</span><span class="hl-4">get</span><span class="hl-0">(</span><span class="hl-6">fromId</span><span class="hl-0">), </span><span class="hl-6">User</span><span class="hl-0">.</span><span class="hl-4">get</span><span class="hl-0">(</span><span class="hl-6">toId</span><span class="hl-0">)]).</span><span class="hl-4">then</span><span class="hl-0">(([</span><span class="hl-6">fromUser</span><span class="hl-0">, </span><span class="hl-6">toUser</span><span class="hl-0">]) </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">fromUser</span><span class="hl-0">.</span><span class="hl-6">amount</span><span class="hl-0"> -= </span><span class="hl-6">amount</span><span class="hl-0">;</span><br/><span class="hl-0"> </span><span class="hl-6">toUser</span><span class="hl-0">.</span><span class="hl-6">amount</span><span class="hl-0"> += </span><span class="hl-6">amount</span><span class="hl-0">;</span><br/><span class="hl-0"> </span><span class="hl-5">return</span><span class="hl-0"> </span><span class="hl-9">Promise</span><span class="hl-0">.</span><span class="hl-4">all</span><span class="hl-0">([</span><span class="hl-6">user1</span><span class="hl-0">.</span><span class="hl-4">save</span><span class="hl-0">(), </span><span class="hl-6">user2</span><span class="hl-0">.</span><span class="hl-4">save</span><span class="hl-0">()]);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0"> })</span><br/><span class="hl-0"> .</span><span class="hl-4">then</span><span class="hl-0">(() </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-7">&#39;Transfer completed&#39;</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0">}</span>
63
+ </code></pre>
64
+
65
+ <a href="#using-callback-interface" id="using-callback-interface" style="color: inherit; text-decoration: none;">
66
+ <h5>Using callback interface</h5>
67
+ </a>
68
+ <pre><code class="language-javascript"><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">BetterLock</span><span class="hl-0"> = </span><span class="hl-4">require</span><span class="hl-0">(</span><span class="hl-7">&#39;better-lock&#39;</span><span class="hl-0">);</span><br/><br/><span class="hl-2">const</span><span class="hl-0"> </span><span class="hl-3">lock</span><span class="hl-0"> = </span><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-4">BetterLock</span><span class="hl-0">();</span><br/><span class="hl-1">//...</span><br/><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><br/><span class="hl-0"> </span><span class="hl-6">done</span><span class="hl-0"> </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Inside the lock</span><br/><span class="hl-0"> </span><span class="hl-4">doMyAsyncStuffHere</span><span class="hl-0">(</span><span class="hl-6">err</span><span class="hl-0"> </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Call done when done</span><br/><span class="hl-0"> </span><span class="hl-4">done</span><span class="hl-0">(</span><span class="hl-6">err</span><span class="hl-0">);</span><br/><span class="hl-0"> });</span><br/><span class="hl-0"> },</span><br/><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">, </span><span class="hl-6">result</span><span class="hl-0">) </span><span class="hl-2">=&gt;</span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-1">// Outside the lock</span><br/><span class="hl-0"> </span><span class="hl-5">if</span><span class="hl-0"> (</span><span class="hl-6">err</span><span class="hl-0">) {</span><br/><span class="hl-0"> </span><span class="hl-1">// Either your or BetterLock&#39;s error</span><br/><span class="hl-0"> </span><span class="hl-6">console</span><span class="hl-0">.</span><span class="hl-4">error</span><span class="hl-0">(</span><span class="hl-6">err</span><span class="hl-0">);</span><br/><span class="hl-0"> }</span><br/><span class="hl-0"> }</span><br/><span class="hl-0">);</span>
69
+ </code></pre>
70
+ <p>You can see a bunch more usage examples in the spec file, <a href="spec/better_lock.spec.ts">here</a>;</p>
71
+
72
+ <a href="#api" id="api" style="color: inherit; text-decoration: none;">
73
+ <h3>API</h3>
74
+ </a>
75
+ <ul>
76
+ <li><p><code>new BetterLock(options)</code><br>Create a new instance of <code>BetterLock</code>. Options should match interface <code>BetterLockOptions</code>. See below for details.</p>
77
+ </li>
78
+ <li><p><code>BetterLock.acquire([key], executor, [callback], [jobOptions])</code><br>The main method you&#39;ll want to call. For each <code>key</code>, given <code>executor</code> will be called only one at a time. If you don&#39;t provide <code>callback</code>, it will return a promise that will be resolved with whatever <code>executor</code> returns.</p>
79
+ <ul>
80
+ <li><code>key</code>: Arbitrary string under which to lock. It allows you to use the same lock instance for multiple parallel concerns. Eg. this might be a database record id or filename.</li>
81
+ <li><code>executor</code>: Function that will be called within the lock. This function should have one of two forms.<ol>
82
+ <li><em>Without arguments</em>, in which case it should return a promise. Lock will remain locked until the promise resolves.</li>
83
+ <li><em>With single <code>done</code></em> argument. In this case, the executor should call <code>done(err, res)</code> once it is done. Arguments passed to done will be passed to the callback of the lock.</li>
84
+ </ol>
85
+ </li>
86
+ <li><code>callback</code>: Optional callback that will be called once executor exits. Results from executor (resolved/rejected value or arguments given to <code>done</code>) will be passed along. This can be used in addition to the returned promise.</li>
87
+ <li><code>jobOptions</code>: An object that should match interface <code>BetterLockJobOptions</code>. A subset of main options that will serve as overrides for this particular job (for example, timeout settings).</li>
88
+ </ul>
89
+ </li>
90
+ <li><p><code>BetterLock.canAcquire([key])</code><br>Returns true if given key can be acquired.</p>
91
+ </li>
92
+ <li><p><code>BetterLock.abort([key])</code><br>Abort all jobs for a given key (or from the default job queue, if no key is given). Job executors will not be called. Callbacks will be called with <code>JobAbortedError</code>. Currently executing job will not be interrupted.</p>
93
+ </li>
94
+ <li><p><code>BetterLock.abortAll()</code><br>Abort all jobs for all keys. This is suitable to be called during shutdown of your app.</p>
95
+ </li>
96
+ </ul>
97
+
98
+ <a href="#options" id="options" style="color: inherit; text-decoration: none;">
99
+ <h3>Options</h3>
100
+ </a>
101
+ <p>All available options can be seen <a href="https://panta82.github.io/better-lock/interfaces/BetterLockOptions">here</a>.</p>
102
+ <p><code>BetterLockOptions</code> are provided when you construct a lock instance. A subset of options given in <code>LockJobOptions</code> can be provided when you call <code>lock.acquire</code>, as the last argument.</p>
103
+ <p>Example:</p>
104
+ <pre><code class="language-javascript"><span class="hl-6">lock</span><span class="hl-0">.</span><span class="hl-4">acquire</span><span class="hl-0">(</span><span class="hl-6">executor</span><span class="hl-0">, </span><span class="hl-6">callback</span><span class="hl-0">, {</span><br/><span class="hl-0"> </span><span class="hl-6">wait_timeout:</span><span class="hl-0"> </span><span class="hl-8">1000</span><span class="hl-0">,</span><br/><span class="hl-0">});</span>
105
+ </code></pre>
106
+ <p>Most commonly used options are:</p>
107
+ <ul>
108
+ <li><p><code>wait_timeout</code><br>How long can jobs wait in queue before timing out (ms). Null to disable timeout.</p>
109
+ </li>
110
+ <li><p><code>execution_timeout</code><br>How long can a job be executing before timing out (ms). Null to disable timeout.
111
+ If you do that, though, and you have a swallowed callback, the lock can remain locked permanently.</p>
112
+ </li>
113
+ <li><p><code>queue_size</code><br>Max queue size for waiting jobs.</p>
114
+ </li>
115
+ <li><p><code>queue_ejection_strategy</code><br>Which job to eject from the queue when it&#39;s full. Default is <code>newest</code>.</p>
116
+ </li>
117
+ </ul>
118
+ <p>Default options are a static member <code>DEFAULT_OPTIONS</code> on the <code>BetterLock</code> class. During runtime, you can change the defaults like this:</p>
119
+ <pre><code class="language-javascript"><span class="hl-5">import</span><span class="hl-0"> </span><span class="hl-6">BetterLock</span><span class="hl-0"> </span><span class="hl-5">from</span><span class="hl-0"> </span><span class="hl-7">&#39;better-lock&#39;</span><span class="hl-0">;</span><br/><br/><span class="hl-6">BetterLock</span><span class="hl-0">.</span><span class="hl-3">DEFAULT_OPTIONS</span><span class="hl-0">.</span><span class="hl-6">wait_timeout</span><span class="hl-0"> = </span><span class="hl-8">1000</span><span class="hl-0">;</span>
120
+ </code></pre>
121
+
122
+ <a href="#when-to-use" id="when-to-use" style="color: inherit; text-decoration: none;">
123
+ <h3>When to use</h3>
124
+ </a>
125
+ <p>This library is a good fit if:</p>
126
+ <ul>
127
+ <li>You need a local lock in your node.js application.</li>
128
+ <li>You have some advanced needs, like multiple keys per lock, timeouts, aborting...</li>
129
+ <li>You like good error messages, with full stack traces.</li>
130
+ <li>You like good types, either through typescript or JSDoc comments</li>
131
+ </ul>
132
+ <p>The library is not a good fit if:</p>
133
+ <ul>
134
+ <li><p><strong>You need lock reentrancy.</strong><br>There is no good solution for this in node.js that I know of. And this library doesn&#39;t offer any.</p>
135
+ </li>
136
+ <li><p><strong>You need a shared lock between different nodes</strong><br>This library is a single process only. If you need to coordinate multiple apps or services, you need a different library.</p>
137
+ </li>
138
+ </ul>
139
+
140
+ <a href="#change-log" id="change-log" style="color: inherit; text-decoration: none;">
141
+ <h3>Change log</h3>
142
+ </a>
143
+
144
+ <a href="#300-20240418" id="300-20240418" style="color: inherit; text-decoration: none;">
145
+ <h4><strong>3.0.0</strong> (<em>2024/04/18</em>)</h4>
146
+ </a>
147
+ <p>Add option <code>queue_ejection_strategy</code>.</p>
148
+ <p>Major version bump because the default strategy changed from &quot;newest&quot; (the old assumed value) to &quot;newest&quot; (makes more sense).</p>
149
+ <p>To migrate, specify:</p>
150
+ <pre><code class="language-javascript"><span class="hl-0">{</span><br/><span class="hl-0"> </span><span class="hl-7">&quot;queue_ejection_strategy&quot;</span><span class="hl-0">: </span><span class="hl-7">&quot;newest&quot;</span><br/><span class="hl-0">}</span>
151
+ </code></pre>
152
+ <p>in your job options.</p>
153
+
154
+ <a href="#203-20220528" id="203-20220528" style="color: inherit; text-decoration: none;">
155
+ <h4><strong>2.0.3</strong> (<em>2022/05/28</em>)</h4>
156
+ </a>
157
+ <p>Introduce generated API docs. Remove beta tag from npm version.</p>
158
+
159
+ <a href="#200-20210530" id="200-20210530" style="color: inherit; text-decoration: none;">
160
+ <h4><strong>2.0.0</strong> (<em>2021/05/30</em>)</h4>
161
+ </a>
162
+ <p>Major update. The entire library was rewritten in typescript, so you should now get typings in most editors. We also had to switch tests from mocha + chai to jest (easier ts integration).</p>
163
+ <p>The API and features have remained largely the same, just a bit of a refresh.</p>
164
+ <p>Non-breaking and internal changes:</p>
165
+ <ul>
166
+ <li>We now export all error names as a type script type. A few other types as well.</li>
167
+ <li>Errors now have <code>name</code> parameter, which matches these names.</li>
168
+ </ul>
169
+ <p>Breaking changes:</p>
170
+ <ul>
171
+ <li><p>You can no longer use camel case versions of external-facing objects. Eg. you can no longer pass <code>waitTimeout</code> instead of <code>wait_timeout</code>. In retrospect, this was a pretty flaky API to maintain.</p>
172
+ </li>
173
+ <li><p>Internal <code>LockJob</code> class is no longer exported.</p>
174
+ </li>
175
+ <li><p>Also, errors no longer expose internal <code>LockJob</code> instances (<code>err.job</code>). We now instead provide the most important fields from the job (<code>id</code> and <code>keys</code>).</p>
176
+ </li>
177
+ <li><p>Error names have been renamed to have <code>BetterLock</code> prefix. Eg. <code>WaitTimeoutError</code> -&gt; <code>BetterLockWaitTimeoutError</code>. This will influence <code>err.name</code> and <code>err.message</code> parameters. The idea here is, if you see <code>BetterLock</code> error in the wild, you will know what generated it.</p>
178
+ </li>
179
+ <li><p>We have renamed <code>BetterLock.BetterLockError</code> to <code>BetterLock.BaseError</code> and <code>BetterLock.BetterLockInternalError</code> to <code>BetterLock.InternalError</code> to better match the naming scheme.</p>
180
+ </li>
181
+ <li><p>Since Options are no longer a class but interface, we are no longer exporting them under <code>BetterLock.Options</code>. You can do <code>import {BetterLockOptions} from &#39;better-lock&#39;;</code> to get the typescript type.</p>
182
+ </li>
183
+ </ul>
184
+
185
+ <a href="#101-20190128" id="101-20190128" style="color: inherit; text-decoration: none;">
186
+ <h4><strong>1.0.1</strong> (<em>2019/01/28</em>)</h4>
187
+ </a>
188
+ <p>Handle empty key list</p>
189
+
190
+ <a href="#100-20190128" id="100-20190128" style="color: inherit; text-decoration: none;">
191
+ <h4><strong>1.0.0</strong> (<em>2019/01/28</em>)</h4>
192
+ </a>
193
+ <p>Major version bump.</p>
194
+ <ul>
195
+ <li>Added multi-key locks and refactored a bunch of internals.</li>
196
+ <li>Removed <code>OVERFLOW_STRATEGIES</code> and related options, which is mostly the reason for the major version bump. The library should otherwise work the same.</li>
197
+ </ul>
198
+
199
+ <a href="#031-20181001" id="031-20181001" style="color: inherit; text-decoration: none;">
200
+ <h4><strong>0.3.1</strong> (<em>2018/10/01</em>)</h4>
201
+ </a>
202
+ <p>Updated CI to use the current node versions (0.8 &amp; 0.10). Older node versions should continue to work, but are no longer tested. Also, README updates.</p>
203
+
204
+ <a href="#030-20181001" id="030-20181001" style="color: inherit; text-decoration: none;">
205
+ <h4><strong>0.3.0</strong> (<em>2018/10/01</em>)</h4>
206
+ </a>
207
+ <p>Can abort jobs waiting in queue.</p>
208
+
209
+ <a href="#021-20180927" id="021-20180927" style="color: inherit; text-decoration: none;">
210
+ <h4><strong>0.2.1</strong> (<em>2018/09/27</em>)</h4>
211
+ </a>
212
+ <ul>
213
+ <li>Better and customizable Promise detection.</li>
214
+ <li>Restored DEFAULT_OPTIONS.</li>
215
+ </ul>
216
+
217
+ <a href="#020-20180927" id="020-20180927" style="color: inherit; text-decoration: none;">
218
+ <h4><strong>0.2.0</strong> (<em>2018/09/27</em>)</h4>
219
+ </a>
220
+ <p>Code reformat, better pattern for loading options. No feature upgrades.</p>
221
+
222
+ <a href="#011-20180604" id="011-20180604" style="color: inherit; text-decoration: none;">
223
+ <h4><strong>0.1.1</strong> (<em>2018/06/04</em>)</h4>
224
+ </a>
225
+ <p>You can now use a Number as job name</p>
226
+
227
+ <a href="#development" id="development" style="color: inherit; text-decoration: none;">
228
+ <h3>Development</h3>
229
+ </a>
230
+ <p>Fork, then git clone. The project is already set up with a WebStorm project, if that&#39;s your cup of tee.</p>
231
+ <p>To run tests, with coverage:</p>
232
+ <pre><code><span class="hl-6">npm</span><span class="hl-0"> </span><span class="hl-6">run</span><span class="hl-0"> </span><span class="hl-6">test</span>
233
+ </code></pre>
234
+ <p>If you want to contribute, create a branch off master, do your work and then make a pull request against master. Unit tests would be appreciated.</p>
235
+
236
+ <a href="#license" id="license" style="color: inherit; text-decoration: none;">
237
+ <h2>License</h2>
238
+ </a>
239
+ <p><a href="./LICENSE">MIT</a></p>
240
+ </div></div>
241
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
242
+ <div class="tsd-navigation settings">
243
+ <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
244
+ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
245
+ <div class="tsd-accordion-details">
246
+ <div class="tsd-filter-visibility">
247
+ <h4 class="uppercase">Member Visibility</h4><form>
248
+ <ul id="tsd-filter-options">
249
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div>
250
+ <div class="tsd-theme-toggle">
251
+ <h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
252
+ <nav class="tsd-navigation primary">
253
+ <details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
254
+ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
255
+ <div class="tsd-accordion-details">
256
+ <ul>
257
+ <li class="current selected"><a href="modules.html">better-<wbr/>lock</a>
258
+ <ul>
259
+ <li class="tsd-kind-namespace"><a href="modules/_internal_.html">&lt;internal&gt;</a>
260
+ <ul>
261
+ <li class="tsd-kind-namespace tsd-parent-kind-namespace"><a href="modules/_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html">&quot;/home/panta/dev/pantas/better-<wbr/>lock/src/errors&quot;</a></li></ul></li></ul></li></ul></div></details></nav>
262
+ <nav class="tsd-navigation secondary menu-sticky">
263
+ <ul>
264
+ <li class="tsd-kind-reference"><a href="modules.html#default" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="#FF4D82" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12" id="icon-8388608-path"></rect><path d="M10.354 17V8.24H13.066C13.586 8.24 14.042 8.348 14.434 8.564C14.826 8.772 15.13 9.064 15.346 9.44C15.562 9.816 15.67 10.256 15.67 10.76C15.67 11.352 15.514 11.86 15.202 12.284C14.898 12.708 14.482 13 13.954 13.16L15.79 17H14.518L12.838 13.28H11.434V17H10.354ZM11.434 12.308H13.066C13.514 12.308 13.874 12.168 14.146 11.888C14.418 11.6 14.554 11.224 14.554 10.76C14.554 10.288 14.418 9.912 14.146 9.632C13.874 9.352 13.514 9.212 13.066 9.212H11.434V12.308Z" fill="var(--color-text)" id="icon-8388608-text"></path></svg>default</a></li>
265
+ <li class="tsd-kind-class"><a href="classes/BetterLockError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg>Better<wbr/>Lock<wbr/>Error</a></li>
266
+ <li class="tsd-kind-class"><a href="classes/BetterLockExecutionTimeoutError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Execution<wbr/>Timeout<wbr/>Error</a></li>
267
+ <li class="tsd-kind-class"><a href="classes/BetterLockInternalError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Internal<wbr/>Error</a></li>
268
+ <li class="tsd-kind-class"><a href="classes/BetterLockInvalidArgumentError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Invalid<wbr/>Argument<wbr/>Error</a></li>
269
+ <li class="tsd-kind-class"><a href="classes/BetterLockJobAbortedError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Job<wbr/>Aborted<wbr/>Error</a></li>
270
+ <li class="tsd-kind-class"><a href="classes/BetterLockQueueOverflowError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Queue<wbr/>Overflow<wbr/>Error</a></li>
271
+ <li class="tsd-kind-class"><a href="classes/BetterLockWaitTimeoutError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Better<wbr/>Lock<wbr/>Wait<wbr/>Timeout<wbr/>Error</a></li>
272
+ <li class="tsd-kind-interface"><a href="interfaces/BetterLockJobOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg>Better<wbr/>Lock<wbr/>Job<wbr/>Options</a></li>
273
+ <li class="tsd-kind-interface"><a href="interfaces/BetterLockOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg>Better<wbr/>Lock<wbr/>Options</a></li>
274
+ <li class="tsd-kind-type-alias"><a href="types/BetterLockErrorName.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-4194304-path"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)" id="icon-4194304-text"></path></svg>Better<wbr/>Lock<wbr/>Error<wbr/>Name</a></li>
275
+ <li class="tsd-kind-type-alias"><a href="types/BetterLockExecutor.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Better<wbr/>Lock<wbr/>Executor</a></li>
276
+ <li class="tsd-kind-type-alias"><a href="types/BetterLockKey.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Better<wbr/>Lock<wbr/>Key</a></li>
277
+ <li class="tsd-kind-type-alias"><a href="types/BetterLockQueueEjectionStrategy.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-4194304-path"></use><use href="#icon-4194304-text"></use></svg>Better<wbr/>Lock<wbr/>Queue<wbr/>Ejection<wbr/>Strategy</a></li>
278
+ <li class="tsd-kind-variable"><a href="variables/BetterLock.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-32-path"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)" id="icon-32-text"></path></svg>Better<wbr/>Lock</a></li></ul></nav></div></div>
279
+ <div class="container tsd-generator">
280
+ <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
281
+ <div class="overlay"></div><script src="assets/main.js"></script></body></html>
@@ -0,0 +1,89 @@
1
+ <!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>BetterLockJobOptions | better-lock</title><meta name="description" content="Documentation for better-lock"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
+ <div class="tsd-toolbar-contents container">
3
+ <div class="table-cell" id="tsd-search" data-base="..">
4
+ <div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
5
+ <ul class="results">
6
+ <li class="state loading">Preparing search index...</li>
7
+ <li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">better-lock</a></div>
8
+ <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
9
+ <div class="container container-main">
10
+ <div class="col-8 col-content">
11
+ <div class="tsd-page-title">
12
+ <ul class="tsd-breadcrumb">
13
+ <li><a href="../modules.html">better-lock</a></li>
14
+ <li><a href="BetterLockJobOptions.html">BetterLockJobOptions</a></li></ul>
15
+ <h1>Interface BetterLockJobOptions</h1></div>
16
+ <section class="tsd-panel tsd-comment">
17
+ <div class="tsd-comment tsd-typography"><p>Options that apply on LockJob</p>
18
+ </div></section>
19
+ <section class="tsd-panel tsd-hierarchy">
20
+ <h4>Hierarchy</h4>
21
+ <ul class="tsd-hierarchy">
22
+ <li><span class="target">BetterLockJobOptions</span>
23
+ <ul class="tsd-hierarchy">
24
+ <li><a href="BetterLockOptions.html" class="tsd-signature-type" data-tsd-kind="Interface">BetterLockOptions</a></li></ul></li></ul></section>
25
+ <section class="tsd-panel-group tsd-index-group">
26
+ <section class="tsd-panel tsd-index-panel">
27
+ <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
28
+ <h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex=0><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M1.5 5.50969L8 11.6609L14.5 5.50969L12.5466 3.66086L8 7.96494L3.45341 3.66086L1.5 5.50969Z" fill="var(--color-text)"></path></svg> Index</h5></summary>
29
+ <div class="tsd-accordion-details">
30
+ <section class="tsd-index-section">
31
+ <h3 class="tsd-index-heading">Properties</h3>
32
+ <div class="tsd-index-list"><a href="BetterLockJobOptions.html#execution_timeout" class="tsd-index-link tsd-kind-property tsd-parent-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="#FF984D" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="12" id="icon-1024-path"></rect><path d="M9.354 16V7.24H12.174C12.99 7.24 13.638 7.476 14.118 7.948C14.606 8.412 14.85 9.036 14.85 9.82C14.85 10.604 14.606 11.232 14.118 11.704C13.638 12.168 12.99 12.4 12.174 12.4H10.434V16H9.354ZM10.434 11.428H12.174C12.646 11.428 13.022 11.284 13.302 10.996C13.59 10.7 13.734 10.308 13.734 9.82C13.734 9.324 13.59 8.932 13.302 8.644C13.022 8.356 12.646 8.212 12.174 8.212H10.434V11.428Z" fill="var(--color-text)" id="icon-1024-text"></path></svg><span>execution_<wbr/>timeout</span></a>
33
+ <a href="BetterLockJobOptions.html#extend_stack_traces" class="tsd-index-link tsd-kind-property tsd-parent-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-1024-path"></use><use href="#icon-1024-text"></use></svg><span>extend_<wbr/>stack_<wbr/>traces</span></a>
34
+ <a href="BetterLockJobOptions.html#wait_timeout" class="tsd-index-link tsd-kind-property tsd-parent-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-1024-path"></use><use href="#icon-1024-text"></use></svg><span>wait_<wbr/>timeout</span></a>
35
+ </div></section></div></details></section></section>
36
+ <section class="tsd-panel-group tsd-member-group">
37
+ <h2>Properties</h2>
38
+ <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="execution_timeout" class="tsd-anchor"></a>
39
+ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagOptional">Optional</code> <span>execution_<wbr/>timeout</span><a href="#execution_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none" id="icon-anchor-a"></path><path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" id="icon-anchor-b"></path><path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" id="icon-anchor-c"></path></svg></a></h3>
40
+ <div class="tsd-signature">execution_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div>
41
+ <div class="tsd-comment tsd-typography"><p>How long can a job be executing before timing out. Null to disable timeout. Overrides BetterLockOptions value.</p>
42
+ </div><aside class="tsd-sources">
43
+ <ul>
44
+ <li>Defined in <a href="https://github.com/panta82/better-lock/blob/336aa4f/src/options.ts#L13">options.ts:13</a></li></ul></aside></section>
45
+ <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="extend_stack_traces" class="tsd-anchor"></a>
46
+ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagOptional">Optional</code> <span>extend_<wbr/>stack_<wbr/>traces</span><a href="#extend_stack_traces" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
47
+ <div class="tsd-signature">extend_<wbr/>stack_<wbr/>traces<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div>
48
+ <div class="tsd-comment tsd-typography"><p>In any error produced by BetterLock, extend the stack trace to include incoming trace. Overrides BetterLockOptions value.</p>
49
+ </div><aside class="tsd-sources">
50
+ <ul>
51
+ <li>Defined in <a href="https://github.com/panta82/better-lock/blob/336aa4f/src/options.ts#L18">options.ts:18</a></li></ul></aside></section>
52
+ <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="wait_timeout" class="tsd-anchor"></a>
53
+ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagOptional">Optional</code> <span>wait_<wbr/>timeout</span><a href="#wait_timeout" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
54
+ <div class="tsd-signature">wait_<wbr/>timeout<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div>
55
+ <div class="tsd-comment tsd-typography"><p>How long can jobs wait in queue before timing out. Overrides BetterLockOptions value.</p>
56
+ </div><aside class="tsd-sources">
57
+ <ul>
58
+ <li>Defined in <a href="https://github.com/panta82/better-lock/blob/336aa4f/src/options.ts#L8">options.ts:8</a></li></ul></aside></section></section></div>
59
+ <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
60
+ <div class="tsd-navigation settings">
61
+ <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
62
+ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
63
+ <div class="tsd-accordion-details">
64
+ <div class="tsd-filter-visibility">
65
+ <h4 class="uppercase">Member Visibility</h4><form>
66
+ <ul id="tsd-filter-options">
67
+ <li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div>
68
+ <div class="tsd-theme-toggle">
69
+ <h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
70
+ <nav class="tsd-navigation primary">
71
+ <details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
72
+ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
73
+ <div class="tsd-accordion-details">
74
+ <ul>
75
+ <li><a href="../modules.html">better-<wbr/>lock</a>
76
+ <ul>
77
+ <li class="tsd-kind-namespace"><a href="../modules/_internal_.html">&lt;internal&gt;</a>
78
+ <ul>
79
+ <li class="tsd-kind-namespace tsd-parent-kind-namespace"><a href="../modules/_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html">&quot;/home/panta/dev/pantas/better-<wbr/>lock/src/errors&quot;</a></li></ul></li></ul></li></ul></div></details></nav>
80
+ <nav class="tsd-navigation secondary menu-sticky">
81
+ <ul>
82
+ <li class="current tsd-kind-interface"><a href="BetterLockJobOptions.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg><span>Better<wbr/>Lock<wbr/>Job<wbr/>Options</span></a>
83
+ <ul>
84
+ <li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#execution_timeout" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-1024-path"></use><use href="#icon-1024-text"></use></svg>execution_<wbr/>timeout</a></li>
85
+ <li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#extend_stack_traces" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-1024-path"></use><use href="#icon-1024-text"></use></svg>extend_<wbr/>stack_<wbr/>traces</a></li>
86
+ <li class="tsd-kind-property tsd-parent-kind-interface"><a href="BetterLockJobOptions.html#wait_timeout" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-1024-path"></use><use href="#icon-1024-text"></use></svg>wait_<wbr/>timeout</a></li></ul></li></ul></nav></div></div>
87
+ <div class="container tsd-generator">
88
+ <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
89
+ <div class="overlay"></div><script src="../assets/main.js"></script></body></html>