Help designing user management

66 views
Skip to first unread message

Rajagopal V

unread,
Apr 22, 2014, 10:57:55 AM4/22/14
to mobile-c...@googlegroups.com
Hi
We are designing a system where mobile users connect to a sync gateway and create various objects. I have a listener that listens to the continuous feed from gateway and makes webservice calls to a PHP server to create those objects. So far it seems to work very well. 

The problem that I have right now is that if any of the webservice calls fail, I would need to inform just that mobile client who created it (Since its not a valid object in the system). I tried to look at parameterized filters, which could allow this as I can pass in a parameter from iOS/Android and return TRUE or FALSE from the filter, but that wont work with Sync Gateway. Im unable to find out how to create an equivalent system using channels. The one way I can think of is to create users for each of my mobile clients(during registration or something similar) and have each of them subscribe to a unique channel (probably keyed off their username) in addition to a global channel where they all receive valid updates.

When the webservice call fails, I would update back to the Sync gateway indicating that its an error and the sync function can then channel it to the user who created it. Is this the only way to do it?  Since we have 3000 mobile users and are expecting a surge in the upcoming release (that uses SG + couchbase mobile), would it be okay to  create a channel for each user? Are there any performance implications I should be worried about. 

Thanks
Raja

Jens Alfke

unread,
Apr 22, 2014, 1:32:52 PM4/22/14
to mobile-c...@googlegroups.com
On Apr 22, 2014, at 7:57 AM, Rajagopal V <raja...@gmail.com> wrote:

The problem that I have right now is that if any of the webservice calls fail, I would need to inform just that mobile client who created it (Since its not a valid object in the system). I tried to look at parameterized filters, which could allow this as I can pass in a parameter from iOS/Android and return TRUE or FALSE from the filter

I don’t understand how you’d use filters for that. Can you explain what you’d do?

My immediate idea would be to just have the server code update the document, perhaps adding an “error” property describing the problem. But that assumes the clients are pulling changes from the gateway; is that happening in your system?

Since we have 3000 mobile users and are expecting a surge in the upcoming release (that uses SG + couchbase mobile), would it be okay to  create a channel for each user? Are there any performance implications I should be worried about. 

Yes, that works. The overhead per channel is pretty low.

—Jens

Rajagopal V

unread,
Apr 22, 2014, 1:41:35 PM4/22/14
to mobile-c...@googlegroups.com
Thanks for the response. 


On Tuesday, April 22, 2014 11:02:52 PM UTC+5:30, Jens Alfke wrote:

On Apr 22, 2014, at 7:57 AM, Rajagopal V <raja...@gmail.com> wrote:

The problem that I have right now is that if any of the webservice calls fail, I would need to inform just that mobile client who created it (Since its not a valid object in the system). I tried to look at parameterized filters, which could allow this as I can pass in a parameter from iOS/Android and return TRUE or FALSE from the filter

I don’t understand how you’d use filters for that. Can you explain what you’d do?


I was assuming a filter that would work like:
{
    "_id": "_design/owndocs",
    "filters": {
        "owndocs": "function(doc,req) { return (req.query.owner == doc.createdById); }"
    }
}

and I could pass in the "owner" parameter to the filter. The "createdById" is populated from the mobile when the object gets created and with this condition, you would only be able to pull the documents that a user created.
 
My immediate idea would be to just have the server code update the document, perhaps adding an “error” property describing the problem. But that assumes the clients are pulling changes from the gateway; is that happening in your system?

Yes, that is correct. All mobile clients are pulling in from the gateway and this is what will happen even if there is an "error". I was planning on changing the type of the document to "error" and PUT-ting it back to the gateway, but that would mean that all the clients will fetch it.

 

Since we have 3000 mobile users and are expecting a surge in the upcoming release (that uses SG + couchbase mobile), would it be okay to  create a channel for each user? Are there any performance implications I should be worried about. 

Yes, that works. The overhead per channel is pretty low.

I will try based on this approach.

Thanks
Raja

Jens Alfke

unread,
Apr 22, 2014, 2:06:21 PM4/22/14
to mobile-c...@googlegroups.com

On Apr 22, 2014, at 10:41 AM, Rajagopal V <raja...@gmail.com> wrote:

> I was assuming a filter that would work like:

Right, that would be the CouchDB approach. It’s more expensive than channels because that JavaScript function has to run once per document per user.

> Yes, that is correct. All mobile clients are pulling in from the gateway and this is what will happen even if there is an "error". I was planning on changing the type of the document to "error" and PUT-ting it back to the gateway, but that would mean that all the clients will fetch it.

If there aren’t too many errors, that might work OK. It’s a simpler system because you don’t need individual user channels, just one ‘errors’ channel.
Otherwise, assign the document to a channel based on its createdById property, and have each client pull only from the channel corresponding to its ID.

—Jens
Reply all
Reply to author
Forward
0 new messages