Class: Qpid::Proton::Transport Deprecated

Inherits:
Object
  • Object
show all
Includes:
Util::Deprecation, Util::ErrorHandler, Util::Wrapper
Defined in:
lib/core/transport.rb

Overview

Deprecated.

all important features are available from #Connection

Constant Summary collapse

PROTON_METHOD_PREFIX =
"pn_transport"
TRACE_OFF =

Turn logging off entirely.

Cproton::PN_TRACE_OFF
TRACE_RAW =

Log raw binary data into/out of the transport.

Cproton::PN_TRACE_RAW
TRACE_FRM =

Log frames into/out of the transport.

Cproton::PN_TRACE_FRM
TRACE_DRV =

Log driver related events; i.e., initialization, end of stream, etc.

Cproton::PN_TRACE_DRV

Constants included from Util::Deprecation

Util::Deprecation::DEPRECATE_FULL_TRACE, Util::Deprecation::MATCH_DIR

Instance Attribute Summary collapse

Attributes included from Util::Wrapper

#impl

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::ErrorHandler

#can_raise_error, #check_for_error, #create_exception_handler_wrapper, included

Methods included from Util::Wrapper

included, #inspect, registry, #to_s

Methods included from Util::Deprecation

deprecated, #deprecated, included

Constructor Details

#initialize(impl = Cproton.pn_transport) ⇒ Transport

Creates a new transport instance.



171
172
173
174
# File 'lib/core/transport.rb', line 171

def initialize(impl = Cproton.pn_transport)
  @impl = impl
  self.class.store_instance(self, :pn_transport_attachments)
end

Instance Attribute Details

#capacityInteger (readonly)

If the engine is in an exception state such as encountering an error condition or reaching the end of stream state, a negative value will be returned indicating the condition.

If an error is indicated, further deteails can be obtained from #error.

Calls to #process may alter the value of this value. See #process for more details

transport’s tail pointer.

Returns:

  • (Integer)

    The amount of free space for input following the



100
# File 'lib/core/transport.rb', line 100

proton_caller :capacity

#channel_maxInteger

Returns The maximum allowed channel.

Returns:

  • (Integer)

    The maximum allowed channel.



45
# File 'lib/core/transport.rb', line 45

proton_set_get :channel_max

#closed?Boolean (readonly)

A transport is defined to be closed when both the tail and the head are closed. In other words, when both #capacity < 0 and #pending < 0.

Returns:

  • (Boolean)

    Returns true if the tranpsort is closed.



146
# File 'lib/core/transport.rb', line 146

proton_caller :closed?

#frames_inputInteger (readonly)

Returns The number of frames input by a transport.

Returns:

  • (Integer)

    The number of frames input by a transport.



158
# File 'lib/core/transport.rb', line 158

proton_get :frames_input

#frames_outputInteger (readonly)

Returns The number of frames output by a transport.

Returns:

  • (Integer)

    The number of frames output by a transport.



152
# File 'lib/core/transport.rb', line 152

proton_get :frames_output

#headString (readonly)

This referneces queued output data. It reports the bytes of output data.

Calls to #pop may alter this attribute, and any data it references.

Returns:

  • (String)

    The transport’s head pointer.



110
# File 'lib/core/transport.rb', line 110

proton_caller :head

#idle_timeoutInteger

Deprecated.

use Connection#open with the :idle_timeout option to set

the timeout, and Connection#idle_timeout to query the remote timeout.

The Connection timeout values are in seconds and are automatically converted.

Returns:

  • (Integer)

    The idle timeout in milliseconds.



75
# File 'lib/core/transport.rb', line 75

proton_set_get :idle_timeout

#max_frame_sizeInteger

Returns The maximum frame size.

Returns:

  • (Integer)

    The maximum frame size.



56
# File 'lib/core/transport.rb', line 56

proton_set_get :max_frame

#pendingInteger (readonly)

If the ending is in an exceptional state, such as encountering an error condition or reachign the end of the stream state, a negative value will be returned indicating the condition.

If an error is indicated, further details can be obtained from #error.

Calls to #pop may alter the value of this pointer as well.

pointer.

Returns:

  • (Integer)

    The number of pending output bytes following the header

Raises:

  • (TransportError)

    If any error other than an end of stream occurs.



137
# File 'lib/core/transport.rb', line 137

