Class: Qpid::Proton::Connection
- Includes:
- Util::SwigHelper, Util::Wrapper
- Defined in:
- lib/core/connection.rb
Overview
A Connection option has at most one Qpid::Proton::Transport instance.
Constant Summary collapse
- PROTON_METHOD_PREFIX =
"pn_connection"
Constants inherited from Endpoint
Endpoint::LOCAL_ACTIVE, Endpoint::LOCAL_CLOSED, Endpoint::LOCAL_MASK, Endpoint::LOCAL_UNINIT, Endpoint::REMOTE_ACTIVE, Endpoint::REMOTE_CLOSED, Endpoint::REMOTE_MASK, Endpoint::REMOTE_UNINIT
Instance Attribute Summary collapse
-
#hostname ⇒ String
The AMQP hostname for the connection.
-
#overrides ⇒ Object
Returns the value of attribute overrides.
-
#session_policy ⇒ Object
Returns the value of attribute session_policy.
Class Method Summary collapse
Instance Method Summary collapse
- #_local_condition ⇒ Object
- #_remote_condition ⇒ Object
-
#close ⇒ Object
Closes the connection.
-
#collect(collector) ⇒ Object
Associates the connection with an event collector.
-
#connection ⇒ Connection
This method is used when working within the context of an event.
- #container ⇒ Object
- #container=(name) ⇒ Object
-
#error ⇒ Fixnum
Returns the code for a connection error.
-
#initialize(impl = Cproton.pn_connection) ⇒ Connection
constructor
Constructs a new instance of Connection.
-
#link_head(mask) ⇒ Link
Returns the first link that matches the given state mask.
-
#open ⇒ Object
Opens the connection.
- #overrides? ⇒ Boolean
-
#remote_container ⇒ String
Get the AMQP container name advertised by the remote connection endpoint.
-
#remote_desired_capabilities ⇒ Data
Get the AMQP desired capabilities supplied by the remote connection endpoint.
-
#remote_hostname ⇒ String
Get the AMQP hostname set by the remote connection endpoint.
-
#remote_offered_capabilities ⇒ Data
Get the AMQP offered capabilities suppolied by the remote connection endpoint.
-
#remote_properties ⇒ Data
Get the AMQP connection properties supplie by the remote connection endpoint.
-
#session ⇒ Session
Returns the session for this connection.
-
#session_head(mask) ⇒ Session
Returns the first session from the connection that matches the specified state mask.
- #session_policy? ⇒ Boolean
-
#state ⇒ Fixnum
Gets the endpoint current state flags.
-
#transport ⇒ Transport
The Transport to which this connection is bound.
-
#work_head ⇒ Delivery
Extracts the first delivery on the connection that has pending operations.
Methods included from Util::Wrapper
#impl, #impl=, included, registry
Methods included from Util::SwigHelper
Methods inherited from Endpoint
#_update_condition, #check_state, #handler, #handler=, #local_active?, #local_closed?, #local_uninit?, #remote_active?, #remote_closed?, #remote_condition, #remote_uninit?
Methods included from Util::Engine
#condition_to_object, #data_to_object, #object_to_condition, #object_to_data, receive_message
Constructor Details
#initialize(impl = Cproton.pn_connection) ⇒ Connection
Constructs a new instance of Connection.
You do not need to provide the underlying C struct, as this is automatically generated as needed. The argument is a convenience for returning existing Connection objects.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/core/connection.rb', line 62 def initialize(impl = Cproton.pn_connection) super() @impl = impl @offered_capabilities = nil @desired_capabilities = nil @properties = nil @overrides = nil @collector = nil @session_policy = nil self.class.store_instance(self, :pn_connection_attachments) end |
Instance Attribute Details
#hostname ⇒ String
Returns The AMQP hostname for the connection.
36 |
# File 'lib/core/connection.rb', line 36 proton_accessor :hostname |
#overrides ⇒ Object
Returns the value of attribute overrides.
41 42 43 |
# File 'lib/core/connection.rb', line 41 def overrides @overrides end |
#session_policy ⇒ Object
Returns the value of attribute session_policy.
42 43 44 |
# File 'lib/core/connection.rb', line 42 def session_policy @session_policy end |
Class Method Details
.wrap(impl) ⇒ Object
48 49 50 51 52 |
# File 'lib/core/connection.rb', line 48 def self.wrap(impl) return nil if impl.nil? self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl) end |
Instance Method Details
#_local_condition ⇒ Object
317 318 319 |
# File 'lib/core/connection.rb', line 317 def _local_condition Cproton.pn_connection_condition(@impl) end |
#_remote_condition ⇒ Object
322 323 324 |
# File 'lib/core/connection.rb', line 322 def _remote_condition Cproton.pn_connection_remote_condition(@impl) end |
#close ⇒ Object
Closes the connection.
Once this operation has completed, the #LOCAL_CLOSED state flag will be set.
215 216 217 218 |
# File 'lib/core/connection.rb', line 215 def close self._update_condition Cproton.pn_connection_close(@impl) end |
#collect(collector) ⇒ Object
Associates the connection with an event collector.
By doing this, key changes in the endpoint’s state are reported to the connector via Event objects that can be inspected and processed.
Note that, by registering a collector, the user is requesting that an indefinite number of events be queued up on its behalf. This means that, unless the application eventual processes these events, the storage requirements for keeping them will grow without bound. So be careful and do not register a collector with a connection unless the application will process the events.
112 113 114 115 116 117 118 119 |
# File 'lib/core/connection.rb', line 112 def collect(collector) if collector.nil? Cproton.pn_connection_collect(@impl, nil) else Cproton.pn_connection_collect(@impl, collector.impl) end @collector = collector end |
#connection ⇒ Connection
This method is used when working within the context of an event.
86 87 88 |
# File 'lib/core/connection.rb', line 86 def connection self end |
#container ⇒ Object
142 143 144 |
# File 'lib/core/connection.rb', line 142 def container Cproton.pn_connection_get_container(@impl) end |
#container=(name) ⇒ Object
138 139 140 |
# File 'lib/core/connection.rb', line 138 def container=(name) Cproton.pn_connection_set_container(@impl, name) end |
#error ⇒ Fixnum
Returns the code for a connection error.
312 313 314 |
# File 'lib/core/connection.rb', line 312 def error Cproton.pn_error_code(Cproton.pn_connection_error(@impl)) end |
#link_head(mask) ⇒ Link
Returns the first link that matches the given state mask.
Examines the state of each link owned by the connection and returns the first that matches the given state mask. If the state mask contains both local and remote flags, then an exact match against those flags is performed. If the state mask contains only local or remote flags, then a match occurs if any of the local ore remote flags are set, respectively.
286 287 288 |
# File 'lib/core/connection.rb', line 286 def link_head(mask) Link.wrap(Cproton.pn_link_head(@impl, mask)) end |
#open ⇒ Object
Opens the connection.
200 201 202 203 204 205 206 207 208 |
# File 'lib/core/connection.rb', line 200 def open object_to_data(@offered_capabilities, Cproton.pn_connection_offered_capabilities(@impl)) object_to_data(@desired_capabilities, Cproton.pn_connection_desired_capabilities(@impl)) object_to_data(@properties, Cproton.pn_connection_properties(@impl)) Cproton.pn_connection_open(@impl) end |
#overrides? ⇒ Boolean
74 75 76 |
# File 'lib/core/connection.rb', line 74 def overrides? !@overrides.nil? end |
#remote_container ⇒ String
Get the AMQP container name advertised by the remote connection endpoint.
This will return nil until the REMOTE_ACTIVE state is reached.
Any non-nil container returned by this operation will be valid until the connection is unbound from a transport, or freed, whichever happens sooner.
134 135 136 |
# File 'lib/core/connection.rb', line 134 def remote_container Cproton.pn_connection_remote_container(@impl) end |
#remote_desired_capabilities ⇒ Data
Get the AMQP desired capabilities supplied by the remote connection endpoint.
The object returned is valid until the connection is freed. The Data object will be empty until the remote connection is opened, as indicated by the #REMOTE_ACTIVE flag.
181 182 183 |
# File 'lib/core/connection.rb', line 181 def remote_desired_capabilities data_to_object(Cproton.pn_connection_remote_desired_capabilities(@impl)) end |
#remote_hostname ⇒ String
Get the AMQP hostname set by the remote connection endpoint.
This will return nil until the #REMOTE_ACTIVE state is reached.
155 156 157 |
# File 'lib/core/connection.rb', line 155 def remote_hostname Cproton.pn_connection_remote_hostname(@impl) end |
#remote_offered_capabilities ⇒ Data
Get the AMQP offered capabilities suppolied by the remote connection endpoint.
This object returned is valid until the connection is freed. The Data object will be empty until the remote connection is opened, as indicated by the #REMOTE_ACTIVE flag.
168 169 170 |
# File 'lib/core/connection.rb', line 168 def remote_offered_capabilities data_to_object(Cproton.pn_connection_remote_offered_capabilities(@impl)) end |
#remote_properties ⇒ Data
Get the AMQP connection properties supplie by the remote connection endpoint.
The object returned is valid until the connection is freed. The Data object will be empty until the remote connection is opened, as indicated by the #REMOTE_ACTIVE flag.
194 195 196 |
# File 'lib/core/connection.rb', line 194 def remote_properties data_to_object(Cproton.pn_connection_remote_properites(@impl)) end |
#session ⇒ Session
Returns the session for this connection.
237 238 239 |
# File 'lib/core/connection.rb', line 237 def session @session ||= Session.wrap(Cproton.pn_session(@impl)) end |
#session_head(mask) ⇒ Session
Returns the first session from the connection that matches the specified state mask.
Examines the state of each session owned by the connection, and returns the first session that matches the given state mask. If the state mask contains both local and remote flags, then an exact match against those flags is performed. If the state mask contains only local or remote flags, then a match occurs if a*any* of the local or remote flags are set, respectively.
262 263 264 |
# File 'lib/core/connection.rb', line 262 def session_head(mask) Session.wrap(Cproton.pn_session_header(@impl, mask)) end |
#session_policy? ⇒ Boolean
78 79 80 |
# File 'lib/core/connection.rb', line 78 def session_policy? !@session_policy.nil? end |
#state ⇒ Fixnum
Gets the endpoint current state flags
229 230 231 |
# File 'lib/core/connection.rb', line 229 def state Cproton.pn_connection_state(@impl) end |
#transport ⇒ Transport
The Transport to which this connection is bound.
94 95 96 |
# File 'lib/core/connection.rb', line 94 def transport Transport.wrap(Cproton.pn_connection_transport(@impl)) end |
#work_head ⇒ Delivery
Extracts the first delivery on the connection that has pending operations.
A readable delivery indicates message data is waiting to be read. A A writable delivery indcates that message data may be sent. An updated delivery indicates that the delivery’s disposition has changed.
A delivery will never be both readable and writable, but it may be both readable or writable and updated.
304 305 306 |
# File 'lib/core/connection.rb', line 304 def work_head Delivery.wrap(Cproton.pn_work_head(@impl)) end |