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 2015/06/08 20:13:51 UTC

[22/31] qpid-proton git commit: PROTON-781: Added the set of LinkOption classes to Ruby.

PROTON-781: Added the set of LinkOption classes to Ruby.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3d946127
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3d946127
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3d946127

Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 3d94612780d5f299a2eb47cd54ddb488ff1360d4
Parents: 9b30655
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon May 4 13:26:26 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Mon Jun 8 13:57:52 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/qpid_proton.rb       |  1 +
 .../bindings/ruby/lib/reactor/link_option.rb    | 90 ++++++++++++++++++++
 2 files changed, 91 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d946127/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 ba1e66e..1d614a4 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -107,6 +107,7 @@ require "reactor/connector"
 require "reactor/backoff"
 require "reactor/session_per_connection"
 require "reactor/container"
+require "reactor/link_option"
 
 module Qpid::Proton
   # @private

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d946127/proton-c/bindings/ruby/lib/reactor/link_option.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/link_option.rb b/proton-c/bindings/ruby/lib/reactor/link_option.rb
new file mode 100644
index 0000000..628a811
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/reactor/link_option.rb
@@ -0,0 +1,90 @@
+#--
+# 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::Reactor
+
+  class LinkOption
+    def apply(link)
+    end
+
+    # Subclasses should override this to selectively apply an option.
+    def test(link)
+      true
+    end
+  end
+
+  class AtMostOne < LinkOption
+    def apply(link)
+      link.snd_settle_mod = Link::SND_SETTLED
+    end
+  end
+
+  class AtLeastOnce < LinkOption
+    def apply(link)
+      link.snd_settle_mode = Link::SND_UNSETTLED
+      link.rcv_settle_mode = Link::RCV_FIRST
+    end
+  end
+
+  class SenderOption < LinkOption
+    def test(link)
+      link.sender?
+    end
+  end
+
+  class ReceiverOption < LinkOption
+    def test(link)
+      link.receiver?
+    end
+  end
+
+  class DynamicNodeProperties < LinkOption
+    def initialize(properties = {})
+      @properties = []
+      properties.each do |property|
+        @properties << property.to_sym
+      end
+    end
+
+    def apply(link)
+      if link.receiver?
+        link.source.properties.dict = @properties
+      else
+        link.target.properties.dict = @properties
+      end
+    end
+  end
+
+  class Filter < ReceiverOption
+    def initialize(filter_set = {})
+      @filter_set = filter_set
+    end
+
+    def apply(receiver)
+      receiver.source.filter.dict = @filter_set
+    end
+  end
+
+  #class Selector < Filter
+  #  def initialize(value, name = 'selector')
+  #
+  #  end
+  #end
+
+end


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