Code Monkey home page Code Monkey logo

Comments (4)

acurrieclark avatar acurrieclark commented on August 17, 2024

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.

pvh avatar pvh commented on August 17, 2024

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.

ept avatar ept commented on August 17, 2024

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.

pvh avatar pvh commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.