New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sync): add blob engine #6937
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Your org has enabled the Graphite merge queue for merging into masterAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account in order to use the merge queue. Sign up using this link. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this close #6294? I haven't found implementation for uploading image blobs to remote server endpoints yet.
Would also be better to add migration guide, aka the comparison between the new API surface and the implementation based on the legacy BlobStorage
. This is needed for bumping downstream (e.g. https://github.com/toeverything/blocksuite/blob/master/examples/react-sqlite/src/editor/provider/provider.ts#L17)
This depends on the storage service used; perhaps we can write an example based on R2 or S3.
I will update the migration document, and after merging, I will migrate the old implementation in the example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please wait for other reviewers.
The blob engine completes a part that has been missing in the sync package, from now on all data synchronization of the blocksuite editor (including yjs data and blob data) can be achieved through the sync package.
Breaking changes
Removed the old blob addon (other addons will also be gradually removed and refactored in the future)
Usage of new API
Similar to other engines in the sync package (doc engine and awareness engine), blob engine requires implementing a blob source interface to control the source of blob data. There are two types of data sources: main and shadow, usually one main and multiple shadows, where main is mandatory and shadow is optional. The blob engine will automatically synchronize multiple blob sources, prioritizing data retrieval from the main source.
For example, we implement a blob source based on IndexedDB and use it when initializing DocCollection.
Another common use case is storing editor's blob data on a remote server. For this purpose, we only need to implement a corresponding blob source. For instance, for testing purposes, we have implemented a mock server blob source.
The sync package has pre-implemented two commonly used blob sources (IndexedDBBlobSource and MemoryBlobSource), which can be used directly.
Close #6294
Close #6752
Close BS-283
Migration Guide
Delete Method
The blob engine does not yet support the deletion of specific blobs, as we currently cannot determine which blobs can be safely deleted, because we cannot confirm whether a blob is used by a doc. For this, we need to wait for the implementation of the indexer.