Skip to main content
Version: v1

ContainerRuntime Class

Represents the runtime of the container. Contains helper functions/state of the container. It will define the store level mappings.

Signature​

export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents> implements IContainerRuntime, IGarbageCollectionRuntime, IRuntime, ISummarizerRuntime, ISummarizerInternalsProvider

Extends: TypedEventEmitter<IContainerRuntimeEvents

Implements: IContainerRuntime, IGarbageCollectionRuntime, IRuntime, ISummarizerRuntime, ISummarizerInternalsProvider

Static Methods​

MethodReturn TypeDescription
load(context, registryEntries, requestHandler, runtimeOptions, containerScope, existing)Promise<ContainerRuntime>Load the stores from a snapshot and returns the runtime.

Properties​

PropertyTypeDescription
attachStateAttachState
clientDetailsIClientDetails
clientIdstring | undefined
closeFn(error?: ICriticalContainerError) => void
connectedboolean
deltaManagerIDeltaManager<ISequencedDocumentMessage, IDocumentMessage>
disableIsolatedChannelsbooleanTrue if generating summaries with isolated channels is explicitly disabled. This only affects how summaries are written, and is the single source of truth for this container.
disposedboolean
enqueueSummarizeISummarizer["enqueueSummarize"]
flushModeFlushMode
IContainerRuntimethis
IFluidDataStoreRegistryIFluidDataStoreRegistry
IFluidHandleContextIFluidHandleContext
IFluidRouterthis
IFluidTokenProviderIFluidTokenProvider | undefined
isDirtybooleanReturns true of container is dirty, i.e. there are some pending local changes that either were not sent out to delta stream or were not yet acknowledged.
loggerITelemetryLogger
optionsILoaderOptions
reSubmitFn(type: ContainerMessageType, content: any, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined) => void
scopeFluidObject
storageIDocumentStorageService
summarizeOnDemandISummarizer["summarizeOnDemand"]
summarizerClientIdstring | undefinedclientId of parent (non-summarizing) container that owns summarizer container

Methods​

MethodAlertsReturn TypeDescription
_createDataStoreWithProps(pkg, props, id, isRoot)Promise<IDataStore>
addedGCOutboundReference(srcHandle, outboundHandle)voidCalled when a new outbound reference is added to another node. This is used by garbage collection to identify all references added in the system.
collectGarbage(options)Promise<IGCStats>Runs garbage collection and updates the reference / used state of the nodes in the container.
createDataStore(pkg)Promise<IDataStore>
createDetachedDataStore(pkg)IFluidDataStoreContextDetached
createDetachedRootDataStore(pkg, rootDataStoreId)IFluidDataStoreContextDetached
createRootDataStore(pkg, rootDataStoreId)DeprecatedPromise<IFluidRouter>
createSummary(blobRedirectTable, telemetryContext)ISummaryTreeCreate a summary. Used when attaching or serializing a detached container.
deleteUnusedRoutes(unusedRoutes)voidWhen running GC in test mode, this is called to delete objects whose routes are unused. This enables testing scenarios with accessing deleted content.
dispose(error)void
flush()void
getAbsoluteUrl(relativeUrl)Promise<string | undefined>
getAudience()IAudience
getCurrentReferenceTimestampMs()number | undefinedReturns a server generated referenced timestamp to be used to track unreferenced nodes by GC.
getGCData(fullGC)Promise<IGarbageCollectionData>Implementation of IGarbageCollectionRuntime::getGCData. Generates and returns the GC data for this container.
getGCNodePackagePath(nodePath)Promise<readonly string[] | undefined>Called by GC to retrieve the package path of the node with the given path. The node should belong to a data store or an attachment blob.
getNodeType(nodePath)GCNodeTypeReturns the type of the GC node. Currently, there are nodes that belong to the root ("/"), data stores or blob manager.
getPendingLocalState()IPendingRuntimeState
getQuorum()IQuorumClients
getRootDataStore(id, wait)Promise<IFluidRouter>
getSnapshotBlobs()Promise<void>
notifyAttaching(snapshot)void
orderSequentially(callback)void
process(messageArg, local)void
processSignal(message, local)void
refreshLatestSummaryAck(proposalHandle, ackHandle, summaryRefSeq, summaryLogger)Promise<void>Implementation of ISummarizerInternalsProvider.refreshLatestSummaryAck
request(request)Promise<IResponse>Notifies this object about the request made to the container.
resolveHandle(request)Promise<IResponse>Resolves URI representing handle
setAttachState(attachState)void
setConnectionState(connected, clientId)void
setFlushMode(mode)void
submitDataStoreAliasOp(contents, localOpMetadata)void
submitDataStoreOp(id, contents, localOpMetadata)void
submitDataStoreSignal(address, type, content)void
submitSignal(type, content)voidSubmits the signal to be sent to other clients.
submitSummary(options)Promise<SubmitSummaryResult>Generates the summary tree, uploads it to storage, and then submits the summarize op. This is intended to be called by the summarizer, since it is the implementation of ISummarizerInternalsProvider.submitSummary. It takes care of state management at the container level, including pausing inbound op processing, updating SummarizerNode state tracking, and garbage collection.
summarize(options)Promise<IRootSummaryTreeWithStats>Returns a summary of the runtime at the current sequence number.
updateStateBeforeGC()Promise<void>Implementation of IGarbageCollectionRuntime::updateStateBeforeGC. Before GC runs, called by the garbage collector to update any pending GC state. This is mainly used to notify the garbage collector of references detected since the last GC run. Most references are notified immediately but there can be some for which async operation is required (such as detecting new root data stores).
updateUsedRoutes(usedRoutes, gcTimestamp)voidImplementation of IGarbageCollectionRuntime::updateUsedRoutes. After GC has run, called to notify this container's nodes of routes that are used in it.
uploadBlob(blob)Promise<IFluidHandle<ArrayBufferLike>>

