allow specifying the sidekiq queue
This commit is contained in:
parent
426a68f567
commit
4035b22bf6
|
@ -1,5 +1,6 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Queries::User < Query
|
class Queries::User < Query
|
||||||
|
set_queue(:user_sync, :user_sync)
|
||||||
params :id, :login, :email, :github_id, :is_syncing
|
params :id, :login, :email, :github_id, :is_syncing
|
||||||
|
|
||||||
def find
|
def find
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Query
|
class Query
|
||||||
@@sidekiq_cache = Tool::ThreadLocal.new
|
@@sidekiq_queue = {}
|
||||||
|
|
||||||
|
def self.sidekiq_queue(identifier)
|
||||||
|
@@sidekiq_queue[identifier] ||= [
|
||||||
|
"Travis::Sidekiq::#{identifier.to_s.camelcase}".freeze,
|
||||||
|
identifier.to_s.pluralize.freeze
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.set_queue(identifier, queue)
|
||||||
|
sidekiq_queue(identifier)[1] = queue
|
||||||
|
end
|
||||||
|
|
||||||
# generate from eval to avoid additional string allocations on every params access
|
# generate from eval to avoid additional string allocations on every params access
|
||||||
@@params_accessor = <<-RUBY
|
@@params_accessor = <<-RUBY
|
||||||
|
@ -90,11 +101,7 @@ module Travis::API::V3
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_async(identifier, *args)
|
def perform_async(identifier, *args)
|
||||||
class_name, queue = @@sidekiq_cache[identifier] ||= [
|
class_name, queue = Query.sidekiq_queue(identifier)
|
||||||
"Travis::Sidekiq::#{identifier.to_s.camelcase}".freeze,
|
|
||||||
identifier.to_s.pluralize.freeze
|
|
||||||
]
|
|
||||||
|
|
||||||
::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => args)
|
::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user