Module: AMQ::Settings
- Defined in:
- lib/amq/settings.rb
Constant Summary collapse
- AMQPS =
"amqps".freeze
Class Method Summary collapse
-
.configure(settings = nil) ⇒ Hash
Merges given configuration parameters with defaults and returns the result.
-
.default ⇒ Object
Default connection settings used by AMQ clients.
-
.parse_amqp_url(connection_string) ⇒ Hash
Parses AMQP connection URI and returns its components as a hash.
Class Method Details
.configure(settings = nil) ⇒ Hash
Merges given configuration parameters with defaults and returns the result.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/amq/settings.rb', line 68 def self.configure(settings = nil) case settings when Hash then if username = (settings.delete(:username) || settings.delete(:user)) settings[:user] ||= username end if password = (settings.delete(:password) || settings.delete(:pass)) settings[:pass] ||= password end self.default.merge(settings) when String then settings = self.parse_amqp_url(settings) self.default.merge(settings) when NilClass then self.default end end |
.default ⇒ Object
Default connection settings used by AMQ clients
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/amq/settings.rb', line 15 def self.default @default ||= { # TCP/IP connection parameters host: "127.0.0.1", port: AMQ::Protocol::DEFAULT_PORT, auth_mechanism: [], # authentication parameters user: "guest", pass: "guest", vhost: "/", # client connection parameters frame_max: (128 * 1024), heartbeat: nil, connection_timeout: nil, channel_max: nil, # ssl parameters ssl: false, verify: false, fail_if_no_peer_cert: false, cacertfile: nil, certfile: nil, keyfile: nil } end |
.parse_amqp_url(connection_string) ⇒ Hash
Parses AMQP connection URI and returns its components as a hash.
h2. vhost naming schemes
It is convenient to be able to specify the AMQP connection parameters as a URI string, and various “amqp” URI schemes exist. Unfortunately, there is no standard for these URIs, so while the schemes share the basic idea, they differ in some details. This implementation aims to encourage URIs that work as widely as possible.
The URI scheme should be “amqp”, or “amqps” if SSL is required.
The host, port, username and password are represented in the authority component of the URI in the same way as in http URIs.
The vhost is obtained from the first segment of the path, with the leading slash removed. The path should contain only a single segment (i.e, the only slash in it should be the leading one). If the vhost is to include slashes or other reserved URI characters, these should be percent-escaped.
127 128 129 |
# File 'lib/amq/settings.rb', line 127 def self.parse_amqp_url(connection_string) AMQ::URI.parse(connection_string) end |