Property Details​

attachState​

Signature​

get attachState(): AttachState;

Type: AttachState

clientDetails​

Signature​

get clientDetails(): IClientDetails;

Type: IClientDetails

clientId​

Signature​

get clientId(): string | undefined;

Type: string | undefined

closeFn​

Signature​

get closeFn(): (error?: ICriticalContainerError) => void;

Type: (error?: ICriticalContainerError) => void

connected​

Signature​

get connected(): boolean;

Type: boolean

deltaManager​

Signature​

get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;

Type: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>

disableIsolatedChannels​

True if generating summaries with isolated channels is explicitly disabled. This only affects how summaries are written, and is the single source of truth for this container.

Signature​

readonly disableIsolatedChannels: boolean;

Type: boolean

disposed​

Signature​

get disposed(): boolean;

Type: boolean

enqueueSummarize​

Signature​

readonly enqueueSummarize: ISummarizer["enqueueSummarize"];

Type: ISummarizer["enqueueSummarize"]

flushMode​

Signature​

get flushMode(): FlushMode;

Type: FlushMode

IContainerRuntime​

Signature​

get IContainerRuntime(): this;

Type: this

IFluidDataStoreRegistry​

Signature​

get IFluidDataStoreRegistry(): IFluidDataStoreRegistry;

Type: IFluidDataStoreRegistry

IFluidHandleContext​

Signature​

get IFluidHandleContext(): IFluidHandleContext;

Type: IFluidHandleContext

IFluidRouter​

Signature​

get IFluidRouter(): this;

Type: this

IFluidTokenProvider​

Signature​

get IFluidTokenProvider(): IFluidTokenProvider | undefined;

Type: IFluidTokenProvider | undefined

isDirty​

Returns true of container is dirty, i.e. there are some pending local changes that either were not sent out to delta stream or were not yet acknowledged.

Signature​

get isDirty(): boolean;

Type: boolean

logger​

Signature​

readonly logger: ITelemetryLogger;

Type: ITelemetryLogger

options​

Signature​

get options(): ILoaderOptions;

Type: ILoaderOptions

reSubmitFn​

Signature​

get reSubmitFn(): (type: ContainerMessageType, content: any, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined) => void;

Type: (type: ContainerMessageType, content: any, localOpMetadata: unknown, opMetadata: Record<string, unknown> | undefined) => void

