Skip to main content

EphemeralService Interface

An in-memory Fluid service that can produce connected EphemeralServiceClients.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/local-driver/alpha.

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

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
export interface EphemeralService extends ErasedBaseType<readonly ["EphemeralService"]>

Extends: ErasedBaseType<readonly ["EphemeralService"]>

Remarks

All documents created through clients connected to a given EphemeralService are held in-memory by that service. Closing the service (via close() or cleanupEphemeralService(service)) closes the connections to any remaining open containers, and cleans up the service's timers.

Create one with startEphemeralService(isDefault).

Most ServiceClient implementations would take in a URL and credentials to connect to a service, but that is not needed for the ephemeral in-memory service. Instead this object representing the actual service instance is provided.

Properties

PropertyAlertsModifiersTypeDescription
defaultClientAlphareadonlyEphemeralServiceClientA client connected to this service using the default options.

Methods

MethodAlertsReturn TypeDescription
close()AlphaPromise<void>Close this service, which closes all containers connected to it and releases its resources.
newClient(options)AlphaEphemeralServiceClientCreates and returns a EphemeralServiceClient for an in-memory, ephemeral Fluid service.
synchronize(timeoutMilliseconds)AlphaPromise<void>Drives all containers connected to this service toward convergence, processing pending operations and waiting for all dirty containers to save.

Property Details

defaultClient

A client connected to this service using the default options.

This API is provided as an alpha preview and may change without notice.

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

Signature

readonly defaultClient: EphemeralServiceClient;

Type: EphemeralServiceClient

Method Details

close

Close this service, which closes all containers connected to it and releases its resources.

This API is provided as an alpha preview and may change without notice.

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

Signature

close(): Promise<void>;

Remarks

All documents held by this service are discarded, and any timers it (or its containers) were keeping alive are cleaned up. The returned promise resolves once all asynchronous cleanup (including shutting down the in-memory server) has completed. Closing is idempotent: calling it again after the service is closed resolves without doing anything.

Returns

Return type: Promise<void>

newClient

Creates and returns a EphemeralServiceClient for an in-memory, ephemeral Fluid service.

This API is provided as an alpha preview and may change without notice.

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

Signature

newClient(options: ServiceOptions): EphemeralServiceClient;

Remarks

The service is ephemeral and in-memory: all documents are held by the EphemeralService the client is connected to, and live for as long as that service is open — independent of whether any container for them is open. A document created and attached (obtaining an id) can be loaded by id for as long as its service remains open, even after every container for it has been closed. Closing the service (via close() or cleanupEphemeralService(service)) discards all of its documents and releases its resources; afterwards those ids can no longer be loaded.

When no service is provided, a new one is allocated for this client (accessible via service). Provide the same EphemeralService to multiple clients (via options.service) to have them collaborate on the same documents, and control that service's lifetime explicitly.

Since a service holds timers while open, tests should close the services they use (e.g. via cleanupEphemeralService(service) in an afterEach) to avoid lingering timers that can hang test runners.

Parameters

ParameterTypeDescription
optionsServiceOptionsOptions for the client. oldestSupportedClient may be omitted because all clients are in the same process, so it defaults to the current version. service may be omitted to allocate a new EphemeralService dedicated to this client, or provided to connect the client to an existing service instance.

Returns

Return type: EphemeralServiceClient

synchronize

Drives all containers connected to this service toward convergence, processing pending operations and waiting for all dirty containers to save.

This API is provided as an alpha preview and may change without notice.

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

Signature

synchronize(timeoutMilliseconds?: number): Promise<void>;

Parameters

ParameterModifiersTypeDescription
timeoutMillisecondsoptionalnumberThe maximum time to wait for containers to quiesce, in milliseconds. Defaults to 30_000.

Returns

Return type: Promise<void>