PROTON-799: Added the Session class to the Ruby engine APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/82072689 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/82072689 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/82072689 Branch: refs/heads/ruby-engine-apis Commit: 8207268903e97eab18ef3a3c36762761abf5cf6a Parents: b66f117 Author: Darryl L. Pierce <mcpie...@gmail.com> Authored: Tue Jan 20 10:37:14 2015 -0500 Committer: Darryl L. Pierce <mcpie...@gmail.com> Committed: Tue May 19 08:02:47 2015 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/lib/core/exceptions.rb | 5 + proton-c/bindings/ruby/lib/core/session.rb | 163 +++++++++++++++++++++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 3 files changed, 169 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/82072689/proton-c/bindings/ruby/lib/core/exceptions.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/exceptions.rb b/proton-c/bindings/ruby/lib/core/exceptions.rb index 5e39ced..4e0bfc1 100644 --- a/proton-c/bindings/ruby/lib/core/exceptions.rb +++ b/proton-c/bindings/ruby/lib/core/exceptions.rb @@ -80,6 +80,11 @@ module Qpid class InProgressError < ProtonError end + # Raised by Session. + # + class SessionError < ProtonError + end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/82072689/proton-c/bindings/ruby/lib/core/session.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/core/session.rb b/proton-c/bindings/ruby/lib/core/session.rb new file mode 100644 index 0000000..2c9c3a1 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/session.rb @@ -0,0 +1,163 @@ +#-- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +#++ + +module Qpid::Proton + + # A session is the parent for senders and receivers. + # + # A Session has a single parent Qpid::Proton::Connection instance. + # + class Session < Endpoint + + # @private + include Util::Wrapper + + # @private + include Util::SwigHelper + + # @private + PROTON_METHOD_PREFIX = "pn_session" + + # @!attribute incoming_capacity + # + # The incoming capacity of a session determines how much incoming message + # data the session will buffer. Note that if this value is less than the + # negotatied frame size of the transport, it will be rounded up to one full + # frame. + # + # @return [Fixnum] The incoing capacity of the session, measured in bytes. + # + proton_accessor :incoming_capacity + + # @private + proton_reader :attachments + + # @!attribute [r] outgoing_bytes + # + # @return [Fixnum] The number of outgoing bytes currently being buffered. + # + proton_caller :outgoing_bytes + + # @!attribute [r] incoming_bytes + # + # @return [Fixnum] The number of incomign bytes currently being buffered. + # + proton_caller :incoming_bytes + + # @!method open + # Opens the session. + # + # Once this operaton has completed, the state flag is updated. + # + # @see LOCAL_ACTIVE + # + proton_caller :open + + # @!attribute [r] state + # + # @return [Fixnum] The endpoint state. + # + proton_caller :state + + # @private + def self.wrap(impl) + return nil if impl.nil? + self.fetch_instance(impl, :pn_session_attachments) || Session.new(impl) + end + + # @private + def initialize(impl) + @impl = impl + self.class.store_instance(self, :pn_session_attachments) + end + + # Closed the session. + # + # Once this operation has completed, the state flag will be set. This may be + # called without calling #open, in which case it is the equivalence of + # calling #open and then close immediately. + # + def close + self._update_condition + Cproton.pn_session_close(@impl) + end + + # Retrieves the next session from a given connection that matches the + # specified state mask. + # + # When uses with Connection#session_head an application can access all of + # the session son the connection that match the given state. + # + # @param state_mask [Fixnum] The state mask to match. + # + # @return [Session, nil] The next session if one matches, or nil. + # + def next(state_mask) + Session.wrap(Cproton.pn_session_next(@impl, state_mask)) + end + + # Returns the parent connection. + # + # @return [Connection] The connection. + # + def connection + Connection.wrap(Cproton.pn_session_connection(@impl)) + end + + # Constructs a new sender. + # + # Each sender between two AMQP containers must be uniquely named. Note that + # this uniqueness cannot be enforced at the library level, so some + # consideration should be taken in choosing link names. + # + # @param name [String] The link name. + # + # @return [Sender, nil] The sender, or nil if an error occurred. + # + def sender(name) + Sender.new(Cproton.pn_sender(@impl, name)) + end + + # Constructs a new receiver. + # + # Each receiver between two AMQP containers must be uniquely named. Note + # that this uniqueness cannot be enforced at the library level, so some + # consideration should be taken in choosing link names. + # + # @param name [String] The link name. + # + # @return [Receiver, nil] The receiver, or nil if an error occurred. + # + def receiver(name) + Receiver.new(Cproton.pn_receiver(@impl, name)) + end + + # @private + def _local_condition + Cproton.pn_session_condition(@impl) + end + + # @private + def _remote_condition # :nodoc: + Cproton.pn_session_remote_condition(@impl) + end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/82072689/proton-c/bindings/ruby/lib/qpid_proton.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb index fff9b0b..7f6b3ee 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -55,6 +55,7 @@ require "event/collector" # Main Proton classes require "core/message" require "core/endpoint" +require "core/session" # Messenger API classes require "messenger/filters" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org