Created
October 19, 2015 07:23
-
-
Save shio-phys/961af7a766bc9d245cd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Crawler | |
class DomainSpecificWorker | |
include Sidekiq::Worker | |
def self.domainify(domain_id) | |
klass_name = "#{self.name.split('::').last}_#{domain_id}" | |
unless Crawler.const_defined?(klass_name) | |
Crawler.const_set(klass_name.to_sym, self.clone) | |
klass = Crawler.const_get(klass_name.to_sym) | |
queue = klass.class_variable_get(:@@queue).to_s + "-#{domain_id}" | |
klass.sidekiq_options(queue: queue.to_sym) | |
klass.class_variable_set(:@@queue, queue) | |
end | |
Crawler.const_get(klass_name.to_sym) | |
end | |
end | |
class HogeWorker < DomainSpecificWorker | |
@@queue = :hoge | |
def perform(pamram) | |
# do something | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment