Skip to main content
Version: v1

ReplayController Class

Replay controller object It controls where we start (snapshot, local file, no snapshots) As well as dispatch of ops

Signature​

export declare abstract class ReplayController extends ReadDocumentStorageServiceBase

Extends: ReadDocumentStorageServiceBase

Methods​

MethodReturn TypeDescription
fetchTo(currentOp)number | undefinedReturns last op number to fetch from current op Note: this API is called while replay() is in progress - next batch of ops is downloaded in parallel
getStartingOpSequence()Promise<number>Returns sequence number to start processing ops Should be zero if not using snapshot, and snapshot seq# otherwise
initStorage(documentService)Promise<boolean>Initialize reply controller
isDoneFetch(currentOp, lastTimeStamp)booleanReturns true if no more ops should be processed (or downloaded for future processing). It's called at end of each batch with latest op timestamp. Also it's called when there are no more ops available (lastTimeStamp === undefined). If false is returned and there are no more ops, request for more ops is made every 2 seconds. Note: this API is called while replay() is in progress - next batch of ops is downloaded in parallel
replay(emitter, fetchedOps)Promise<void>Replay batch of ops NOTE: new batch of ops is fetched (fetchTo() & isDoneFetch() APIs are called) while this call is in flights

Method Details​

fetchTo​

Returns last op number to fetch from current op Note: this API is called while replay() is in progress - next batch of ops is downloaded in parallel

Signature​

abstract fetchTo(currentOp: number): number | undefined;

Parameters​

ParameterTypeDescription
currentOpnumbercurrent op

Returns​

Return type: number | undefined

getStartingOpSequence​

Returns sequence number to start processing ops Should be zero if not using snapshot, and snapshot seq# otherwise

Signature​

abstract getStartingOpSequence(): Promise<number>;

Returns​

Return type: Promise<number>

initStorage​

Initialize reply controller

Signature​

abstract initStorage(documentService: IDocumentService): Promise<boolean>;

Parameters​

ParameterTypeDescription
documentServiceIDocumentServicethe real document service

Returns​

  • Boolean, indicating if controller should be used. If false is returned, caller should fallback to original storage.

Return type: Promise<boolean>

isDoneFetch​

Returns true if no more ops should be processed (or downloaded for future processing). It's called at end of each batch with latest op timestamp. Also it's called when there are no more ops available (lastTimeStamp === undefined). If false is returned and there are no more ops, request for more ops is made every 2 seconds. Note: this API is called while replay() is in progress - next batch of ops is downloaded in parallel

Signature​

abstract isDoneFetch(currentOp: number, lastTimeStamp?: number): boolean;

Parameters​

ParameterModifiersTypeDescription
currentOpnumbercurrent op
lastTimeStampoptionalnumbertimestamp of last op (if more ops are available). Undefined otherwise.

Returns​

Return type: boolean

replay​

Replay batch of ops NOTE: new batch of ops is fetched (fetchTo() & isDoneFetch() APIs are called) while this call is in flights

Signature​

abstract replay(emitter: (op: api.ISequencedDocumentMessage[]) => void, fetchedOps: api.ISequencedDocumentMessage[]): Promise<void>;

Parameters​

ParameterTypeDescription
emitter(op: api.ISequencedDocumentMessage[]) => voidcallback to emit ops
fetchedOpsapi.ISequencedDocumentMessage[]ops to process

Returns​

Return type: Promise<void>