proton_caller :pending

#remote_channel_maxInteger (readonly)

Returns The maximum allowed channel of a transport’s remote peer.

Returns:

  • (Integer)

    The maximum allowed channel of a transport’s remote peer.



51
# File 'lib/core/transport.rb', line 51

proton_caller :remote_channel_max

#remote_idle_timeout in millisecondsInteger (readonly)

Deprecated.

Use Qpid::Proton::Connection#idle_timeout to query the remote timeout.

Returns The idle timeout for the transport’s remote peer.

Returns:

  • (Integer)

    The idle timeout for the transport’s remote peer.



83
# File 'lib/core/transport.rb', line 83

proton_set_get :remote_idle_timeout

#remote_max_frame_sizeInteger (readonly)

Returns The maximum frame size of the transport’s remote peer.

Returns:

  • (Integer)

    The maximum frame size of the transport’s remote peer.



63
# File 'lib/core/transport.rb', line 63

proton_get :remote_max_frame_size

#tailString (readonly)

The amount of free space following this data is reported by #capacity.

Calls to #process may alter the value of this attribute.

Returns:

  • (String)

    The transport’s tail pointer.



120
# File 'lib/core/transport.rb', line 120

proton_caller :tail

Class Method Details

.wrap(impl) ⇒ Object



164
165
166
167
168
# File 'lib/core/transport.rb', line 164

def self.wrap(impl)
  return nil if impl.nil?

  self.fetch_instance(impl, :pn_transport_attachments) || Transport.new(impl)
end

Instance Method Details

#apply(opts) ⇒ Object

Options are documented Connection#open, keep that consistent with this



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/core/transport.rb', line 357

def apply opts
  sasl if opts[:sasl_enabled]                                 # Explicitly enabled
  unless opts.include?(:sasl_enabled) && !opts[:sasl_enabled] # Not explicitly disabled
    sasl.allowed_mechs = opts[:sasl_allowed_mechs] if opts.include? :sasl_allowed_mechs
    sasl.allow_insecure_mechs = opts[:sasl_allow_insecure_mechs] if opts.include? :sasl_allow_insecure_mechs
  end
  self.channel_max= opts[:max_sessions] if opts.include? :max_sessions
  self.max_frame = opts[:max_frame_size] if opts.include? :max_frame_size
  # NOTE: The idle_timeout option is in Numeric *seconds*, can be Integer, Float or Rational.
  # This is consistent with idiomatic ruby.
  # The transport #idle_timeout property is in *milliseconds* passed direct to C.
  # Direct use of the transport is deprecated.
  self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? :idle_timeout
  self.ssl(opts[:ssl_domain]) if opts[:ssl_domain]
end

#bind(connection) ⇒ Object

Binds to the given connection.

Parameters:



203
204
205
# File 'lib/core/transport.rb', line 203

def bind(connection)
  Cproton.pn_transport_bind(@impl, connection.impl)
end

#close_headObject

Indicate that the output has closed.

Tells the transport that no more output will be popped.

Raises:



310
311
312
# File 'lib/core/transport.rb', line 310

def close_head
  Cproton.pn_transport_close_head(@impl)
end

#close_tailObject

Indicate that the input has reached EOS (end of stream).

This tells the transport that no more input will be forthcoming.

Raises:



276
277
278
# File 'lib/core/transport.rb', line 276

def close_tail
  Cproton.pn_transport_close_tail(@impl)
end

#conditionCondition?

Returns transport error condition or nil if there is no error.

Returns:

  • (Condition, nil)

    transport error condition or nil if there is no error.



189
190
191
# File 'lib/core/transport.rb', line 189

def condition
  Condition.convert(Cproton.pn_transport_condition(@impl))
end

#condition=(c) ⇒ Object

Set the error condition for the transport.

Parameters:



195
196
197
# File 'lib/core/transport.rb', line 195

def condition=(c)
  Condition.assign(Cproton.pn_transport_condition(@impl), c)
end

#connectionConnection?

Return the AMQP connection associated with the transport.

Returns:

  • (Connection, nil)

    The bound connection, or nil.



230
231
232
# File 'lib/core/transport.rb', line 230

def connection
  Connection.wrap(Cproton.pn_transport_connection(@impl))
end

#log(message) ⇒ Object

Log a message to the transport’s logging mechanism.

