Interface: CustomSlotSupplier<SI>
The interface can be implemented to provide custom slot supplier behavior.
Type Parameters
SI
SI extends SlotInfo
Properties
type
type:
"custom"
Methods
markSlotUsed()
markSlotUsed(
ctx):void
This function is called once a slot is actually being used to process some task, which may be some time after the slot was reserved originally. For example, if there is no work for a worker, a number of slots equal to the number of active pollers may already be reserved, but none of them are being used yet. This call should be non-blocking.
Parameters
ctx
The context for marking a slot as used.
Returns
void
releaseSlot()
releaseSlot(
ctx):void
This function is called once a permit is no longer needed. This could be because the task has finished, whether successfully or not, or because the slot was no longer needed (ex: the number of active pollers decreased). This call should be non-blocking.
Parameters
ctx
The context for releasing a slot.
Returns
void
reserveSlot()
reserveSlot(
ctx,abortSignal):Promise<SlotPermit>
This function is called before polling for new tasks. Your implementation should return a permit when a slot is available.
Note: This function is called asynchronously from the Rust side. It should return a Promise that resolves when a slot is available. You can use async/await or return a Promise directly.
The only acceptable exception to throw is AbortError, any other exceptions thrown will be logged and ignored.
The value inside the returned promise should be an object, however other types will still count as having issued a permit. Including undefined or null. Returning undefined or null does not mean you have not issued a permit. Implementations are expected to block until a meaningful permit can be issued.
Parameters
ctx
The context for slot reservation.
abortSignal
AbortSignal
The SDK may decide to abort the reservation request if it's no longer needed. Implementations may clean up and then must reject the promise with AbortError.
Returns
Promise<SlotPermit>
A promise that resolves to a permit to use the slot which may be populated with your own data.
tryReserveSlot()
tryReserveSlot(
ctx):SlotPermit|null
This function is called when trying to reserve slots for "eager" workflow and activity tasks. Eager tasks are those which are returned as a result of completing a workflow task, rather than from polling. Your implementation must not block, and if a slot is available, return a permit to use that slot.
Parameters
ctx
The context for slot reservation.
Returns
SlotPermit | null
Maybe a permit to use the slot which may be populated with your own data.