Skip to Content
Packages@tuwaio/pulsar-coreType AliasesPollingTrackerConfig<R, T>

PollingTrackerConfig<R, T>

PollingTrackerConfig<R, T> = object

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:55 

The configuration of initializePollingTracker.

Type Parameters

R

R

The response type the fetcher reports.

T

T extends Pick<Transaction, "txKey" | "pending">

The tracked transaction type; only txKey and pending are required.

Properties

fetcher

fetcher: (params) => Promise<void>

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:63 

Checks the transaction once per tick and reports through the callbacks it receives. It must call stopPolling on a terminal result. A thrown error counts as a failed attempt.

Parameters

params

PollingFetcherParams<R, T>

The transaction, stopPolling and the callbacks.

Returns

Promise<void>


isAbandoned?

optional isAbandoned?: () => boolean

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:110 

Asked before every check. true stops polling without any callback: nothing reads the result any more, for example as the transaction was removed from the pool.

Returns

boolean

Whether to stop.


maxRetries?

optional maxRetries?: number

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:98 

The number of consecutive failed attempts (thrown errors) after which polling stops. Defaults to 10.


onFailure

onFailure: (response?) => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:74 

Called by the fetcher when the transaction failed, and without arguments by the tracker after maxRetries consecutive failed attempts.

Parameters

response?

R

The result reported by the fetcher, if any.

Returns

void


onInitialize?

optional onInitialize?: () => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:76 

Called once, synchronously, when polling starts.

Returns

void


onIntervalTick?

optional onIntervalTick?: (response) => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:81 

Called by the fetcher with intermediate results.

Parameters

response

R

The intermediate result.

Returns

void


onReplaced?

optional onReplaced?: (response) => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:86 

Called by the fetcher when the transaction was replaced.

Parameters

response

R

The result describing the replacement.

Returns

void


onSuccess

onSuccess: (response) => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:68 

Called by the fetcher when the transaction succeeded.

Parameters

response

R

The result reported by the fetcher.

Returns

void


pollingInterval?

optional pollingInterval?: number | ((elapsedMs) => number)

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:96 

The delay before each attempt, in milliseconds, or a function that returns it from the milliseconds elapsed since polling started, to poll less often over time. Defaults to 5000.


removeTxFromPool?

optional removeTxFromPool?: (txKey) => void

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:91 

Called when polling stops, unless it was stopped with withoutRemoving: true.

Parameters

txKey

string

The txKey of the tracked transaction.

Returns

void


retryForeverEveryMs?

optional retryForeverEveryMs?: number

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:104 

With a delay here, maxRetries consecutive failed attempts no longer end tracking: the tracker keeps asking at this delay, in milliseconds, until an attempt succeeds. Not being able to ask says nothing about the transaction, so use it where a person would otherwise be told that a transaction failed because a service was down.


tx

tx: T

Defined in: packages/pulsar-core/src/utils/initializePollingTracker.ts:57 

The transaction to track. Polling starts only if pending is true.

Last updated on