Gearman:将数据从后台工作人员发送到客户端
是否可以从后台运行的 gearman 工作人员(使用 PHP)发回数据?
我知道我可以将状态(分子/分母)传递给客户端,但我需要“返回”数据。
背景是我需要调用不同服务器上的工作人员,如果他们没有响应,则主脚本应该继续。所以我想我必须在后台运行工人。但我需要他们提供一些数据。
更新: 似乎不可能。我想我必须将数据存储在共享数据库中,或者将其从远程服务器写入本地服务器,或者从远程服务器读取数据,或者进行如下操作:
shell_exec('gearman -f getdata-192-168-200-1 > /my/path/ 2>&1 & echo $!');
Is it possible to send back data from a gearman worker that runs in the background (with PHP)?
I know that I can pass a status (numerator/denominator) to the client but I need to "return" data.
The background is that I need to call workers on different servers and if they don't respond, the main script should continue. So I think I have to run the workers in the background. But I need some data from them.
UPDATE:
It seems not to be possible. I think I have either to store the data in a shared database or to write it from the remote server to the local server or to read it from the remote server or to make something like this:
shell_exec('gearman -f getdata-192-168-200-1 > /my/path/ 2>&1 & echo $!');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以使用以下函数将数据从工作人员传递到客户端
通过在 $result 变量中提供数据,您也可以使用该函数在客户端中处理这些数据
您可以获得更多信息
http://www.php.net/manual/en/gearmanclient.setdatacallback.php
I think you can pass the data from the worker to client using the following function
By giving your data in $result variable and also you can handle this data in the client by using the function
You can get bit more information
http://www.php.net/manual/en/gearmanclient.setdatacallback.php