Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.51 KB

design.mkd

File metadata and controls

63 lines (45 loc) · 1.51 KB

General Idea

  • Run one FileWatcher on the client, and sync changes client to server
  • Run one FileWatcher on the server, and sync changes server to client
  • Bootstrap the process, for now with an rsync of server to client
  • When a file changes, send path+time+data to other side
  • State machine of the file on each side?

  • Server-side should own the state machine of path/mtime/hash
  • If no client-side connection, server-side can cache changes since last client connect
  • When client connects, bring up to date

Need a state machine of the connection state:

  1. Initialize
  2. Get Server State
  • If overflow goto 1
  1. Get Client State
  • If overlfow goto 1
  1. Bring into sync
  2. Watch server
  • If overflow goto 1
  1. watch client
  • If overlfow goto 1

The steady-state (post initial sync) client side would be:

  • One thread listening for file changes (or overflow)
  • One thread listening for server changes
  • Central logic that, on each incoming Update, decides what to do

Then:

  • On change from server:
    • Ensure server's mtime >= our mtime
      • If so, write file
      • If not, it's fine, we should have an incoming/outgoing Update to correct the server
  • On add/change from file system:
    • Send file + mtime to server

Threads

Both sides should have:

  • One thread for inotify (FileWatcher)
    • Writes to inbound queue
  • grpc thread(s) listening stream
    • Writes to inbound queue
  • One thread diffing trees (SyncLogic)
    • Writes to outbound queue
  • One thread putting updates on the wire