strategy
Type Aliases
Section titled “Type Aliases”Predicate
Section titled “Predicate”Predicate<
T> = (canisterId,requestId,status) =>Promise<T>
Defined in: packages/core/src/agent/polling/types.ts:12
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”canisterId
Section titled “canisterId”requestId
Section titled “requestId”status
Section titled “status”Returns
Section titled “Returns”Promise<T>
Functions
Section titled “Functions”backoff()
Section titled “backoff()”backoff(
startingThrottleInMsec,backoffFactor):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:113
A strategy that throttle, but using an exponential backoff strategy.
Parameters
Section titled “Parameters”startingThrottleInMsec
Section titled “startingThrottleInMsec”number
The throttle in milliseconds to start with.
backoffFactor
Section titled “backoffFactor”number
The factor to multiple the throttle time between every poll. For example if using 2, the throttle will double between every run.
Returns
Section titled “Returns”chain()
Section titled “chain()”chain(…
strategies):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:130
Chain multiple polling strategy. This chains the strategies, so if you pass in, say, two throttling strategy of 1 second, it will result in a throttle of 2 seconds.
Parameters
Section titled “Parameters”strategies
Section titled “strategies”…PollStrategy[]
A strategy list to chain.
Returns
Section titled “Returns”conditionalDelay()
Section titled “conditionalDelay()”conditionalDelay(
condition,timeInMsec):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:41
Delay the polling once.
Parameters
Section titled “Parameters”condition
Section titled “condition”Predicate<boolean>
A predicate that indicates when to delay.
timeInMsec
Section titled “timeInMsec”number
The amount of time to delay.
Returns
Section titled “Returns”defaultStrategy()
Section titled “defaultStrategy()”defaultStrategy():
PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:18
A best practices polling strategy: wait 2 seconds before the first poll, then 1 second with an exponential backoff factor of 1.2. Timeout after 5 minutes.
Note that calling this function will create the strategy chain described above and already start the 5 minutes timeout. You should only call this function when you want to start the polling, and not before, to avoid exhausting the 5 minutes timeout in advance.
Returns
Section titled “Returns”maxAttempts()
Section titled “maxAttempts()”maxAttempts(
count):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:57
Error out after a maximum number of polling has been done.
Parameters
Section titled “Parameters”number
The maximum attempts to poll.
Returns
Section titled “Returns”once()
Section titled “once()”once():
Predicate<boolean>
Defined in: packages/core/src/agent/polling/strategy.ts:25
Predicate that returns true once.
Returns
Section titled “Returns”Predicate<boolean>
throttle()
Section titled “throttle()”throttle(
throttleInMsec):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:80
Throttle polling.
Parameters
Section titled “Parameters”throttleInMsec
Section titled “throttleInMsec”number
Amount in millisecond to wait between each polling.
Returns
Section titled “Returns”timeout()
Section titled “timeout()”timeout(
timeInMsec):PollStrategy
Defined in: packages/core/src/agent/polling/strategy.ts:88
Reject a call after a certain amount of time.
Parameters
Section titled “Parameters”timeInMsec
Section titled “timeInMsec”number
Time in milliseconds before the polling should be rejected.
Returns
Section titled “Returns”References
Section titled “References”PollStrategy
Section titled “PollStrategy”Re-exports PollStrategy