@@ -5,6 +5,32 @@ module RabbitMQ
55 class Client
66 DEFAULT_PROTOCOL_TIMEOUT = 30 # seconds
77
8+ # Create a new {Client} instance with the given properties.
9+ # There are several ways to convey connection info:
10+ #
11+ # @example with a URL string
12+ # RabbitMQ::Client.new("amqp://user:password@host:1234/vhost")
13+ #
14+ # @example with explicit options
15+ # RabbitMQ::Client.new(user: "user", password: "password", port: 1234)
16+ #
17+ # @example with both URL string and explicit options
18+ # RabbitMQ::Client.new("amqp://host:1234", user: "user", password: "password")
19+ #
20+ # Parsed options from a URL will be applied first, then any options given
21+ # explicitly will override those parsed. If any options are ambiguous, they
22+ # will have the default values:
23+ # {
24+ # user: "guest",
25+ # password: "guest",
26+ # host: "localhost",
27+ # vhost: "/",
28+ # port: 5672,
29+ # ssl: false,
30+ # max_channels: RabbitMQ::FFI::CHANNEL_MAX_ID, # absolute maximum
31+ # max_frame_size: 131072,
32+ # }
33+ #
834 def initialize ( *args )
935 @conn = Connection . new ( *args )
1036
@@ -16,18 +42,24 @@ def initialize(*args)
1642 @protocol_timeout = DEFAULT_PROTOCOL_TIMEOUT
1743 end
1844
45+ # Initiate the connection with the server. It is necessary to call this
46+ # before any other communication, including creating a {#channel}.
1947 def start
2048 close # Close if already open
2149 @conn . start
2250 self
2351 end
2452
53+ # Gracefully close the connection with the server. This will
54+ # be done automatically on garbage collection if not called explicitly.
2555 def close
2656 @conn . close
2757 release_all_channels
2858 self
2959 end
3060
61+ # Free the native resources associated with this object. This will
62+ # be done automatically on garbage collection if not called explicitly.
3163 def destroy
3264 @conn . destroy
3365 self
0 commit comments