refactor: use PoolEvents enum
[poolifier.git] / docs / classes / WorkerChoiceStrategyContext.html
1 <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>WorkerChoiceStrategyContext | poolifier - v3.1.21</title><meta name="description" content="Documentation for poolifier"/><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 defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">poolifier - v3.1.21</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">poolifier</a></li><li><a href="WorkerChoiceStrategyContext.html">WorkerChoiceStrategyContext</a></li></ul><h1>Class WorkerChoiceStrategyContext&lt;Worker, Data, Response&gt;</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>The worker choice strategy context.</p>
2 </div><div class="tsd-comment tsd-typography"></div></section> <section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="Worker" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Worker</span><span class="tsd-signature-keyword"> extends </span><a href="../interfaces/IWorker.html" class="tsd-signature-type tsd-kind-interface">IWorker</a></span><div class="tsd-comment tsd-typography"><p>Type of worker.</p>
3 </div><div class="tsd-comment tsd-typography"></div></li><li><span><a id="Data" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Data</span> = <span class="tsd-signature-type">unknown</span></span><div class="tsd-comment tsd-typography"><p>Type of data sent to the worker. This can only be structured-cloneable data.</p>
4 </div><div class="tsd-comment tsd-typography"></div></li><li><span><a id="Response" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Response</span> = <span class="tsd-signature-type">unknown</span></span><div class="tsd-comment tsd-typography"><p>Type of execution response. This can only be structured-cloneable data.</p>
5 </div><div class="tsd-comment tsd-typography"></div></li></ul></section> <aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L27">src/pools/selection-strategies/worker-choice-strategy-context.ts:27</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><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"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="WorkerChoiceStrategyContext.html#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
6 </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="WorkerChoiceStrategyContext.html#retries" class="tsd-index-link tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>retries</span></a>
7 <a href="WorkerChoiceStrategyContext.html#retriesCount" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>retries<wbr/>Count</span></a>
8 <a href="WorkerChoiceStrategyContext.html#workerChoiceStrategies" class="tsd-index-link tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>worker<wbr/>Choice<wbr/>Strategies</span></a>
9 <a href="WorkerChoiceStrategyContext.html#workerChoiceStrategy" class="tsd-index-link tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>worker<wbr/>Choice<wbr/>Strategy</span></a>
10 </div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="WorkerChoiceStrategyContext.html#execute" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a>
11 <a href="WorkerChoiceStrategyContext.html#executeStrategy" class="tsd-index-link tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute<wbr/>Strategy</span></a>
12 <a href="WorkerChoiceStrategyContext.html#getStrategyPolicy" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Strategy<wbr/>Policy</span></a>
13 <a href="WorkerChoiceStrategyContext.html#getTaskStatisticsRequirements" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Task<wbr/>Statistics<wbr/>Requirements</span></a>
14 <a href="WorkerChoiceStrategyContext.html#remove" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove</span></a>
15 <a href="WorkerChoiceStrategyContext.html#setOptions" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>set<wbr/>Options</span></a>
16 <a href="WorkerChoiceStrategyContext.html#setWorkerChoiceStrategy" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>set<wbr/>Worker<wbr/>Choice<wbr/>Strategy</span></a>
17 <a href="WorkerChoiceStrategyContext.html#update" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>update</span></a>
18 </div></section></div></details></section></section><section class="tsd-panel-group tsd-member-group"><h2>Constructors</h2><section class="tsd-panel tsd-member"><a id="constructor" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="constructor.new_WorkerChoiceStrategyContext" class="tsd-anchor"></a><span class="tsd-kind-constructor-signature">new <wbr/>Worker<wbr/>Choice<wbr/>Strategy<wbr/>Context</span><span class="tsd-signature-symbol">&lt;</span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Worker-1">Worker</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Data-1">Data</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Response-1">Response</a><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">pool</span>, <span class="tsd-kind-parameter">workerChoiceStrategy</span><span class="tsd-signature-symbol">?</span>, <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">?</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WorkerChoiceStrategyContext.html" class="tsd-signature-type tsd-kind-class">WorkerChoiceStrategyContext</a><span class="tsd-signature-symbol">&lt;</span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Worker-1">Worker</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Data-1">Data</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Response-1">Response</a><span class="tsd-signature-symbol">&gt;</span><a href="#constructor.new_WorkerChoiceStrategyContext" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Worker choice strategy context constructor.</p>
19 </div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span><a id="constructor.new_WorkerChoiceStrategyContext.Worker-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Worker</span><span class="tsd-signature-keyword"> extends </span><a href="../interfaces/IWorker.html" class="tsd-signature-type tsd-kind-interface">IWorker</a></span></li><li><span><a id="constructor.new_WorkerChoiceStrategyContext.Data-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Data</span> = <span class="tsd-signature-type">unknown</span></span></li><li><span><a id="constructor.new_WorkerChoiceStrategyContext.Response-1" class="tsd-anchor"></a><span class="tsd-kind-type-parameter">Response</span> = <span class="tsd-signature-type">unknown</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">pool</span>: <a href="../interfaces/IPool.html" class="tsd-signature-type tsd-kind-interface">IPool</a><span class="tsd-signature-symbol">&lt;</span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Worker-1">Worker</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Data-1">Data</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Response-1">Response</a><span class="tsd-signature-symbol">&gt;</span></span><div class="tsd-comment tsd-typography"><p>The pool instance.</p>
20 </div><div class="tsd-comment tsd-typography"></div></li><li><span><span class="tsd-kind-parameter">workerChoiceStrategy</span>: <span class="tsd-signature-type">&quot;ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_USED&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_BUSY&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_ELU&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;FAIR_SHARE&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;INTERLEAVED_WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> = WorkerChoiceStrategies.ROUND_ROBIN</span></span><div class="tsd-comment tsd-typography"><p>The worker choice strategy.</p>
21 </div><div class="tsd-comment tsd-typography"></div></li><li><span><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-parameter">opts</span>: <a href="../interfaces/WorkerChoiceStrategyOptions.html" class="tsd-signature-type tsd-kind-interface">WorkerChoiceStrategyOptions</a></span><div class="tsd-comment tsd-typography"><p>The worker choice strategy options.</p>
22 </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="WorkerChoiceStrategyContext.html" class="tsd-signature-type tsd-kind-class">WorkerChoiceStrategyContext</a><span class="tsd-signature-symbol">&lt;</span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Worker-1">Worker</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Data-1">Data</a><span class="tsd-signature-symbol">, </span><a class="tsd-signature-type tsd-kind-type-parameter" href="WorkerChoiceStrategyContext.html#constructor.new_WorkerChoiceStrategyContext.Response-1">Response</a><span class="tsd-signature-symbol">&gt;</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L57">src/pools/selection-strategies/worker-choice-strategy-context.ts:57</a></li></ul></aside></li></ul></section></section><section class="tsd-panel-group tsd-member-group"><h2>Properties</h2><section class="tsd-panel tsd-member tsd-is-private"><a id="retries" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <code class="tsd-tag ts-flagReadonly">Readonly</code> <span>retries</span><a href="#retries" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">retries</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><div class="tsd-comment tsd-typography"><p>The maximum number of worker choice strategy execution retries.</p>
23 </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L48">src/pools/selection-strategies/worker-choice-strategy-context.ts:48</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="retriesCount" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>retries<wbr/>Count</span><a href="#retriesCount" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">retries<wbr/>Count</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div><div class="tsd-comment tsd-typography"><p>The number of worker choice strategy execution retries.</p>
24 </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L35">src/pools/selection-strategies/worker-choice-strategy-context.ts:35</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-private"><a id="workerChoiceStrategies" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <code class="tsd-tag ts-flagReadonly">Readonly</code> <span>worker<wbr/>Choice<wbr/>Strategies</span><a href="#workerChoiceStrategies" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">worker<wbr/>Choice<wbr/>Strategies</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">&quot;ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_USED&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_BUSY&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_ELU&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;FAIR_SHARE&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;INTERLEAVED_WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol">, </span><a href="../interfaces/IWorkerChoiceStrategy.html" class="tsd-signature-type tsd-kind-interface">IWorkerChoiceStrategy</a><span class="tsd-signature-symbol">&gt;</span></div><div class="tsd-comment tsd-typography"><p>The worker choice strategy instances registered in the context.</p>
25 </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L40">src/pools/selection-strategies/worker-choice-strategy-context.ts:40</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-private"><a id="workerChoiceStrategy" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <span>worker<wbr/>Choice<wbr/>Strategy</span><a href="#workerChoiceStrategy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">worker<wbr/>Choice<wbr/>Strategy</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">&quot;ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_USED&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_BUSY&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_ELU&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;FAIR_SHARE&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;INTERLEAVED_WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> = WorkerChoiceStrategies.ROUND_ROBIN</span></div><div class="tsd-comment tsd-typography"><p>The worker choice strategy.</p>
26 </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L59">src/pools/selection-strategies/worker-choice-strategy-context.ts:59</a></li></ul></aside></section></section><section class="tsd-panel-group tsd-member-group"><h2>Methods</h2><section class="tsd-panel tsd-member"><a id="execute" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>execute</span><a href="#execute" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="execute.execute-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">execute</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><a href="#execute.execute-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Executes the worker choice strategy in the context algorithm.</p>
27 </div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><p>The key of the worker node.</p>
28 <div class="tsd-comment tsd-typography"><h4>Throws</h4><p><a href="https://nodejs.org/api/errors.html#class-error">https://nodejs.org/api/errors.html#class-error</a> If after computed retries the worker node key is null or undefined.</p>
29 </div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L177">src/pools/selection-strategies/worker-choice-strategy-context.ts:177</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member tsd-is-private"><a id="executeStrategy" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagPrivate">Private</code> <span>execute<wbr/>Strategy</span><a href="#executeStrategy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-private"><li class="tsd-signature tsd-anchor-link"><a id="executeStrategy.executeStrategy-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">execute<wbr/>Strategy</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">workerChoiceStrategy</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><a href="#executeStrategy.executeStrategy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Executes the given worker choice strategy.</p>
30 </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">workerChoiceStrategy</span>: <a href="../interfaces/IWorkerChoiceStrategy.html" class="tsd-signature-type tsd-kind-interface">IWorkerChoiceStrategy</a></span><div class="tsd-comment tsd-typography"><p>The worker choice strategy.</p>
31 </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4><p>The key of the worker node.</p>
32 <div class="tsd-comment tsd-typography"><h4>Throws</h4><p><a href="https://nodejs.org/api/errors.html#class-error">https://nodejs.org/api/errors.html#class-error</a> If after computed retries the worker node key is null or undefined.</p>
33 </div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L191">src/pools/selection-strategies/worker-choice-strategy-context.ts:191</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="getStrategyPolicy" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>get<wbr/>Strategy<wbr/>Policy</span><a href="#getStrategyPolicy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="getStrategyPolicy.getStrategyPolicy-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">get<wbr/>Strategy<wbr/>Policy</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/StrategyPolicy.html" class="tsd-signature-type tsd-kind-interface">StrategyPolicy</a><a href="#getStrategyPolicy.getStrategyPolicy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets the strategy policy in the context.</p>
34 </div><h4 class="tsd-returns-title">Returns <a href="../interfaces/StrategyPolicy.html" class="tsd-signature-type tsd-kind-interface">StrategyPolicy</a></h4><p>The strategy policy.</p>
35 <div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L128">src/pools/selection-strategies/worker-choice-strategy-context.ts:128</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="getTaskStatisticsRequirements" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>get<wbr/>Task<wbr/>Statistics<wbr/>Requirements</span><a href="#getTaskStatisticsRequirements" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="getTaskStatisticsRequirements.getTaskStatisticsRequirements-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">get<wbr/>Task<wbr/>Statistics<wbr/>Requirements</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/TaskStatisticsRequirements.html" class="tsd-signature-type tsd-kind-interface">TaskStatisticsRequirements</a><a href="#getTaskStatisticsRequirements.getTaskStatisticsRequirements-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Gets the worker choice strategy in the context task statistics requirements.</p>
36 </div><h4 class="tsd-returns-title">Returns <a href="../interfaces/TaskStatisticsRequirements.html" class="tsd-signature-type tsd-kind-interface">TaskStatisticsRequirements</a></h4><p>The task statistics requirements.</p>
37 <div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L139">src/pools/selection-strategies/worker-choice-strategy-context.ts:139</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="remove" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>remove</span><a href="#remove" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="remove.remove-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">remove</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">workerNodeKey</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><a href="#remove.remove-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Removes the worker node key from the worker choice strategy in the context.</p>
38 </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">workerNodeKey</span>: <span class="tsd-signature-type">number</span></span><div class="tsd-comment tsd-typography"><p>The worker node key.</p>
39 </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><p><code>true</code> if the removal is successful, <code>false</code> otherwise.</p>
40 <div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L217">src/pools/selection-strategies/worker-choice-strategy-context.ts:217</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="setOptions" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>set<wbr/>Options</span><a href="#setOptions" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="setOptions.setOptions-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">set<wbr/>Options</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#setOptions.setOptions-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Sets the worker choice strategies in the context options.</p>
41 </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">opts</span>: <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><a href="../interfaces/WorkerChoiceStrategyOptions.html" class="tsd-signature-type tsd-kind-interface">WorkerChoiceStrategyOptions</a></span><div class="tsd-comment tsd-typography"><p>The worker choice strategy options.</p>
42 </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L229">src/pools/selection-strategies/worker-choice-strategy-context.ts:229</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="setWorkerChoiceStrategy" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>set<wbr/>Worker<wbr/>Choice<wbr/>Strategy</span><a href="#setWorkerChoiceStrategy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="setWorkerChoiceStrategy.setWorkerChoiceStrategy-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">set<wbr/>Worker<wbr/>Choice<wbr/>Strategy</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">workerChoiceStrategy</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#setWorkerChoiceStrategy.setWorkerChoiceStrategy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Sets the worker choice strategy to use in the context.</p>
43 </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">workerChoiceStrategy</span>: <span class="tsd-signature-type">&quot;ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_USED&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_BUSY&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;LEAST_ELU&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;FAIR_SHARE&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;WEIGHTED_ROUND_ROBIN&quot;</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">&quot;INTERLEAVED_WEIGHTED_ROUND_ROBIN&quot;</span></span><div class="tsd-comment tsd-typography"><p>The worker choice strategy to set.</p>
44 </div><div class="tsd-comment tsd-typography"></div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L150">src/pools/selection-strategies/worker-choice-strategy-context.ts:150</a></li></ul></aside></li></ul></section><section class="tsd-panel tsd-member"><a id="update" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>update</span><a href="#update" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="update.update-1" class="tsd-anchor"></a><span class="tsd-kind-call-signature">update</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">workerNodeKey</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><a href="#update.update-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Updates the worker node key in the worker choice strategy in the context internals.</p>
45 </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">workerNodeKey</span>: <span class="tsd-signature-type">number</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><p><code>true</code> if the update is successful, <code>false</code> otherwise.</p>
46 <div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/poolifier/poolifier/blob/0e86917/src/pools/selection-strategies/worker-choice-strategy-context.ts#L164">src/pools/selection-strategies/worker-choice-strategy-context.ts:164</a></li></ul></aside></li></ul></section></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><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>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><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>Private</span></label></li><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><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><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>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-index-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#constructor" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a><a href="#retries" class="tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>retries</span></a><a href="#retriesCount" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>retries<wbr/>Count</span></a><a href="#workerChoiceStrategies" class="tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>worker<wbr/>Choice<wbr/>Strategies</span></a><a href="#workerChoiceStrategy" class="tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>worker<wbr/>Choice<wbr/>Strategy</span></a><a href="#execute" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute</span></a><a href="#executeStrategy" class="tsd-is-private"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>execute<wbr/>Strategy</span></a><a href="#getStrategyPolicy" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Strategy<wbr/>Policy</span></a><a href="#getTaskStatisticsRequirements" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>get<wbr/>Task<wbr/>Statistics<wbr/>Requirements</span></a><a href="#remove" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove</span></a><a href="#setOptions" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>set<wbr/>Options</span></a><a href="#setWorkerChoiceStrategy" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>set<wbr/>Worker<wbr/>Choice<wbr/>Strategy</span></a><a href="#update" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-2048"></use></svg><span>update</span></a></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>poolifier - v3.1.21</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><div class="tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div></body></html>