You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2012/11/14 21:15:36 UTC

svn commit: r1409368 - in /qpid/proton/trunk/proton-c/bindings/ruby: lib/qpid_proton/messenger.rb spec/qpid/proton/messenger_spec.rb

Author: mcpierce
Date: Wed Nov 14 20:15:36 2012
New Revision: 1409368

URL: http://svn.apache.org/viewvc?rev=1409368&view=rev
Log:
NO-JIRA: Added incoming/outgoing window support to the Ruby bindings.

Added the incoming_window=, incoming_window, outgoing_window= and
outgoing_window methods to Qpid::Proton::Messenger. Added rspec tests to
verify the methods as working properly.

Modified:
    qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
    qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb

Modified: qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb?rev=1409368&r1=1409367&r2=1409368&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb Wed Nov 14 20:15:36 2012
@@ -337,6 +337,47 @@ module Qpid
         Cproton.pn_messenger_settle(@impl, tracker.impl, flag)
       end
 
+      # Sets the incoming window.
+      #
+      # If the incoming window is set to a positive value, then after each
+      # call to #accept or #reject, the object will track the status of that
+      # many deliveries.
+      #
+      # ==== Options
+      #
+      # * window - the window size
+      #
+      def incoming_window=(window)
+        raise TypeError.new("invalid window: #{window}") unless valid_window?(window)
+        check_for_error(Cproton.pn_messenger_set_incoming_window(@impl, window))
+      end
+
+      # Returns the incoming window.
+      #
+      def incoming_window
+        Cproton.pn_messenger_get_incoming_window(@impl)
+      end
+
+      #Sets the outgoing window.
+      #
+      # If the outgoing window is set to a positive value, then after each call
+      # to #send, the object will track the status of that  many deliveries.
+      #
+      # ==== Options
+      #
+      # * window - the window size
+      #
+      def outgoing_window=(window)
+        raise TypeError.new("invalid window: #{window}") unless valid_window?(window)
+        check_for_error(Cproton.pn_messenger_set_outgoing_window(@impl, window))
+      end
+
+      # Returns the outgoing window.
+      #
+      def outgoing_window
+        Cproton.pn_messenger_get_outgoing_window(@impl)
+      end
+
       private
 
       def valid_tracker?(tracker)
@@ -347,6 +388,10 @@ module Qpid
         [ACCEPT_MODE_AUTO, ACCEPT_MODE_MANUAL].include?(mode)
       end
 
+      def valid_window?(window)
+        !window.nil? && [Float, Fixnum].include?(window.class)
+      end
+
     end
 
   end

Modified: qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb?rev=1409368&r1=1409367&r2=1409368&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb Wed Nov 14 20:15:36 2012
@@ -177,6 +177,66 @@ module Qpid
         @messenger.accept_mode.should equal(mode)
       end
 
+      it "raises an error on a nil outgoing window" do
+        expect {
+          @messenger.outgoing_window = nil
+        }.to raise_error(TypeError)
+      end
+
+      it "raises an error on a non-numeric outgoing window" do
+        expect {
+          @messenger.outgoing_window = random_string(16)
+        }.to raise_error(TypeError)
+      end
+
+      it "can have a negative outgoing window" do
+        window = 0 - (rand(256) + 1)
+        @messenger.outgoing_window = window
+        @messenger.outgoing_window.should eq(window)
+      end
+
+      it "can have a positive outgoing window" do
+        window = (rand(256) + 1)
+        @messenger.outgoing_window = window
+        @messenger.outgoing_window.should eq(window)
+      end
+
+      it "can have a zero outgoing window" do
+        window = 0
+        @messenger.outgoing_window = window
+        @messenger.outgoing_window.should eq(window)
+      end
+
+      it "raises an error on a nil incoming window" do
+        expect {
+          @messenger.incoming_window = nil
+        }.to raise_error(TypeError)
+      end
+
+      it "raises an error on a non-numeric incoming window" do
+        expect {
+          @messenger.incoming_window = random_string(16)
+        }.to raise_error(TypeError)
+      end
+
+      it "can have a negative incoming window" do
+        window = 0 - (rand(256) + 1)
+        @messenger.incoming_window = window
+        @messenger.incoming_window.should eq(window)
+      end
+
+      it "can have a positive incoming window" do
+        window = (rand(256) + 1)
+        @messenger.incoming_window = window
+        @messenger.incoming_window.should eq(window)
+      end
+
+      it "can have a zero incoming window" do
+        window = 0
+        @messenger.incoming_window = window
+        @messenger.incoming_window.should eq(window)
+      end
+
       describe "once started" do
 
         before (:each) do



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org