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

Constructor Alerts Description
(constructor)(cache, fileEntry, logger, clientIsSummarizer) Beta Constructs a new instance of the EpochTracker class

Properties

Property Alerts Modifiers Type Description
cache Beta readonly IPersistedCache
clientIsSummarizer Beta optional, readonly boolean | undefined
fileEntry Beta readonly IFileEntry
fluidEpoch Beta readonly string | undefined
logger Beta readonly ITelemetryLoggerExt
rateLimiter Beta readonly RateLimiter

Methods

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

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

Parameter Modifiers Type Description
cache IPersistedCache
fileEntry IFileEntry
logger ITelemetryLoggerExt
clientIsSummarizer optional boolean | 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

Parameter Modifiers Type Description
url string url of the request
fetchOptions RequestInit fetch options for request containing body, headers etc.
fetchType FetchType method for which fetch is called.
addInBody optional boolean Pass True if caller wants to add epoch in post body.
fetchReason optional string fetch 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
Parameter Description
T

Parameters

Parameter Modifiers Type Description
url string url of the request
fetchOptions RequestInit fetch options for request containing body, headers etc.
fetchType FetchType method for which fetch is called.
addInBody optional boolean Pass True if caller wants to add epoch in post body.
fetchReason optional string fetch 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

Parameter Modifiers Type Description
url string url of the request
fetchOptions { [index: string]: RequestInit; } fetch options for request containing body, headers etc.
fetchType FetchType method for which fetch is called.
addInBody optional boolean Pass True if caller wants to add epoch in post body.
fetchReason optional string fetch 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

Parameter Type Description
entry IEntry

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

Parameter Type Description
entry IEntry
value any

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

Parameter Type Description
epoch string
fromCache boolean
fetchType FetchTypeInternal

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

Parameter Type Description
epoch string | undefined
fetchType FetchType

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

Parameter Modifiers Type Description
epochFromResponse string | undefined
fetchType FetchTypeInternal
fromCache optional boolean