-
Notifications
You must be signed in to change notification settings - Fork 68
Persistence [v2]
The persistence of the state of the server (save/load the resource tree) is handled by each file system, and more precisely by the file system serializer (FileSystemSerializer
) of each file system.
A file system serializer will manage the serialization of a file system and its unserialization. The choice of what to serialize (what to keep) and what to not is the choice of the implementation. You might need to save the full resource tree if you implement a VirtualFileSystem
, because if you don't, you will lose it, but if you implement a FTPFileSystem
, the resource tree is already stored in the remote server, so you might want to serialize only the properties.
When serializing, the serialize
method of the serializer of the file system to serialize will be called with the subject file system as argument. The caller expect the serialized data to be returned in the callback. The caller will then link these returned data with the path of the file system (where it was mounted/mapped in the server) and the unique identifier (provided by the uid()
method) of the serializer to be able to unserialize in the future.
When unserializing, the unserialize
method of the serializer with the matching unique identifier will be called with the data provided by the previous serialization. The caller expect the rebuilt file system to be returned in the callback. The caller will then mount/map the returned file system to its previous mounted/mapped path in the server.
interface FileSystemSerializer
{
uid() : string;
serialize(fs : FileSystem, callback : ReturnCallback<any>) : void;
unserialize(serializedData : any, callback : ReturnCallback<FileSystem>) : void;
}
You can share your file system serializer through file systems, but you must make sure that the serializer fit with the file system implementation. The good practice is to have one type of serializer by type of file system (1 to 1 relationship).
The unique identifier, provided by the uid()
method, MUST be unique through all serializers and dependent of the version of the serializer.
A good practice is to use a name like that : <class_name>-<version>
The name must be modified if its new version might cause conflicts with the old implementation. For instance, fixing a bug should not modify the name, because it will not conflict with the old version, but adding a property might.
- Home
- Version 2
- Install
- Quick Start Guide
- Examples
- Concepts
- User concepts
- Server concepts
- Customizing
- Version 1 [Obsolete]
- Install
- Quick Start Guide
- Examples
- Features
- Resource concepts
- User concepts
- Server concepts
- Customizing
- Project