是否可以让CouchApp自主发送请求?
我想编写非常简单的应用程序,女巫监视一些网站的状态。我还想以 Couchapp 风格制作它,而不使用除 CouchDB 之外的任何环境。
所以问题是如何让 CouchApp 自行使用某个时间表发送站点请求?
顺便说一句,如果我这个 CouchApp 失败了,有什么方法可以让它不涉及 PHP 甚至 Java 上的恶魔东西(或 cron)?我想让它尽可能简单,但又不简单。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
rsp是正确的。由于 CouchDB 使用 Web 协议和 Javascript,它已成为自身成功的受害者。
我的经验法则是:CouchDB 是一个数据库。它存储您的数据。我不期望 MySQL 自动监控外部网站。为什么我期望 CouchDB 这样做?
不过我同意; CouchDB 总是受益于一些持久处理来维护数据。
由于 CouchDB 完全基于 Web,因此您可以从一个简单的专用“工作”Web 浏览器开始。从 CouchDB 获取受密码保护的 HTML 页面。该页面包含 Javascript 来使浏览器查询服务器并更新 CouchDB。这可以作为一种快速解决方案在短期内发挥作用。然而,浏览器对您的查询施加了安全限制;而且浏览器也不是一个长期的计算平台。
传统的方式是运行自己的客户端软件来完成这些事情。您可以运行专用计算机,也可以使用 PHP、NodeJS 或任何其他托管服务。
2. 的
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
您无法单独在 CouchDB 中完成此操作(CouchApp 只能具有没有副作用的纯函数,因此可以保证它们可缓存),但您可以使用与 CouchDB 对话的简单脚本来完成此操作。有关如何操作的详细信息,请参阅Mikeal Rogers 的演讲。
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.