- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Rails(4.1.0) 和 Sidekiq(3.2.1) 以及 acts_as_tenantInstalling (0.3.5)
这是我的 worker 。
class NotificationWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform(current_account_id, notification_method_name, resource_id)
current_account = Account.find(current_account_id)
# Prcocess only if current account is not nil
if current_account.present?
ActsAsTenant.with_tenant(current_account) do
# Current tenant is set for all code in this block
notification_service = NotificationService.new
notification_service.method(notification_method_name).call(resource_id)
end
end
end
end
我调用 perform_async 形式的 assignments_controller。
def create
@assignment = Assignment.new(assignment_params)
respond_to do |format|
if @assignment.save
current_account_id = current_tenant.id
resource_id = @assignment.id
NotificationWorker.perform_async(current_account_id, "assignment_notification", resource_id)
format.html { redirect_to @assignment, notice: 'Assignment was successfully created.' }
format.json { render :show, status: :created, location: @assignment }
else
format.html { render :new }
format.json { render json: @assignment.errors, status: :unprocessable_entity }
end
end
end
我从 Controller 中有 sidekiq 调用的行中得到“错误数量的参数(4 个参数为 3 个)”。我已经阅读了文档以及其他问题,但无法弄清楚我做错了什么。请帮忙。谢谢。
更新:
出现错误是因为在 acts_as_tenant gem 中需要 sidekiq 支持。
ActsAsTenant.configure do |config|
#ActsAsTenant supports Sidekiq. A background processing library.
require 'acts_as_tenant/sidekiq'
# When set to true will raise an ActsAsTenant::NoTenant error, whenever
# a query is made without a tenant set.
config.require_tenant = false # true
end
最佳答案
试试这个:
notification_method_name = "assignment_notification"
NotificationWorker.perform_async(current_account_id, notification_method_name, resource_id)
或者您可以尝试使用符号,例如 here .
关于ruby-on-rails - Sidekiq:perform_async 中的参数数量错误(4 对 3)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25328588/
我正在使用 Sidekiq 创建 Elasticsearch 回调。我启动了 Redis 和 Sidekiq,并在 Rails 控制台中创建了一个对象,但似乎 perform_sync 没有触发。如果
我正在尝试使用 sidekiq 在后台处理一些请求(它与 padrino 框架集成)。 我的期望是,一旦调用了 worker,请求处理程序会立即将答案返回给用户。 为了确保它正常工作,我实现了一个 w
我想用新的时间间隔更新旧的 sidekiq 作业。我该怎么做?是否可以通过 perform_in 选项。此外,我想知道 perform_in 和 perform_async 之间的明显区别。 最佳答案
我正在努力将广泛的后台任务外推给 sidekiq 工作人员(第一次使用 sidekiq)。 我已经能够让它正常运行。 但我不确定如何检查 sidekiq worker 的进度 - 检查 worker
我正在使用 Rails(4.1.0) 和 Sidekiq(3.2.1) 以及 acts_as_tenantInstalling (0.3.5) 这是我的 worker 。 class Notifica
我是一名优秀的程序员,十分优秀!