Microsoft is readying version 2.0 of their Fluid Framework for real-time collaboration. The available alpha and internal releases add a new object-oriented shared data structure and browser-based developer tooling.
Fluid Framework is a set of client libraries and underlying server technologies that enable the building of real-time collaboration applications. In these applications, clients share the same data structures kept in sync by the framework. It intends to simplify merging concurrent changes in multiple clients while leveraging existing web technology.
The main concepts of the Fluid Framework are the shared data structures (called DDS for distributed data structures) and the Fluid service that runs on the server. The Fluid service can run locally on a development machine or a server and is responsible for communicating with the connected Fluid clients. Conveniently, Microsoft Azure offers a hosted Azure Fluid Relay service for production loads.
In its first version, Fluid Framework offered simple data structures such as strings, hash maps and counters. Version 2.0 adds a fully encapsulated data structure called SharedTree, a hierarchical tree-like collection of nodes containing objects. Each object can contain properties of different types, including other objects. The SharedTree DDS has a root note that is used as an entry point for Fluid Framework data synchronisation. It also has atomic node tree manipulation methods for inserting, removing and moving nodes in the SharedTree.
The syntax of defining the SharedTree uses the Builder pattern, which leads to a simple but verbose code, for example:
const builder = new SchemaBuilder('95ac89d1-d485-4210-b6f2-3a23bfd6366f');
export const float64 = builder.primitive('number', ValueSchema.Number);
export const string = builder.primitive('string', ValueSchema.String);
export const userSchema = builder.object('demo:user', {
local: {
name: SchemaBuilder.field(FieldKinds.value, string),
id: SchemaBuilder.field(FieldKinds.value, string),
},
});
export const noteSchema = builder.object('demo:note', {
local: {
id: SchemaBuilder.field(FieldKinds.value, string),
text: SchemaBuilder.field(FieldKinds.value, string),
author: SchemaBuilder.field(FieldKinds.value, userSchema),
votes: SchemaBuilder.field(FieldKinds.sequence, userSchema),
created: SchemaBuilder.field(FieldKinds.value, float64),
lastChanged: SchemaBuilder.field(FieldKinds.value, float64)
},
});
export const appSchema = builder.object('demo:app', {
local: {
notes: SchemaBuilder.field(FieldKinds.sequence, noteSchema),
},
});
export const rootField = SchemaBuilder.field(FieldKinds.value, appSchema);
export const schema = builder.intoDocumentSchema(rootField);
According to Microsoft,
(the) development (of SharedTree) is driven by significant feedback from developers looking for Fluid data structures that map more closely to document object models, inheritance trees, and other common use cases for hierarchical data.
The other feature in version 2.0 of the Fluid Framework is the launch of Fluid Developer Tools, a browser extension for Edge and Chrome that helps develop and debug Fluid Framework applications. It allows the developers to see the state and the data shared in the Fluid Framework applications. Developers can change the connection state and the shared data to test different scenarios, such as offline or reconnection attempts. Finally, it includes event logs and telemetry graphs of the performance logs.
The developer response to Fluid Framework has been lukewarm, with some developers struggling to see the benefits of using it over established technologies like SignalR (so much that the Fluid Framework FAQ has a section on that). The company has been using Fluid Framework internally for the Microsoft Loop app in the Microsoft 365 offering.
Fluid Framework was first launched in November 2019 as a preview technology announced at Microsoft’s Build conference. It was open-sourced in September 2020. The expected timeline for the 2.0 general availability release is still unknown. The GitHub repo has frequent internal builds of the new version released since June, the most current one being the v2.0.0-internal.6.1.1.