Skip to main content

EpochTracker Class

In ODSP, the concept of "epoch" refers to binary updates to files. For example, this might include using version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch value being incremented.

The implications of these binary updates is that the Fluid state is disrupted: the sequence number might go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's not safe to continue collaboration across an epoch change. We need to detect these epoch changes and error out from the collaboration.

This class is a wrapper around fetch calls. It adds epoch to the request made so that the server can match it with its epoch value in order to match the version. It also validates the epoch value received in response of fetch calls. If the epoch does not match, then it also clears all the cached entries for the given container.

This API is provided for existing users, but is not recommended for new users.

To use, import via @fluidframework/odsp-driver/legacy.

For more information about our API support guarantees, see here.

Signature

export declare class EpochTracker implements IPersistedFileCache

Implements: IPersistedFileCache

Constructors

ConstructorAlertsDescription
(constructor)(cache, fileEntry, logger, clientIsSummarizer)BetaConstructs a new instance of the EpochTracker class

Properties

PropertyAlertsModifiersTypeDescription
cacheBetareadonlyIPersistedCache
clientIsSummarizerBetaoptional, readonlyboolean | undefined
fileEntryBetareadonlyIFileEntry
fluidEpochBetareadonlystring | undefined
loggerBetareadonlyITelemetryLoggerExt
rateLimiterBetareadonlyRateLimiter

Methods

MethodAlertsReturn TypeDescription
fetch(url, fetchOptions, fetchType, addInBody, fetchReason)BetaPromise<IOdspResponse<Response>>Api to fetch the response for given request and parse it as json.
fetchAndParseAsJSON(url, fetchOptions, fetchType, addInBody, fetchReason)BetaPromise<IOdspResponse<T>>Api to fetch the response for given request and parse it as json.
fetchArray(url, fetchOptions, fetchType, addInBody, fetchReason)BetaPromise<IOdspResponse<ArrayBuffer>>Api to fetch the response as it is for given request.
get(entry)BetaPromise<any>
put(entry, value)BetaPromise<void>
removeEntries()BetaPromise<void>
setEpoch(epoch, fromCache, fetchType)Betavoid
validateEpoch(epoch, fetchType)BetaPromise<void>
validateEpochFromResponse(epochFromResponse, fetchType, fromCache)Betavoid

Constructor Details

(constructor)

Constructs a new instance of the EpochTracker class

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

constructor(cache: IPersistedCache, fileEntry: IFileEntry, logger: ITelemetryLoggerExt, clientIsSummarizer?: boolean | undefined);

Parameters

ParameterModifiersTypeDescription
cacheIPersistedCache
fileEntryIFileEntry
loggerITelemetryLoggerExt
clientIsSummarizeroptionalboolean | undefined

Property Details

cache

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly cache: IPersistedCache;

Type: IPersistedCache

clientIsSummarizer

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly clientIsSummarizer?: boolean | undefined;

Type: boolean | undefined

fileEntry

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly fileEntry: IFileEntry;

Type: IFileEntry

fluidEpoch

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get fluidEpoch(): string | undefined;

Type: string | undefined

logger

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected readonly logger: ITelemetryLoggerExt;

Type: ITelemetryLoggerExt

rateLimiter

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

readonly rateLimiter: RateLimiter;

Type: RateLimiter

Method Details

fetch

Api to fetch the response for given request and parse it as json.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

fetch(url: string, fetchOptions: RequestInit, fetchType: FetchType, addInBody?: boolean, fetchReason?: string): Promise<IOdspResponse<Response>>;

Parameters

ParameterModifiersTypeDescription
urlstringurl of the request
fetchOptionsRequestInitfetch options for request containing body, headers etc.
fetchTypeFetchTypemethod for which fetch is called.
addInBodyoptionalbooleanPass True if caller wants to add epoch in post body.
fetchReasonoptionalstringfetch reason to add to the request.

Returns

Return type: Promise<IOdspResponse<Response>>

fetchAndParseAsJSON

Api to fetch the response for given request and parse it as json.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

fetchAndParseAsJSON<T>(url: string, fetchOptions: RequestInit, fetchType: FetchType, addInBody?: boolean, fetchReason?: string): Promise<IOdspResponse<T>>;
Type Parameters
ParameterDescription
T

Parameters

ParameterModifiersTypeDescription
urlstringurl of the request
fetchOptionsRequestInitfetch options for request containing body, headers etc.
fetchTypeFetchTypemethod for which fetch is called.
addInBodyoptionalbooleanPass True if caller wants to add epoch in post body.
fetchReasonoptionalstringfetch reason to add to the request.

Returns

Return type: Promise<IOdspResponse<T>>

fetchArray

Api to fetch the response as it is for given request.

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

fetchArray(url: string, fetchOptions: {
[index: string]: RequestInit;
}, fetchType: FetchType, addInBody?: boolean, fetchReason?: string): Promise<IOdspResponse<ArrayBuffer>>;

Parameters

ParameterModifiersTypeDescription
urlstringurl of the request
fetchOptions{ [index: string]: RequestInit; }fetch options for request containing body, headers etc.
fetchTypeFetchTypemethod for which fetch is called.
addInBodyoptionalbooleanPass True if caller wants to add epoch in post body.
fetchReasonoptionalstringfetch reason to add to the request.

Returns

Return type: Promise<IOdspResponse<ArrayBuffer>>

get

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

get(entry: IEntry): Promise<any>;

Parameters

ParameterTypeDescription
entryIEntry

Returns

Return type: Promise<any>

put

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

put(entry: IEntry, value: any): Promise<void>;

Parameters

ParameterTypeDescription
entryIEntry
valueany

Returns

Return type: Promise<void>

removeEntries

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

removeEntries(): Promise<void>;

Returns

Return type: Promise<void>

setEpoch

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void;

Parameters

ParameterTypeDescription
epochstring
fromCacheboolean
fetchTypeFetchTypeInternal

validateEpoch

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

validateEpoch(epoch: string | undefined, fetchType: FetchType): Promise<void>;

Parameters

ParameterTypeDescription
epochstring | undefined
fetchTypeFetchType

Returns

Return type: Promise<void>

validateEpochFromResponse

This API is provided for existing users, but is not recommended for new users.

For more information about our API support guarantees, see here.

Signature

protected validateEpochFromResponse(epochFromResponse: string | undefined, fetchType: FetchTypeInternal, fromCache?: boolean): void;

Parameters

ParameterModifiersTypeDescription
epochFromResponsestring | undefined
fetchTypeFetchTypeInternal
fromCacheoptionalboolean