scope​

Signature​

get scope(): FluidObject;

Type: FluidObject

storage​

Signature​

get storage(): IDocumentStorageService;

Type: IDocumentStorageService

summarizeOnDemand​

Signature​

readonly summarizeOnDemand: ISummarizer["summarizeOnDemand"];

Type: ISummarizer["summarizeOnDemand"]

summarizerClientId​

clientId of parent (non-summarizing) container that owns summarizer container

Signature​

get summarizerClientId(): string | undefined;

Type: string | undefined

Method Details​

_createDataStoreWithProps​

Signature​

_createDataStoreWithProps(pkg: string | string[], props?: any, id?: string, isRoot?: boolean): Promise<IDataStore>;

Parameters​

ParameterModifiersTypeDescription
pkgstring | string[]
propsoptionalany
idoptionalstring
isRootoptionalboolean

Returns​

Return type: Promise<IDataStore>

addedGCOutboundReference​

Called when a new outbound reference is added to another node. This is used by garbage collection to identify all references added in the system.

Signature​

addedGCOutboundReference(srcHandle: IFluidHandle, outboundHandle: IFluidHandle): void;

Parameters​

ParameterTypeDescription
srcHandleIFluidHandleThe handle of the node that added the reference.
outboundHandleIFluidHandleThe handle of the outbound node that is referenced.

collectGarbage​

Runs garbage collection and updates the reference / used state of the nodes in the container.

Signature​

collectGarbage(options: {
logger?: ITelemetryLogger;
runSweep?: boolean;
fullGC?: boolean;
}): Promise<IGCStats>;

Parameters​

ParameterTypeDescription
options{ logger?: ITelemetryLogger; runSweep?: boolean; fullGC?: boolean; }

Returns​

the statistics of the garbage collection run.

Return type: Promise<IGCStats>

createDataStore​

Signature​

createDataStore(pkg: string | string[]): Promise<IDataStore>;

Parameters​

ParameterTypeDescription
pkgstring | string[]

Returns​

Return type: Promise<IDataStore>

createDetachedDataStore​

Signature​

createDetachedDataStore(pkg: Readonly<string[]>): IFluidDataStoreContextDetached;

Parameters​

ParameterTypeDescription
pkgReadonly<string[]>

Returns​

Return type: IFluidDataStoreContextDetached

createDetachedRootDataStore​

Signature​

createDetachedRootDataStore(pkg: Readonly<string[]>, rootDataStoreId: string): IFluidDataStoreContextDetached;

Parameters​

ParameterTypeDescription
pkgReadonly<string[]>
rootDataStoreIdstring

Returns​

Return type: IFluidDataStoreContextDetached

createRootDataStore​

This API is deprecated and will be removed in a future release.
  • will be removed in an upcoming release. See #9660.

Signature​

createRootDataStore(pkg: string | string[], rootDataStoreId: string): Promise<IFluidRouter>;

Parameters​

ParameterTypeDescription
pkgstring | string[]
rootDataStoreIdstring

Returns​

Return type: Promise<IFluidRouter>

createSummary​

Create a summary. Used when attaching or serializing a detached container.

Signature​

createSummary(blobRedirectTable?: Map<string, string>, telemetryContext?: ITelemetryContext): ISummaryTree;

Parameters​

ParameterModifiersTypeDescription
blobRedirectTableoptionalMap<string, string>A table passed during the attach process. While detached, blob upload is supported using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the new storage IDs so requests can be redirected.
telemetryContextoptionalITelemetryContextsummary data passed through the layers for telemetry purposes

Returns​

Return type: ISummaryTree

deleteUnusedRoutes​

When running GC in test mode, this is called to delete objects whose routes are unused. This enables testing scenarios with accessing deleted content.

Signature​

deleteUnusedRoutes(unusedRoutes: string[]): void;

Parameters​

ParameterTypeDescription
unusedRoutesstring[]The routes that are unused in all data stores in this Container.

dispose​

Signature​

dispose(error?: Error): void;

Parameters​

ParameterModifiersTypeDescription
erroroptionalError

flush​

Signature​

flush(): void;

