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

add remote resource support #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

add remote resource support #2

wants to merge 3 commits into from

Conversation

hahn-kev
Copy link
Collaborator

the purpose of this is to investiage how to connect CRDTs and binary files (called resources here) which can't easily be stored as a CRDT directly.

Basically there's RemoteResources, these a tracked in CRDTs and can be referenced by other objects. They contain a reference to a resource on a remote server (auth left up to the app). Then there's a LocalResource, this represents a resource stored locally. There are 3 states a resource can be in.

  • local only
  • remote only
  • remote and local

if the file is local only then the RemoteResource.RemoteId will be null, indicating it has not yet been uploaded.
if DataModel.GetLocalResource returns null that means the resource has not yet been downloaded.

There are 2 apis to help the application list resources that are pending upload or pending download.

There is also an API to help upload resources before a sync.

Base automatically changed from add-crdt to main June 5, 2024 13:35
@hahn-kev hahn-kev force-pushed the remote-resources branch 2 times, most recently from 5f64c2a to 8f29622 Compare June 5, 2024 15:38
await DataModel.AddLocalResource(localFile, _localClientId, resourceService: _remoteServiceMock);


var resource = await DataModel.GetLatest<RemoteResource>(resourceId);

Choose a reason for hiding this comment

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

Shouldn't the //act go here?

Copy link
Collaborator Author

@hahn-kev hahn-kev Jun 13, 2024

Choose a reason for hiding this comment

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

No this is the assert. It's just fetching what we put in the database on the add local call. Maybe that add method should be renamed, that name doesn't make sense to me anymore.

Copy link

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

Do we need to add anything more to the sample model to demonstrate expected use? Maybe in a follow up?

@hahn-kev
Copy link
Collaborator Author

Yeah that's a good idea. Maybe I'll just make an attached file to the Word entity.

…evant. Update db model snapshot test

add remote resources support.
add method to upload all pending local resources, and call from SyncWithResourceUpload helper method
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