special usage of livedb-mongo

76 views
Skip to first unread message

Antony Chaporgin

unread,
Mar 19, 2014, 7:00:15 AM3/19/14
to sha...@googlegroups.com
Hi! 
In my scenario I have an uncommon use-case of livedb-mongo. I got a web-service storing text documents with HTTP API. It acts like a master for documents, edited in ShareJS. 

When getSnapshot is called I go to mongo and look for document. If none found, I go to HTTP API and get the snapshot. Then it is stored in mongodb and subsequent getSnapshot calls do not hit API, using only mongodb.

Then after some ops have been applied to the docment inside NodeJS, writeSnapshot is called, which stores document in both MongoDB and the webservice through API.

Everything would be OK, if the document in the webservice was unmutable. But it gets modified from time to time and the sharejs clients do not know it, they do not get updates about the changed doc. For me this is unappropriate and I would like to notify sharejs clients of these modifications in form of two sharejs ops: delete current snapshot, insert new snapshot.

I want to have a special client which has access to a list of active user-sessions and to poll web-service in a timeout, asking web-service for fresh documents from opened sessions. If they differ from those stored in mongodb, I want to submit two ops mentioned before: delete and insert so that ShareJS would send them to the clients. 

What I would like to unsderstand is what is the best place to create this, because I need some intermediate level between session of ShareJS and livedb-mongo. 
Could you share some thoughts on this if you have any?

Dmitry

unread,
Mar 24, 2014, 4:39:08 AM3/24/14
to sha...@googlegroups.com
I'd better consider creating a client that polls webservice and submits any changes to livedb using provided API. Any subscribed client will get updates automatically, and also you'll have webservice -> mongo sync for free without any special logic.

Антон Чапоргин

unread,
Mar 24, 2014, 2:09:02 PM3/24/14
to sha...@googlegroups.com
That looks live a better idea, thank you! I'll certainly consider this.
 
24.03.2014, 12:39, "Dmitry" <uvar...@gmail.com>:
--
You received this message because you are subscribed to a topic in the Google Groups "ShareJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sharejs/z65xPTR8JXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sharejs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages