Sha256: bb95128650c764ccbbf799ceb6495b67e06859212530e6aa3d8ba0fa7b7e627d
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
require 'connection_pool' module SmartQue module Publishers class Base # List Queues from configuration def queue_list ::SmartQue.config.queues end # Methods related to bunny exchange, channels, queues def channel_pool @channel_pool ||= ConnectionPool.new do connection.create_channel end end def channel channel_pool.with do |channel| channel end end # Direct exchange def x_direct channel.direct("amq.direct") end def x_default channel.default_exchange end # Topic exchange def x_topic channel.topic("amq.topic") end # Fanout exchange def x_fanout channel.fanout("amq.fanout") end # Connection Object def connection ::SmartQue.establish_connection end def find_or_initialize_queue(q_name) q = get_queue(q_name) q.bind(x_direct, routing_key: q.name) end # Get/Set queue with name # name : sms_otp def get_queue(q_name, options = {}) unless options[:dot_format] == false q_name = modified_q_name(q_name) end channel.queue(q_name) end # Logging def log_message(data) ::SmartQue.log(data) end def config ::SmartQue.config end private def modified_q_name(q_name) dot_formatted(q_name) end def dot_formatted(name_string) name_string.downcase.gsub(/[\/|\_]/,".") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart-que-0.2.3 | lib/smart_que/publishers/base.rb |