Detecting whether documents have been pushed yet

55 views
Skip to first unread message

Traun Leyden

unread,
Sep 2, 2014, 5:31:05 PM9/2/14
to mobile-c...@googlegroups.com

I was asked this question at the recent Tokyo ideathon, and wanted to see if anyone had ideas for better approaches.

Problem: how can you indicate in an app whether a document has been pushed to the sync gateway yet?

A possible solution to this is to have a field which tracks this, and something that is listening to the sync gateway changes feed would update that field.  Here's how the step-by-step would look:

1. Add a new field to the document you care about, called "pushed".  It would start out as pushed: false in the JSON.

2. Add a _changes listener that followed the sync gateway changes feed.  This would run on a backend server that has access to the Sync Gateway.  (An example changes listener for TodoLite demo app can be seen here)

3. When the _changes listener saw a document with "pushed: false", it would update the document to "pushed: true"

4. The Couchbase Lite database would pull the updated version of the document, which is now "pushed: true", and the UI of the app would indicate to the user whether or not the document has been pushed.

My main question is: is there a better way to do this?  

I was discussing w/ Zack and he had some other ideas, which hopefully he'll throw out.  If anyone has suggestions, I'd love to hear it.

PS: Once we figure out a best practice here, I think we should add this feature to TodoLite.

Jens Alfke

unread,
Sep 2, 2014, 6:09:18 PM9/2/14
to mobile-c...@googlegroups.com

On Sep 2, 2014, at 2:31 PM, Traun Leyden <tle...@couchbase.com> wrote:

A possible solution to this is to have a field which tracks this, and something that is listening to the sync gateway changes feed would update that field.

That will work, but it'll result in a lot of extra replication traffic and bigger revision trees. It doesn't seem worth it, IMHO.

We need better replication progress monitoring APIs. It's possible to tell whether a doc has been pushed by comparing the push replicator's checkpoint sequence number with the (local) sequence number of the doc's latest revision. But there's no public API exposing the replicator's checkpoint.

We could add a property to make that checkpoint accessible, but it seems kind of a weird low-level thing. I guess a higher-level API might look like -[CBLReplication hasPushedDocument: (CBLDocument*)doc].

—Jens

Traun Leyden

unread,
Sep 2, 2014, 6:25:31 PM9/2/14
to mobile-c...@googlegroups.com

Yeah, an API call like -[CBLReplication hasPushedDocument: (CBLDocument*)doc] would be perfect.  

I filed a github issue to track it: 



--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/006EC1C3-8766-498C-9CDC-E3315BF4993F%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages