Get the total number of changes from sync gateway ahead of time?

Is there any way to get the total number of changes directly from the sync gateway ahead of time without forcing the client to count the number of lines returned from POST /{db}/_changes ?

I want to provide a progress indicator for my users so they can see how the replication is progressing. Couchbase Lite gives a ‘changes count’ and ‘completed changes count’, so you can sort of do this, but ‘changes count’ seems to reflect the number of changes processed so far, and not the total number of changes.

From my observation of Couchbase Lite .NET, it streams the change feed and processes it in chunks of 200. Since it doesn’t load the whole response from POST /{db}/_changes into memory all at the same time, you don’t know the total number of changes ahead of time. The result is that ‘changes count’ is always ahead of ‘completed changes’ by about 200. You can make a progress indicator out of this, but it will go from 50% to 99% logarithmically. So users will see that the replication is 90% done after 10 seconds, but they still have several minutes left to go - not a good user experience to say the least.

I don’t seem to see any place in the Sync Gateway REST API that just lets you get the number of pending changes? Is there a reason for this, or an oversight, or am I missing something?

1 Like

Sadly no, I’ve asked this question before internally but Sync Gateway both generates and sends the changes feed at the same time so even Sync Gateway itself doesn’t know how many are in there until it is finished. @adamf will have the final word on confirming that though.