This can be using in a debugging scenario as the message will be prepended with the transport’s identifier.

Parameters:

  • message (String)

    The message to be logged.



241
242
243
# File 'lib/core/transport.rb', line 241

def log(message)
  Cproton.pn_transport_log(@impl, message)
end

#peek(size) ⇒ String

Returns the specified number of bytes from the transport’s buffers.

Parameters:

  • size (Integer)

    The number of bytes to return.

Returns:

  • (String)

    The data peeked.

Raises:



288
289
290
291
292
293
# File 'lib/core/transport.rb', line 288

def peek(size)
  cd, out = Cproton.pn_transport_peek(@impl, size)
  return nil if cd == Qpid::Proton::Error::EOS
  raise TransportError.new if cd < -1
  out
end

#pop(size) ⇒ Object

Removes the specified number of bytes from the pending output queue following the transport’s head pointer.

Parameters:

  • size (Integer)

    The number of bytes to remove.



300
301
302
# File 'lib/core/transport.rb', line 300

def pop(size)
  Cproton.pn_transport_pop(@impl, size)
end

#process(size) ⇒ Object

Process input data following the tail pointer.

Calling this function will cause the transport to consume the specified number of bytes of input occupying the free space following the tail pointer. It may also change the value for #tail, as well as the amount of free space reported by #capacity.

Parameters:

  • size (Integer)

    The number of bytes to process.

Raises:



266
267
268
# File 'lib/core/transport.rb', line 266

def process(size)
  Cproton.pn_transport_process(@impl, size)
end

#push(data) ⇒ Integer

Pushes the supplied bytes into the tail of the transport.

Parameters:

  • data (String)

    The bytes to be pushed.

Returns:

  • (Integer)

    The number of bytes pushed.



251
252
253
# File 'lib/core/transport.rb', line 251

def push(data)
  Cproton.pn_transport_push(@impl, data, data.length)
end

#quiesced?Boolean

Returns whether the transport has any buffered data.

Returns:

  • (Boolean)

    True if the transport has no buffered data.



184
185
186
# File 'lib/core/transport.rb', line 184

def quiesced?
  Cproton.pn_transport_quiesced(@impl)
end

#saslSASL

Create, or return existing, SSL object for the transport.

Returns:

  • (SASL)

    the SASL object



335
336
337
# File 'lib/core/transport.rb', line 335

def sasl
  SASL.new(self)
end

#set_serverObject

Set server mode for this tranport - enables protocol detection and server-side authentication for incoming connections



178
# File 'lib/core/transport.rb', line 178

def set_server() Cproton.pn_transport_set_server(@impl); end

#ssl(domain = nil, session_details = nil) ⇒ SSL

Creates, or returns an existing, SSL object for the transport.

Parameters:

  • domain (SSLDomain) (defaults to: nil)

    The SSL domain.

  • session_details (SSLDetails) (defaults to: nil)

    The SSL session details.

Returns:

  • (SSL)

    The SSL object.



346
347
348
# File 'lib/core/transport.rb', line 346

def ssl(domain = nil, session_details = nil)
  @ssl ||= SSL.create(self, domain, session_details)
end

#ssl?Boolean

Returns:

  • (Boolean)


351
352
353
# File 'lib/core/transport.rb', line 351

def ssl?
  !@ssl.nil?
end

#tick(now) ⇒ Integer

Process any pending transport timer events.

This method should be called after all pending input has been processed by the transport (see #input), and before generating output (see #output).

It returns the deadline for the next pending timer event, if any art present.

Parameters:

  • now (Time)

    The timestamp.

Returns:

  • (Integer)

    If non-zero, the expiration time of the next pending timer event for the transport. The caller must invoke #tick again at least once at or before this deadline occurs.



329
330
331
# File 'lib/core/transport.rb', line 329

def tick(now)
  Cproton.pn_transport_tick(@impl, now)
end

#trace(level) ⇒ Object

Updates the transports trace flags.

Parameters:

  • level (Integer)

    The trace level.

See Also:



222
223
224
# File 'lib/core/transport.rb', line 222

def trace(level)
  Cproton.pn_transport_trace(@impl, level)
end

#unbindObject

Unbinds from the previous connection.



209
210
211
# File 'lib/core/transport.rb', line 209

def unbind
  Cproton.pn_transport_unbind(@impl)
end