我试图弄清楚如何模仿 Bugzilla 健全性检查输出,其中 Bugzilla 正在检查数据库中的各种引用以查找逻辑缺陷。每次检查后,结果都会刷新到客户端。 (全套测试可能需要一段时间)。结果中,还有一个链接可以触发对出现的任何问题的“修复”。在整个(慢速)测试集完成之前获得此信息非常有用。
当标头已发送时,处理错误将是一个问题,但我的假设是,在第一次数据库检查完成后,可以安全地刷新结果。我们的想法是将此作为仅限管理员的功能,并且第一次检查完成后的任何错误都将有助于按照在任何情况下发生的顺序输出,以解决数据库的任何问题。
我如何使用 Zend MVC 来完成此任务?
I am trying to figure out how to mimic the Bugzilla sanity check output, where Bugzilla is checking various references in database to look for logic flaws. After each check, the result is flushed to the client. (The full set of tests can take a while). In the result, there is also a link which triggers 'repairs' to any issue that comes up. This is useful to get before the entire (slow) set of tests has completed.
Handling errors would be an issue, when headers are already sent, but my assumption here is that after the first database check is complete, it's safe to flush the result. The idea is to have this as an admin only feature, and any error after the first check completes would be useful to output in the order it occurs in any case, to resolve any issues with the database.
How can I accomplish this using Zend MVC?
发布评论
评论(1)
Bugzilla 使用 MIME 的非标准扩展,称为
multipart/x-mixed-replace
。并非所有客户端都支持它,尤其是 IE。并非没有忽略大多数框架的工具,不是。特别是,您需要自己推出标题和内容,避免使用自动助手。
这听起来像是 Gearman 的工作。您可以将长时间运行的进程设置为工作进程,并让它 持续发送状态信息和部分数据。然后,您可以使用状态和部分数据并提供最新进度通过简单的 ajax 轮询向用户提供,这应该适合您现有的代码。
或者您可以即发即忘并告诉客户回来稍后查看最终处理结果。
Bugzilla uses a non-standard extension to MIME, called
multipart/x-mixed-replace
. It is not supported on all clients, IE in particular.Not without ignoring most of the framework's tools, no. In particular, you'd need to push out headers and content yourself, avoiding the use of automatic helpers.
This sounds like a job for Gearman. You can set up your long-running process as a worker, and have it continually send status information and partial data. You can then consume the status and partial data and deliver the latest progress to users via simple ajax polling, something that should fit right in to your existing code.
Or you can just fire and forget and tell the client to come back later for the final processed result.