在我的 php 应用程序中使用 gearman 的正确方法

发布于 2024-09-04 06:30:31 字数 273 浏览 7 评论 0原文

现在我只想使用 Gearman 进行后台处理。例如,一旦发件人将消息提交到数据库中,我需要向收件人发送电子邮件,告知他们有一条私人消息正在等待他们。我假设我可以在主服务器上运行工作程序/客户端和服务器,但将某些任务卸载到不同的 Web 服务器上没有问题。

无论如何,我的问题是如何处理多个“功能”?假设我需要一份处理电子邮件部分的工作和一份处理图像操作的工作。我可以在worker中拥有多种功能吗?我遵循了在网上找到的几个示例,但每个示例仅显示一个正在初始化的函数。我是否必须启动多个“worker”来处理多个功能?

For now I just want to use Gearman for background processing. For example, I need to email a recipient that they have a private message waiting for them once the sender submits their message into the DB. I assume I can run the worker/client and server on my primary server but I have no problems offloading some of the tasks to a different web server.

Anyways, my question is how do I handle multiple "functions?" Let's say I need a job that handles the email portion and a job to handle image manipulation. Can I have multiple functions in the worker? I've followed a couple of examples I found online but each example only shows one function being initialized. Do I have to start up multiple "workers" to handle multiple functions?

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

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

发布评论

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

评论(1

佼人 2024-09-11 06:30:31

我可以在工作人员中拥有多个功能吗?我遵循了在网上找到的几个示例,但每个示例仅显示一个正在初始化的函数。

当您向 Gearman 服务器注册时,您可以告诉它您可以处理的所有事情。查看 GearmanWorker 类和 addFunction 方法。 (这盲目地假设您正在使用特定的 Gearman 扩展。还有其他扩展。)

Can I have multiple functions in the worker? I've followed a couple of examples I found online but each example only shows one function being initialized.

When you register with the Gearman server, you tell it all the things you can handle. Check out the GearmanWorker class and the addFunction method. (This blindly assumes you're using that particular Gearman extension. There are others.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文