Replication Progress

102 views
Skip to first unread message

Martin Haynes

unread,
Jun 17, 2015, 9:41:47 AM6/17/15
to pou...@googlegroups.com
Hi,

I was wondering if there was anyway of getting progress on the replication. 

I have looked at a number of posts / forums but ether no one knows how to do it , or they simply don't want to do it. 

What I am after is someone to tell how much data is been replicated and where we are in the process. This is because I am trying to build an app with Offline support and I want to inform the user how long they can expect to wait till all the data has sync'd from the server to there local device. 

I was wondering if anyone has a solution to getting the progress of a sync operation

Cheers

Martin 

step...@shimaore.net

unread,
Jun 17, 2015, 12:27:16 PM6/17/15
to pou...@googlegroups.com
Hi Martin,

> What I am after is someone to tell how much data is been replicated and
> where we are in the process.

In CouchDB, the replicator status(*) provides:
- source_seq
- checkpointed_source_seq

The checkpointed_source_seq is originally at some value, typically
the value of the last replication's checkpointed_source_seq, which is
(in CouchDB) stored in a local variable inside the source database.
That value is updated as the documents are successfully replicated into
the target database. (The source_seq is also updated if new documents
are inserted in the source, at least for continuous replications.)

This gives you the total number of documents to transfer, that is
source_seq - original-checkpointed_source_seq
and the number of documents left to be transferred, i.e.
source_seq - checkpointed_source_seq

Divide the later by the former and you get a neat `progress` value.

Reading the docs [1] I suspect that you can get the equivalent of
`checkpointed_source_seq` in the `last_seq` value of the parameter of
the `change` event associated with a replication. (This would have to be
confirmed.) You might have to manually retrieve the `source_seq` from
the source.
S.

(*) e.g. http://127.0.0.1:5984/_active_tasks
[1] http://pouchdb.com/api.html#replication , under "Example Response"

--
tel:+33643482771
http://stephane.shimaore.net/
Reply all
Reply to author
Forward
0 new messages