Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make CouchApp send requests autonomously?

I want to write very simple app, witch monitors states of some sites. I also want to make it in Couchapp style without using any environment except CouchDB.

So the question is how I can make CouchApp send sites requests using some schedule by itself?

BTW, if I fail with this CouchApp, is there some way to make it not involving demon stuff (or cron) on PHP or on even Java? I want to keep it as simple as possible, but not simpler.

like image 669
Dmitry Dushkin Avatar asked Feb 23 '11 20:02

Dmitry Dushkin


2 Answers

rsp is correct. Since CouchDB uses web protocols and Javascript, it has become a victim of its own success.

My rule of thumb is this: CouchDB is a database. It stores your data. I do not expect MySQL to automatically monitor external web sites. Why would I expect CouchDB to do that?

However I agree; CouchDB always benefits from some persistent processing to maintain the data.

Since CouchDB is completely web-based, you could start with a simple dedicated "worker" web browser. Fetch a password-protected HTML page from CouchDB. That page has the Javascript to make the browser query servers and update CouchDB. This could work in the short-term as a quick solution. However browsers impose security restrictions on your queries; and also a browser is not a long-term computing platform.

The traditional way is to run your own client software to do these things. You can either run a dedicated computer, or use PHP, NodeJS, or any other hosting services out there. 2. The

like image 85
JasonSmith Avatar answered Oct 30 '22 13:10

JasonSmith


You can't do it in CouchDB alone (CouchApps can only have pure functions without side effects so they can be guaranteed to be cacheable) but you can do it using simple scripts that talk to CouchDB. See this talk by Mikeal Rogers for details on how to do it.

like image 34
rsp Avatar answered Oct 30 '22 11:10

rsp