Skip to content

Sync API

Chris Anderson edited this page Oct 1, 2013 · 3 revisions

#Proposal

An API like the current _replicator and _replicate solutions, but more data centric. So instead of being at the server level, there'd be a database level API like:

So if you have one for https://sync.example.com/foobar for channels myuser-inbox and broadcast, you can schedule it to be more agressive than another sync from the same remote.

We should automatically avoid push replicating twice to the same remote.

HTTP Methods

GET /mydb/_sync

Returns list of all sync sessions this database has, ordered by remote.

POST /mydb/_sync

It would be nice if this is idempotent: eg the docid is derived from the sync options somehow. I think we do that already.

Create a new sync session. Redirects to the sync session url. Here are some of the options in the JSON object:

push : true,
pull : true
channels:[...],
remote:
  URL
  Auth
  Etc
Other options
  UI triggered (refresh sync on app foreground etc)
  Schedule
  Network
  Attachments defer

Location header: /db/_sync/sync-id

GET /dbname/_sync/fd5412ae

  • Info about remote source and progress (status not stored in database, config stored in database)
  • Session info
  • Last successful request time
  • Last error request time, etc