Skip to content

strategy

Predicate<T> = (canisterId, requestId, status) => Promise<T>

Defined in: packages/core/src/agent/polling/types.ts:12

T

Principal

RequestId

RequestStatusResponseStatus

Promise<T>

backoff(startingThrottleInMsec, backoffFactor): PollStrategy

Defined in: packages/core/src/agent/polling/strategy.ts:113

A strategy that throttle, but using an exponential backoff strategy.

number

The throttle in milliseconds to start with.

number

The factor to multiple the throttle time between every poll. For example if using 2, the throttle will double between every run.

PollStrategy


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.

PollStrategy[]

A strategy list to chain.

PollStrategy


conditionalDelay(condition, timeInMsec): PollStrategy

Defined in: packages/core/src/agent/polling/strategy.ts:41

Delay the polling once.

Predicate<boolean>

A predicate that indicates when to delay.

number

The amount of time to delay.

PollStrategy


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.

PollStrategy


maxAttempts(count): PollStrategy

Defined in: packages/core/src/agent/polling/strategy.ts:57

Error out after a maximum number of polling has been done.

number

The maximum attempts to poll.

PollStrategy


once(): Predicate<boolean>

Defined in: packages/core/src/agent/polling/strategy.ts:25

Predicate that returns true once.

Predicate<boolean>


throttle(throttleInMsec): PollStrategy

Defined in: packages/core/src/agent/polling/strategy.ts:80

Throttle polling.

number

Amount in millisecond to wait between each polling.

PollStrategy


timeout(timeInMsec): PollStrategy

Defined in: packages/core/src/agent/polling/strategy.ts:88

Reject a call after a certain amount of time.

number

Time in milliseconds before the polling should be rejected.

PollStrategy

Re-exports PollStrategy