UseRunPool
katanakit-js / useRunPool
Function: useRunPool()
Section titled “Function: useRunPool()”function useRunPool<TInput, TOutput>(key, data): Promise<TOutput>;Defined in: infrastructure/worker/worker.service.ts:185
Runs a task on an existing Worker pool. Tasks are correlated by __taskId
so concurrent tasks do not stomp each other’s handlers.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
TInput |
Input data type. |
TOutput |
Output data type. |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key |
string |
The pool key created via useCreatePool. |
data |
TInput |
The input data to pass to the pool’s function. |
Returns
Section titled “Returns”Promise<TOutput>
A Promise resolving to the function’s output.
Throws
Section titled “Throws”If the pool does not exist.
Example
Section titled “Example”useCreatePool("math", (n: number) => n * 10);const result = await useRunPool("math", 5); // 50