require "active_job/queue_adapters/active_beaneater_adapter" require "active_beaneater/version" require "active_beaneater/queue_options" require "active_beaneater/worker" require "ostruct" require "beaneater" module URI class BEANSTALK < Generic DEFAULT_PORT = 11300 end @@schemes['BEANSTALK'] = BEANSTALK end module ActiveBeaneater def self.configure url = ENV['BEANSTALK_URL'] url ||= ['beanstalk://localhost'] uri = URI(url) config = { client: Beaneater.new("#{uri.host}:#{uri.port}"), prefix: 'active-beaneater' } config = OpenStruct.new(config) yield(config) if block_given? Rails.application.config.beaneater = config.freeze end def self.resolve_queue_name(queue) prefix = Rails.application.config.beaneater.prefix prefix = [prefix] if !prefix.respond_to?(:to_ary) (prefix + [queue]).join('.') end end