传递 return 来指定 GearmanWorker 上回调函数的结果

发布于 2024-11-18 17:47:25 字数 93 浏览 4 评论 0原文

我试图传递一些数据或操作结果的标识符,例如“true”或“false”。目前我只能根据完成和失败的回调来考虑任务的返回代码。 您能否提供一些有关如何将数据传递给结果的想法。

I am trying to pass some data or an identifier of the result of the operation like 'true' or 'false'. For now I can only think of the return code of the task based on the callback for complete and failed.
Can you give some ideas on how to pass data to the result.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗藏城府 2024-11-25 17:47:25

我已经弄清楚了这一点。我所做的是在客户端上包含一个 setCompleteCallback 并在工作线程上包含一个 sendComplete 。通过 sendComplete 发送的序列化数据可以由使用 setComplete 注册的回调接收。

At worker:
$client->setCompleteCallback('onComplete');
function onComplete($job){
...
}
At client:
$worker->sendComplete('This is the data!');

I have figured out this one. What I did is that I include a setCompleteCallback on the client and a sendComplete on the the worker. A serialized data sent through sendComplete can be received by the registered callback using setComplete.

At worker:
$client->setCompleteCallback('onComplete');
function onComplete($job){
...
}
At client:
$worker->sendComplete('This is the data!');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文