getAbsoluteUrl​

Signature​

getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;

Parameters​

ParameterTypeDescription
relativeUrlstring

Returns​

Return type: Promise<string | undefined>

getAudience​

Signature​

getAudience(): IAudience;

Returns​

Return type: IAudience

getCurrentReferenceTimestampMs​

Returns a server generated referenced timestamp to be used to track unreferenced nodes by GC.

Signature​

getCurrentReferenceTimestampMs(): number | undefined;

Returns​

Return type: number | undefined

getGCData​

Implementation of IGarbageCollectionRuntime::getGCData. Generates and returns the GC data for this container.

Signature​

getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;

Parameters​

ParameterModifiersTypeDescription
fullGCoptionalbooleantrue to bypass optimizations and force full generation of GC data.

Returns​

Return type: Promise<IGarbageCollectionData>

getGCNodePackagePath​

Called by GC to retrieve the package path of the node with the given path. The node should belong to a data store or an attachment blob.

Signature​

getGCNodePackagePath(nodePath: string): Promise<readonly string[] | undefined>;

Parameters​

ParameterTypeDescription
nodePathstring

Returns​

Return type: Promise<readonly string[] | undefined>

getNodeType​

Returns the type of the GC node. Currently, there are nodes that belong to the root ("/"), data stores or blob manager.

Signature​

getNodeType(nodePath: string): GCNodeType;

Parameters​

ParameterTypeDescription
nodePathstring

Returns​

Return type: GCNodeType

getPendingLocalState​

Signature​

getPendingLocalState(): IPendingRuntimeState;

Returns​

Return type: IPendingRuntimeState

getQuorum​

Signature​

getQuorum(): IQuorumClients;

Returns​

Return type: IQuorumClients

getRootDataStore​

Signature​

getRootDataStore(id: string, wait?: boolean): Promise<IFluidRouter>;

Parameters​

ParameterModifiersTypeDescription
idstring
waitoptionalboolean

Returns​

Return type: Promise<IFluidRouter>

getSnapshotBlobs​

Signature​

getSnapshotBlobs(): Promise<void>;

Returns​

Return type: Promise<void>

load​

Load the stores from a snapshot and returns the runtime.

Signature​

static load(context: IContainerContext, registryEntries: NamedFluidDataStoreRegistryEntries, requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>, runtimeOptions?: IContainerRuntimeOptions, containerScope?: FluidObject, existing?: boolean): Promise<ContainerRuntime>;

Parameters​

