繁体   English   中英

通过Sidekiq将工作结果传递给其他工作

[英]Pass job results to other job with Sidekiq

我进行API调用以获取电子邮件地址。 成功后,我想将此电子邮件地址传递给另一份工作。 我使用sidekiqsidekiq批量宝石。

class HandleWebhookJob
  def perform
    batch = Sidekiq::Batch.new
    batch.description = "Handling webhook"
    batch.on(:success, HandleWebhookJob::OtherJob, { email: @email })
    batch.jobs do
      @email = GetEmailJob.perform_async # returns email address
    end
  end

  class OtherJob
    def on_success(status, options)
      puts options # no email address here - nil
      # need to pass it to UseEmailJob.perfom_async(options[:email])
    end
  end
end

我假设将GetEmailJob的结果分配给@email无效。 找不到如何执行此操作的示例,甚至可能的话。

我认为你jid@email 您是否可以使用prefix:jid键将GetEmailJob电子邮件保存到某个存储区(例如redis),然后从那里取出它们?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM