Class: RServiceBus2::EndpointMapping
- Inherits:
-
Object
- Object
- RServiceBus2::EndpointMapping
- Defined in:
- lib/rservicebus2/endpointmapping.rb
Overview
Marshals data for message end points Expected format: <msg mame 1>:<end point 1>;<msg mame 2>:<end point 2>
Instance Method Summary collapse
- #configure(local_queue_name = nil) ⇒ Object
- #configure_mapping(mapping) ⇒ Object
- #get(msg_name) ⇒ Object
- #get_subscription_endpoints ⇒ Object
- #get_value(name) ⇒ Object
-
#initialize ⇒ EndpointMapping
constructor
A new instance of EndpointMapping.
- #log(string, _ver = false) ⇒ Object
Constructor Details
#initialize ⇒ EndpointMapping
Returns a new instance of EndpointMapping.
58 59 60 |
# File 'lib/rservicebus2/endpointmapping.rb', line 58 def initialize @endpoints = {} end |
Instance Method Details
#configure(local_queue_name = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rservicebus2/endpointmapping.rb', line 36 def configure(local_queue_name = nil) log('EndpointMapping.Configure') @queue_name_list = [] @queue_name_list << local_queue_name unless local_queue_name.nil? unless get_value('MESSAGE_ENDPOINT_MAPPING').nil? log('*** MESSAGE_ENDPOINT_MAPPING environment variable was detected') log("*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S' on the end") end mappings = get_value('MESSAGE_ENDPOINT_MAPPINGS') return self if mappings.nil? mappings.split(';').each do |mapping| configure_mapping(mapping) end self end |
#configure_mapping(mapping) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rservicebus2/endpointmapping.rb', line 13 def configure_mapping(mapping) match = mapping.match(/(.+):(.+)/) if match.nil? log 'Mapping string provided is invalid' log "The entire mapping string is: #{mapping}" log "*** Could not find ':' in mapping entry, #{line}" exit end RServiceBus2.rlog "EndpointMapping.configureMapping: #{match[1]}, #{match[2]}" @endpoints[match[1]] = match[2] @queue_name_list.each do |q| if q != match[2] && q.downcase == match[2].downcase log('*** Two queues specified with only case sensitive difference.') log("*** #{q} != #{match[2]}") log('*** If you meant these queues to be the same, please match case and restart the bus.') end end @queue_name_list << match[2] end |
#get(msg_name) ⇒ Object
62 63 64 65 66 |
# File 'lib/rservicebus2/endpointmapping.rb', line 62 def get(msg_name) return @endpoints[msg_name] if @endpoints.key?(msg_name) nil end |
#get_subscription_endpoints ⇒ Object
68 69 70 |
# File 'lib/rservicebus2/endpointmapping.rb', line 68 def get_subscription_endpoints @endpoints.keys.select { |el| el.end_with?('Event') } end |
#get_value(name) ⇒ Object
5 6 7 |
# File 'lib/rservicebus2/endpointmapping.rb', line 5 def get_value(name) RServiceBus2.get_value(name) end |
#log(string, _ver = false) ⇒ Object
9 10 11 |
# File 'lib/rservicebus2/endpointmapping.rb', line 9 def log(string, _ver = false) RServiceBus2.log(string) end |