ParameterModifiersTypeDescription
contextIContainerContextContext of the container.
registryEntriesNamedFluidDataStoreRegistryEntriesMapping to the stores.
requestHandleroptional(request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>Request handlers for the container runtime
runtimeOptionsoptionalIContainerRuntimeOptionsAdditional options to be passed to the runtime
containerScopeoptionalFluidObject
existingoptionalboolean(optional) When loading from an existing snapshot. Precedes context.existing if provided

Returns​

Return type: Promise<ContainerRuntime>

notifyAttaching​

Signature​

notifyAttaching(snapshot: ISnapshotTreeWithBlobContents): void;

Parameters​

ParameterTypeDescription
snapshotISnapshotTreeWithBlobContents

orderSequentially​

Signature​

orderSequentially(callback: () => void): void;

Parameters​

ParameterTypeDescription
callback() => void

process​

Signature​

process(messageArg: ISequencedDocumentMessage, local: boolean): void;

Parameters​

ParameterTypeDescription
messageArgISequencedDocumentMessage
localboolean

processSignal​

Signature​

processSignal(message: ISignalMessage, local: boolean): void;

Parameters​

ParameterTypeDescription
messageISignalMessage
localboolean

refreshLatestSummaryAck​

Implementation of ISummarizerInternalsProvider.refreshLatestSummaryAck

Signature​

refreshLatestSummaryAck(proposalHandle: string | undefined, ackHandle: string, summaryRefSeq: number, summaryLogger: ITelemetryLogger): Promise<void>;

Parameters​

ParameterTypeDescription
proposalHandlestring | undefined
ackHandlestring
summaryRefSeqnumber
summaryLoggerITelemetryLogger

Returns​

Return type: Promise<void>

request​

Notifies this object about the request made to the container.

Signature​

request(request: IRequest): Promise<IResponse>;

Parameters​

ParameterTypeDescription
requestIRequestRequest made to the handler.

Returns​

Return type: Promise<IResponse>

resolveHandle​

Resolves URI representing handle

Signature​

resolveHandle(request: IRequest): Promise<IResponse>;

Parameters​

ParameterTypeDescription
requestIRequestRequest made to the handler.

Returns​

Return type: Promise<IResponse>

setAttachState​

Signature​

setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;

Parameters​

ParameterTypeDescription
attachStateAttachState.Attaching | AttachState.Attached

setConnectionState​

Signature​

setConnectionState(connected: boolean, clientId?: string): void;

Parameters​

ParameterModifiersTypeDescription
connectedboolean
clientIdoptionalstring

setFlushMode​

Signature​

setFlushMode(mode: FlushMode): void;

Parameters​

ParameterTypeDescription
modeFlushMode

submitDataStoreAliasOp​

Signature​

submitDataStoreAliasOp(contents: any, localOpMetadata: unknown): void;

Parameters​

ParameterTypeDescription
contentsany
localOpMetadataunknown

submitDataStoreOp​

Signature​

submitDataStoreOp(id: string, contents: any, localOpMetadata?: unknown): void;

Parameters​

ParameterModifiersTypeDescription
idstring
contentsany
localOpMetadataoptionalunknown

submitDataStoreSignal​

Signature​

submitDataStoreSignal(address: string, type: string, content: any): void;

Parameters​

ParameterTypeDescription
addressstring
typestring
contentany

submitSignal​

Submits the signal to be sent to other clients.

Signature​

submitSignal(type: string, content: any): void;

Parameters​

ParameterTypeDescription
typestringType of the signal.
contentanyContent of the signal.

submitSummary​

Generates the summary tree, uploads it to storage, and then submits the summarize op. This is intended to be called by the summarizer, since it is the implementation of ISummarizerInternalsProvider.submitSummary. It takes care of state management at the container level, including pausing inbound op processing, updating SummarizerNode state tracking, and garbage collection.

Signature​

submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;

Parameters​

ParameterTypeDescription
optionsISubmitSummaryOptionsoptions controlling how the summary is generated or submitted

Returns​

Return type: Promise<SubmitSummaryResult>

summarize​

Returns a summary of the runtime at the current sequence number.

Signature​

summarize(options: {
fullTree?: boolean;
trackState?: boolean;
summaryLogger?: ITelemetryLogger;
runGC?: boolean;
fullGC?: boolean;
runSweep?: boolean;
}): Promise<IRootSummaryTreeWithStats>;

Parameters​

ParameterTypeDescription
options{ fullTree?: boolean; trackState?: boolean; summaryLogger?: ITelemetryLogger; runGC?: boolean; fullGC?: boolean; runSweep?: boolean; }

Returns​

Return type: Promise<IRootSummaryTreeWithStats>

updateStateBeforeGC​

Implementation of IGarbageCollectionRuntime::updateStateBeforeGC. Before GC runs, called by the garbage collector to update any pending GC state. This is mainly used to notify the garbage collector of references detected since the last GC run. Most references are notified immediately but there can be some for which async operation is required (such as detecting new root data stores).

Signature​

updateStateBeforeGC(): Promise<void>;

Returns​

Return type: Promise<void>

updateUsedRoutes​

Implementation of IGarbageCollectionRuntime::updateUsedRoutes. After GC has run, called to notify this container's nodes of routes that are used in it.

Signature​

updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;

Parameters​

ParameterModifiersTypeDescription
usedRoutesstring[]The routes that are used in all nodes in this Container.
gcTimestampoptionalnumberThe time when GC was run that generated these used routes. If any node node becomes unreferenced as part of this GC run, this should be used to update the time when it happens.

uploadBlob​

Signature​

uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;

Parameters​

ParameterTypeDescription
blobArrayBufferLike

Returns​

Return type: Promise<IFluidHandle<ArrayBufferLike>>