在sidekiq工作导轨中执行回叫后

时间:2019-10-01 15:46:07

标签: ruby-on-rails sidekiq rails-activejob

我创建了一个异步cron作业。为记录执行作业并获取值后,我必须发送电子邮件。在工作中是否可以像after_perform这样的回叫,可以与我一起使用来发送电子邮件?

module Reviews
  class EnqueueScheduledReviewWorker
    include Sidekiq::Worker
    sidekiq_options queue: :reviews_critical

    def perform
      ScheduledReview.reviews_pending_launch.each do |launch_id, 
       scheduled_review_id|
        scheduled_review = ScheduledReview.find_by(id: 
          scheduled_review_id)

        if scheduled_review
          Rails.logger.info "[#{self.class.name}] Enqueue scheduled 
          review id:#{scheduled_review.id}"
          scheduled_review.launch(launch_id)
        else
          Rails.logger.warn "[#{self.class.name}] Enqueued scheduled 
          review doesn't exist, id:#{scheduled_review_id}"
        end
      end
    end
  end
end

在此之后,执行了schedule_review启动作业,我需要检查是否已启动计划的审查状态,然后发送有关计划的审查的电子邮件。有办法做到吗

0 个答案:

没有答案