Skip to main content
Version: v1

IContainer Interface

The Host's view of the Container and its connection to storage

Signature

export interface IContainer extends IEventProvider<IContainerEvents>, IFluidRouter

Extends: IEventProvider<IContainerEvents>, IFluidRouter

Properties

Property Type Description
attachState AttachState Indicates the attachment state of the container to a host service.
audience IAudience The audience information for all clients currently associated with the document in the current session
closed boolean Returns true if the container has been closed, otherwise false
connectionState ConnectionState Provides the current state of the container's connection to the ordering service
deltaManager IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> The Delta Manager supporting the op stream for this Container
isDirty boolean Returns true if the container is dirty, i.e. there are user changes that has not been saved Closing container in this state results in data loss for user. Container usually gets into this situation due to loss of connectivity.
readOnlyInfo ReadOnlyInfo

Tells if container is in read-only mode. Data stores should listen for "readonly" notifications and disallow user making changes to data stores. Readonly state can be because of no storage write permission, or due to host forcing readonly mode for container.

We do not differentiate here between no write access to storage vs. host disallowing changes to container - in all cases container runtime and data stores should respect readonly state and not allow local changes.

It is undefined if we have not yet established websocket connection and do not know if user has write access to a file.

resolvedUrl IResolvedUrl | undefined Represents the resolved url to the Container Will be undefined only when the container is in the detatched state.

Methods

Method Return Type Description
attach(request) Promise<void>

Attaches the Container to the Container specified by the given Request.

TODO - in the case of failure options should give a retry policy. Or some continuation function that allows attachment to a secondary document.

close(error) void Closes the container
closeAndGetPendingLocalState() string Closes the container and returns serialized local state intended to be given to a newly loaded container
connect() void Attempts to connect the container to the delta stream and process ops
disconnect() void Disconnects the container from the delta stream and stops processing ops
getAbsoluteUrl(relativeUrl) Promise<string | undefined> Get an absolute url for a provided container-relative request url. If the container is not attached, this will return undefined.
getLoadedCodeDetails() IFluidCodeDetails | undefined Get the code details that were used to load the container.
getQuorum() IQuorumClients The collection of write clients which were connected as of the current sequence number. Also contains a map of key-value pairs that must be agreed upon by all clients before being accepted.
getSpecifiedCodeDetails() IFluidCodeDetails | undefined Get the code details that are currently specified for the container.
proposeCodeDetails(codeDetails) Promise<boolean> Propose new code details that define the code to be loaded for this container's runtime. The returned promise will be true when the proposal is accepted, and false if the proposal is rejected.
request(request) Promise<IResponse> Issue a request against the container for a resource.
serialize() string Extract the snapshot from the detached container.

Property Details

attachState

Indicates the attachment state of the container to a host service.

Signature
readonly attachState: AttachState;

Type: AttachState

audience

The audience information for all clients currently associated with the document in the current session

Signature
readonly audience: IAudience;

Type: IAudience

closed

Returns true if the container has been closed, otherwise false

Signature
readonly closed: boolean;

Type: boolean

connectionState

Provides the current state of the container's connection to the ordering service

Signature
readonly connectionState: ConnectionState;

Type: ConnectionState

deltaManager

The Delta Manager supporting the op stream for this Container

Signature
deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;

Type: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>

isDirty

Returns true if the container is dirty, i.e. there are user changes that has not been saved Closing container in this state results in data loss for user. Container usually gets into this situation due to loss of connectivity.

Signature
readonly isDirty: boolean;

Type: boolean

readOnlyInfo

Tells if container is in read-only mode. Data stores should listen for "readonly" notifications and disallow user making changes to data stores. Readonly state can be because of no storage write permission, or due to host forcing readonly mode for container.

We do not differentiate here between no write access to storage vs. host disallowing changes to container - in all cases container runtime and data stores should respect readonly state and not allow local changes.

It is undefined if we have not yet established websocket connection and do not know if user has write access to a file.

Signature
readonly readOnlyInfo: ReadOnlyInfo;

Type: ReadOnlyInfo

resolvedUrl

Represents the resolved url to the Container Will be undefined only when the container is in the detatched state.

Signature
resolvedUrl: IResolvedUrl | undefined;

Type: IResolvedUrl | undefined

Method Details

attach

Attaches the Container to the Container specified by the given Request.

TODO - in the case of failure options should give a retry policy. Or some continuation function that allows attachment to a secondary document.

Signature
attach(request: IRequest): Promise<void>;

Parameters

Parameter Type Description
request IRequest

Returns

Return type: Promise<void>

close

Closes the container

Signature
close(error?: ICriticalContainerError): void;

Parameters

Parameter Modifiers Type Description
error optional ICriticalContainerError

closeAndGetPendingLocalState

Closes the container and returns serialized local state intended to be given to a newly loaded container

Signature
closeAndGetPendingLocalState(): string;

Returns

Return type: string

connect

Attempts to connect the container to the delta stream and process ops

Signature
connect(): void;

disconnect

Disconnects the container from the delta stream and stops processing ops

Signature
disconnect(): void;

getAbsoluteUrl

Get an absolute url for a provided container-relative request url. If the container is not attached, this will return undefined.

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

Parameters

Parameter Type Description
relativeUrl string A container-relative request URL

Returns

Return type: Promise<string | undefined>

getLoadedCodeDetails

Get the code details that were used to load the container.

Signature
getLoadedCodeDetails(): IFluidCodeDetails | undefined;

Returns

The code details that were used to load the container if it is loaded, undefined if it is not yet loaded.

Return type: IFluidCodeDetails | undefined

getQuorum

The collection of write clients which were connected as of the current sequence number. Also contains a map of key-value pairs that must be agreed upon by all clients before being accepted.

Signature
getQuorum(): IQuorumClients;

Returns

Return type: IQuorumClients

getSpecifiedCodeDetails

Get the code details that are currently specified for the container.

Signature
getSpecifiedCodeDetails(): IFluidCodeDetails | undefined;

Returns

The current code details if any are specified, undefined if none are specified.

Return type: IFluidCodeDetails | undefined

proposeCodeDetails

Propose new code details that define the code to be loaded for this container's runtime. The returned promise will be true when the proposal is accepted, and false if the proposal is rejected.

Signature
proposeCodeDetails(codeDetails: IFluidCodeDetails): Promise<boolean>;

Parameters

Parameter Type Description
codeDetails IFluidCodeDetails

Returns

Return type: Promise<boolean>

request

Issue a request against the container for a resource.

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

Parameters

Parameter Type Description
request IRequest The request to be issued against the container

Returns

Return type: Promise<IResponse>

serialize

Extract the snapshot from the detached container.

Signature
serialize(): string;

Returns

Return type: string