我创建了一个异步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启动作业,我需要检查是否已启动计划的审查状态,然后发送有关计划的审查的电子邮件。有办法做到吗