Module: Messagebus::Validations
- Included in:
- ClusterMap, Connection
- Defined in:
- lib/messagebus/validations.rb
Overview
:nodoc:all
Instance Method Summary collapse
- #valid_host?(string) ⇒ Boolean
- #validate_connection_config(host_params, options = {}) ⇒ Object
- #validate_destination_config(name, is_consumer = false, options = {}) ⇒ Object
Instance Method Details
#valid_host?(string) ⇒ Boolean
34 35 36 |
# File 'lib/messagebus/validations.rb', line 34 def valid_host?(string) Messagebus::SERVER_REGEX.match(string) end |
#validate_connection_config(host_params, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/messagebus/validations.rb', line 46 def validate_connection_config(host_params, = {}) if [:ack_type] && [:ack_type] != Messagebus::ACK_TYPE_AUTO_CLIENT && [:ack_type] != Messagebus::ACK_TYPE_CLIENT raise InvalidAcknowledgementType.new([:ack_type]) end if host_params.nil? raise InvalidHost.new(host_params) end if host_params.is_a?(Array) host_params.each do |string| unless valid_host?(string) raise InvalidHost.new("host should be defined as <host>:<port>, received: #{host_params}") end end else raise InvalidHost.new("host should be defined as <host>:<port>, received #{host_params}") end end |
#validate_destination_config(name, is_consumer = false, options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/messagebus/validations.rb', line 38 def validate_destination_config(name, is_consumer = false, = {}) raise InvalidDestination.new("destination name is nil") unless name if is_consumer && name.match(/^jms.topic/) && [:subscription_id].nil? raise InvalidDestination.new("destination type TOPIC requires a subscription_id") end end |