Comments (4)
Some initial thoughts on how this might work:
- ID is set within repo, and stored under a common ID in whichever storage adapter is attached
- Each time the Repo is initialised, it checks storage for an existing ID and creates a new one if absent
- Can be overridden by passing in a
DeviceId
/RepoId
to the Repo constructor; useful if you have a local Repo instance which is not connected to storage, for example.
from automerge-repo.
This seems very sensible; we can also keep track of sync states with the tuple repoId/docId/syncState.
Note that some peers may not be persistent. Browser tabs have their own local sync state but don't store anything in localstorage. We should be careful not to clutter up storage with the state of ephemeral peers.
from automerge-repo.
Perhaps relatedly, @orionz in automerge/automerge#617 added a kind of "branch ID" concept, which is an actorId extended with an integer to allow several branches to exist side-by-side. Seems like having multiple peers for a single device is a similar idea?
from automerge-repo.
Interesting! I think we can't do quite the same thing without some kind of leader mechanism (and solving the attendant problems that follow)... My gut reaction is that a "peer" in our current terminology should converge to become a "repo", which is to say a stored (or ephemeral) instance of some documents. Peers should include a hint about whether they plan to return during handshaking.
This is a bit of a puzzle... in the case of blutack, where we have messages run from tab -> shared_worker -> sync_server -> shared_worker -> tab, I suppose the "sync state" from an application perspective is whether the shared_worker is in sync with the server, and the "peer state" is the sync state from the other party's shared_worker. Tabs should panic any time they fall out of sync with the shared_worker and otherwise be treated as disposable.
In this case, I believe only the shared_worker's repo, stored in localStorage is really important.
from automerge-repo.
Related Issues (20)
- Add docs and example for adding authentication to the sync server
- 1.0 Release Blog Post
- Automerge-Repo in a SharedWorker under Vite loses "connect". HOT 1
- Ephemeral message scope HOT 1
- Websocket Version bugs
- Leave means leave HOT 2
- New document sync and save HOT 8
- Delete protocol HOT 1
- Unable to use automerge-repo in Deno: Property 'on' missing from 'Repo'
- Handle unavailable files with no storage/peers better HOT 7
- How should the "unavailable" status interact with network adapter startup? HOT 3
- Storage Snapshots HOT 1
- Storage Snapshots HOT 1
- Lose extra diff HOT 10
- apps under /examples don't seem to work HOT 4
- can't load automerge repo HOT 4
- Allow Svelte's `document` store to explicitely receive the `repo` HOT 4
- Sync server scalability for live collaboration HOT 7
- On failure, and what to do about it HOT 2
- Cover reconnection bug with a test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from automerge-repo.