Skip to content
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: support fetching encoded collab in batch from memory #837

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

khorshuheng
Copy link
Collaborator

Currently, there is no options for retrieving encoded collab in batch from the in-memory collab, unlike the fetch single collab counter part.

This is less of a problem for the flutter app, because we do have a websocket client which will eventually sync every collab to the latest, even if the initially fetched data might be outdated.

For AppFlowy Web, however, the changes are pull when the data is refreshed, and there is no websocket client there to keep the state of the collab to the latest. Hence, in cases where the user has a database, changes to the content of the database will not be reflected immediately on the web version of AppFlowy, because the content is fetched via the batch get encoded collab method.

Therefore, an option has been added to the batch get encoded collab method, for the storage class. The existing API will still behave as status quo, and doesn't fetch the encoded collab from in-memory. The get page view API will be affected.

tokio::task::spawn(async move {
let group = cloned_group_manager.get_group(&object_id).await;
if let Some(group) = group {
(object_id, group.encode_collab().await.ok())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be an issue when encoding a big collab. these futures might run concurrently, so i am thinking about using stream

)
.await;
let editing_query_collab_results: HashMap<String, QueryCollabResult> =
tokio::task::spawn_blocking(move || {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can try to use rayon. we already use rayon for cpu bound tasks

@khorshuheng khorshuheng force-pushed the batch-get-encoded-collab-from-memory branch from 6f02b5c to f9a2fa4 Compare September 30, 2024 07:46
@khorshuheng khorshuheng force-pushed the batch-get-encoded-collab-from-memory branch from f9a2fa4 to 6374ca4 Compare September 30, 2024 07:56
@appflowy appflowy merged commit 1173232 into main Oct 2, 2024
9 of 10 checks passed
@appflowy appflowy deleted the batch-get-encoded-collab-from-memory branch October 2, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants