gpt4 book ai didi

javascript - Sidekiq perform_later 不适用于 Action 电缆

转载 作者:行者123 更新时间:2023-12-03 12:29:15 26 4
gpt4 key购买 nike

我在我的应用程序中设置了一个基本的行动电缆供电聊天。我有一个 after_create_commit 回调,它将消息发送到要广播到适当 channel 的作业。当它设置为 perform_now 时它工作正常,但当它设置为 perform_later 时它不起作用。 Sidekiq 执行任务并广播到正确的 channel ,但 channel 订阅没有收到任何内容。

这是正在设置的 channel :

PodsChannel is transmitting the subscription confirmation
PodsChannel is streaming from pods_channel_310
PodsChannel#speak({"message"=>"word", "pod_slug"=>"310", "user_id"=>"1", "msg_type"=>"pod_message"})

这是传入并发送到 sidekiq 的消息:
[ActiveJob] Enqueued MessageBroadcastJob (Job ID: c9cc59ce-2202-400d-92fb-15b80a9ece67) to Sidekiq(development_default) with arguments: #<GlobalID:0x007fa2e63526a0 @uri=#<URI::GID gid://sutra/PodMessage/1390>>

这是 sidekiq 处理作业并广播到正确的 channel :
[ActiveJob] [MessageBroadcastJob] [546222f6-9a57-493d-a3bb-b4886e0ad708]   Rendered pod_messages/_pod_message.html.erb (61.0ms)
[ActiveJob] [MessageBroadcastJob] [546222f6-9a57-493d-a3bb-b4886e0ad708] [ActionCable] Broadcasting to pods_channel_310: {:message=>"<div class='msg-wrap' id='msg_1389'><div class='msg-avatar'><a href=\"http://example.org/lorenzsell\"><img class=\"avatar-img\" alt=\"Lorenz\" src=\"/uploads/user/avatar/1/thumb_Lorenz2-square.jpg\" /></a></div><div class='msg-details'><div class='msg-meta'><div class='msg-sender'>Lorenz</div><div class='msg-timestamp'>Friday, August 12 at 12:09 AM</div><div class='msg-delete'><a data-remote=\"true\" rel=\"nofollow\" data-method=\"delete\" href=\"/delete_pod_message/1389\"><span class='glyphicon glyphicon-remove-circle' aria-hidden='true'></span></a></div></div><div class='msg-text'>word</div></div></div>\n"}
[ActiveJob] [MessageBroadcastJob] [546222f6-9a57-493d-a3bb-b4886e0ad708] Performed MessageBroadcastJob from Sidekiq(development_default) in 143.57ms

但是 channel 实际上并没有得到任何数据。正如我所说,当它设置为 perform_now 但在 perform_later 上失败时,它可以正常工作。有任何想法吗?

最佳答案

我刚遇到同样的问题。貌似是默认cable.yml造成的文件设置如下:

development:
adapter: async

test:
adapter: async

production:
adapter: redis
url: redis://localhost:6379/1

但看起来异步适配器不能用于从单独的进程进行广播。要启用此功能,您可以修改您的 cable.yml文件为:
default: &default
adapter: redis
url: redis://localhost:6379/1

development:
<<: *default

test:
<<: *default

production:
<<: *default

这也将允许您从控制台进行广播。

关于javascript - Sidekiq perform_later 不适用于 Action 电缆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38908012/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com