[18/25] qpid-proton git commit: PROTON-799: Added the Transport class to the Ruby engine APIs.
PROTON-799: Added the Transport 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/d74eb5db Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d74eb5db Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d74eb5db Branch: refs/heads/ruby-engine-apis Commit: d74eb5db75d9539399a552e02b515047535dfbd0 Parents: 3f460aa Author: Darryl L. Pierce Authored: Wed Jan 14 09:31:46 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 5 + proton-c/bindings/ruby/lib/core/transport.rb | 412 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 3 files changed, 418 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d74eb5db/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 2695709..94d2957 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 instances of Transport. +# +class TransportError < ProtonError +end + # Raised by instances of SASL # class SASLError < TransportError http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d74eb5db/proton-c/bindings/ruby/lib/core/transport.rb -- diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb new file mode 100644 index 000..206f97d --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/transport.rb @@ -0,0 +1,412 @@ +#-- +# 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 transport is used by a connection to interface with the network. + # + # A transport is associated with, at most, one Connection. + # + # == Client And Server Mode + # + # Initially, a transport is configured to be a client tranpsort. It can be + # configured to act as a server when it is created. + # + # A client transport initiates outgoing connections. + # + # A client transport must be configured with the protocol layers to use and + # cannot configure itself automatically. + # + # A server transport accepts incoming connections. It can automatically + # configure itself to include the various protocol layers depending on the + # incoming protocol headers. + # + # == Tracing Data + # + # Data can be traced into and out of the transport programmatically by setting + # the #trace level to one of the defined trace values (TRACE_RAW, TRACE_FRM or + # TRACE_DRV). Tracing can also be turned off programmatically by setting the + # #trace level to TRACE_OFF. + # + # @example + # + # # turns on frame tracing + # @transport.trace = Qpid::Proton::Transport::TRACE_FRM + # + # # ... do something where the frames are of interest, such as debugging + # + # # turn tracing off again + # @transport.trace = Qpid::Proton::Transport::TRACE_NONE + # + # Tracing can also be enabled from the command line by defining the similarly + # named environment variable before starting a Proton application: + # + # @example + # + # # enable tracing from the command line + # PN_TRACE_FRM=1 ruby my_proton_app.rb + # + class Transport + +# @private +include Util::Engine + +# Turn logging off entirely. +TRACE_OFF = Cproton::PN_TRACE_OFF +# Log raw binary data into/out of the transport. +TRACE_RAW = Cproton::PN_TRACE_RAW +# Log frames into/out of the transport. +TRACE_FRM = Cproton::PN_TRACE_FRM +# Log driver related events; i.e., initialization, end of stream, etc. +TRACE_DRV = Cproton::PN_TRACE_DRV + +# @private +CLIENT = 1 +# @private +SERVER = 2 + +# @private +include Util::
[11/25] qpid-proton git commit: PROTON-799: Added the Endpoint class to the Ruby engine APIs.
PROTON-799: Added the Endpoint 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/642d319c Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/642d319c Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/642d319c Branch: refs/heads/ruby-engine-apis Commit: 642d319caa4ee56f8453de1461d0090ac5e81e27 Parents: 8f37627 Author: Darryl L. Pierce Authored: Mon Jan 19 10:20:33 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/endpoint.rb | 115 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 116 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/642d319c/proton-c/bindings/ruby/lib/core/endpoint.rb -- diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb new file mode 100644 index 000..cbf1015 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/endpoint.rb @@ -0,0 +1,115 @@ +#-- +# 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 + + # Endpoint is the parent classes for Link and Session. + # + # It provides a namespace for constant values that relate to the current + # state of both links and sessions. + # + # @example + # + # conn = Qpid::Proton::Connection.new + # puts "Local connection flags : #{conn.state || Qpid::Proton::Endpoint::LOCAL_MASK}" + # puts "Remote connection flags: #{conn.state || Qpid::Proton::Endpoint::REMOTE_MASK}" + # + class Endpoint + +# The local connection is uninitialized. +LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT +# The local connection is active. +LOCAL_ACTIVE = Cproton::PN_LOCAL_ACTIVE +# The local connection is closed. +LOCAL_CLOSED = Cproton::PN_LOCAL_CLOSED + +# The remote connection is unitialized. +REMOTE_UNINIT = Cproton::PN_REMOTE_UNINIT +# The remote connection is active. +REMOTE_ACTIVE = Cproton::PN_REMOTE_ACTIVE +# The remote connection is closed. +REMOTE_CLOSED = Cproton::PN_REMOTE_CLOSED + +# Bitmask for the local-only flags. +LOCAL_MASK = Cproton::PN_LOCAL_UNINIT | + Cproton::PN_LOCAL_ACTIVE | + Cproton::PN_LOCAL_CLOSED + +# Bitmask for the remote-only flags. +REMOTE_MASK = Cproton::PN_REMOTE_UNINIT | + Cproton::PN_REMOTE_ACTIVE | + Cproton::PN_REMOTE_CLOSED + +# @private +include Util::Engine + +# @private +def initialize + @condition = nil +end + +# @private +def _update_condition + object_to_condition(@condition, self._local_condition) +end + +# @private +def remote_condition + condition_to_object(self._remote_condition) +end + +# Return the transport associated with this endpoint. +# +# @return [Transport] The transport. +# +def transport + self.connection.transport +end + +def local_uninit? + check_state(LOCAL_UNINIT) +end + +def local_active? + check_state(LOCAL_ACTIVE) +end + +def local_closed? + check_state(LOCAL_CLOSED) +end + +def remote_uninit? + check_state(REMOTE_UNINIT) +end + +def remote_active? + check_state(REMOTE_ACTIVE) +end + +def remote_closed? + check_state(REMOTE_CLOSED) +end + +def check_state(state_mask) + !(self.state & state_mask).zero? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/642d319c/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 507b61f..fff9b0b 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -54,6 +54,7 @@ require "event/collector" # Main Proton classes require "core/messag
[01/25] qpid-proton git commit: PROTON-799: Added the Sender class to the Ruby engine APIs.
Repository: qpid-proton Updated Branches: refs/heads/ruby-engine-apis b5a25940b -> ed9ecab07 (forced update) PROTON-799: Added the Sender 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/dc37435a Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/dc37435a Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/dc37435a Branch: refs/heads/ruby-engine-apis Commit: dc37435a3009c82181970ccabb793b685daa8828 Parents: c2f62c1 Author: Darryl L. Pierce Authored: Tue Jan 20 09:17:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/sender.rb | 76 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 77 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dc37435a/proton-c/bindings/ruby/lib/core/sender.rb -- diff --git a/proton-c/bindings/ruby/lib/core/sender.rb b/proton-c/bindings/ruby/lib/core/sender.rb new file mode 100644 index 000..9ddcaa0 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/sender.rb @@ -0,0 +1,76 @@ +#-- +# 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 + + # The sending endpoint. + # + # @see Receiver + # + class Sender < Link + +# @private +include Util::ErrorHandler + +# @private +can_raise_error :stream, :error_class => Qpid::Proton::LinkError + +# Signals the availability of deliveries. +# +# @param n [Fixnum] The number of deliveries potentially available. +# +def offered(n) + Cproton.pn_link_offered(@impl, n) +end + +# Sends the specified data to the remote endpoint. +# +# @param object [Object] The content to send. +# @param tag [Object] The tag +# +# @return [Fixnum] The number of bytes sent. +# +def send(object, tag = nil) + if object.respond_to? :proton_send +object.proton_send(self, tag) + else +stream(object) + end +end + +# Send the specified bytes as part of the current delivery. +# +# @param bytes [Array] The bytes to send. +# +# @return n [Fixnum] The number of bytes sent. +# +def stream(bytes) + Cproton.pn_link_send(@impl, bytes) +end + +def delivery_tag + @tag_count ||= 0 + result = @tag_count.succ + @tag_count = result + return "#{result}" +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dc37435a/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 9b3becb..39ef351 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -60,6 +60,7 @@ require "core/terminus" require "core/disposition" require "core/delivery" require "core/link" +require "core/sender" # 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
[17/25] qpid-proton git commit: PROTON-799: Added the Receiver class to the Ruby engine APIs.
PROTON-799: Added the Receiver 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/c0248d25 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c0248d25 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c0248d25 Branch: refs/heads/ruby-engine-apis Commit: c0248d258b548f5e4398b6e6f6a4d90206e002c7 Parents: dc37435 Author: Darryl L. Pierce Authored: Tue Jan 20 09:22:49 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/receiver.rb | 95 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 96 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c0248d25/proton-c/bindings/ruby/lib/core/receiver.rb -- diff --git a/proton-c/bindings/ruby/lib/core/receiver.rb b/proton-c/bindings/ruby/lib/core/receiver.rb new file mode 100644 index 000..ca7c5e1 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/receiver.rb @@ -0,0 +1,95 @@ +#-- +# 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 + + # The receiving endpoint. + # + # @see Sender + # + class Receiver < Link + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_link" + +# @!attribute drain +# +# The drain mode. +# +# If a receiver is in drain mode, then the sending endpoint of a link must +# immediately use up all available credit on the link. If this is not +# possible, the excess credit must be returned by invoking #drained. +# +# Only the receiving endpoint can set the drain mode. +# +# @return [Boolean] True if drain mode is set. +# +proton_accessor :drain + +# @!attribute [r] draining? +# +# Returns if a link is currently draining. +# +# A link is defined to be draining when drain mode is set to true and +# the sender still has excess credit. +# +# @return [Boolean] True if the receiver is currently draining. +# +proton_caller :draining? + +# Grants credit for incoming deliveries. +# +# @param n [Fixnum] The amount to increment the link credit. +# +def flow(n) + Cproton.pn_link_flow(@impl, n) +end + +# Allows receiving up to the specified limit of data from the remote +# endpoint. +# +# Note that large messages can be streamed across the network, so just +# because there is no data to read does not imply the message is complete. +# +# To ensure the entirety of the message data has been read, either call +# #receive until nil is returned, or verify that #partial? is false and +# Delivery#pending is 0. +# +# @param limit [Fixnum] The maximum bytes to receive. +# +# @return [Fixnum, nil] The number of bytes received, or nil if the end of +# the stream was reached.t +# +# @see Deliver#pending To see how much buffer space is needed. +# +# @raise [LinkError] If an error occurs. +# +def receive(limit) + (n, bytes) = Cproton.pn_link_recv(@impl, limit) + return nil if n == Qpid::Proton::Error::EOS + raise LinkError.new("[#{n}]: #{Cproton.pn_link_error(@impl)}") if n < 0 + return bytes +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c0248d25/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 39ef351..ed8532f 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -61,6 +61,7 @@ require "core/disposition" require "core/delivery" require "core/link" require "core/sender" +require "core/receiver" # Messenger API classes require "messenger/filters" - To unsubs
[15/25] qpid-proton git commit: PROTON-799: Added yardopts
PROTON-799: Added yardopts Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e61ae224 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e61ae224 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e61ae224 Branch: refs/heads/ruby-engine-apis Commit: e61ae22438229b7d80795b4eb166ef99331578d0 Parents: c236351 Author: Darryl L. Pierce Authored: Mon Feb 9 16:54:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/.yardopts | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e61ae224/proton-c/bindings/ruby/.yardopts -- diff --git a/proton-c/bindings/ruby/.yardopts b/proton-c/bindings/ruby/.yardopts new file mode 100644 index 000..bea5abe --- /dev/null +++ b/proton-c/bindings/ruby/.yardopts @@ -0,0 +1 @@ +--no-private lib/**/*.rb - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[04/25] qpid-proton git commit: PROTON-799: Added the Collector class to the Ruby engine APIs.
PROTON-799: Added the Collector 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/779d72cc Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/779d72cc Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/779d72cc Branch: refs/heads/ruby-engine-apis Commit: 779d72cc0e052a5c8a83a8bd0f1a487e95f0695a Parents: 2253334 Author: Darryl L. Pierce Authored: Tue Jan 6 13:51:34 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/event/collector.rb | 148 + proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + proton-c/bindings/ruby/ruby.i | 9 ++ 3 files changed, 160 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/779d72cc/proton-c/bindings/ruby/lib/event/collector.rb -- diff --git a/proton-c/bindings/ruby/lib/event/collector.rb b/proton-c/bindings/ruby/lib/event/collector.rb new file mode 100644 index 000..c86b0f2 --- /dev/null +++ b/proton-c/bindings/ruby/lib/event/collector.rb @@ -0,0 +1,148 @@ +#-- +# 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::Event + + # A Collector is used to register interest in events produced by one + # or more Connection objects. + # + # == Events + # + # @see Qpid::Proton::Event The list of predefined events. + # + # @example + # + # conn = Qpid::Proton::Connection.new + # coll = Qpid::Proton::Event::Collector.new + # conn.collect(coll) + # + # # transport setup not included here for brevity + # + # loop do + # + # # wait for an event and then perform the following + # + # event = collector.peek + # + # unless event.nil? + #case event.type + # + #when Qpid::Proton::Event::CONNECTION_REMOTE_CLOSE + # conn = event.context # the context here is the connection + # # the remote connection closed, so only close our side if it's + # # still open + # if !(conn.state & Qpid::Proton::Endpoint::LOCAL_CLOSED) + #conn.close + # end + # + #when Qpid::proton::Event::SESSION_REMOTE_OPEN + # session = event.session # the context here is the session + # # the remote session is now open, so if the local session is + # # uninitialized, then open it + # if session.state & Qpid::Proton::Endpoint::LOCAL_UNINIT + #session.incoming_capacity = 100 + #session.open + # end + # + #end + # + # # remove the processed event and get the next event + # # the loop will exit when we have no more events to process + # collector.pop + # event = collector.peek + # + # end + # + class Collector + +# @private +attr_reader :impl + +# Creates a new Collector. +# +def initialize + @impl = Cproton.pn_collector + ObjectSpace.define_finalizer(self, self.class.finalize!(@impl)) +end + +# @private +def self.finalize!(impl) + proc { +Cproton.pn_collector_free(impl) + } +end + +# Releases the collector. +# +# Once in a released state, a collector will drain any internally queued +# events, shrink its memory footprint to a minimu, and discard any newly +# created events. +# +def release + Cproton.pn_collector_release(@impl) +end + +# Place a new event on the collector. +# +# This operation will create a new event of the given type and context +# and return a new Event instance. In some cases an event of a given +# type can be elided. When this happens, this operation will return +# nil. +# +# @param context [Object] The event context. +# @param event_type [EventType] The event type. +# +# @return [Event] the event if it was queued +# @return [nil] if it was elided +# +def put(context, event_type)
[25/25] qpid-proton git commit: PROTON-799: Added the SSL classes to the Ruby engine APIs.
PROTON-799: Added the SSL classes 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/3f460aac Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3f460aac Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3f460aac Branch: refs/heads/ruby-engine-apis Commit: 3f460aac29d57d1ac7d8d43f09222998a6440e08 Parents: 4323634 Author: Darryl L. Pierce Authored: Wed Apr 29 16:45:05 2015 -0400 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 6 + proton-c/bindings/ruby/lib/core/ssl.rb | 160 proton-c/bindings/ruby/lib/core/ssl_details.rb | 33 proton-c/bindings/ruby/lib/core/ssl_domain.rb | 156 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + proton-c/bindings/ruby/ruby.i | 14 ++ 6 files changed, 372 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f460aac/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 714830b..2695709 100644 --- a/proton-c/bindings/ruby/lib/core/exceptions.rb +++ b/proton-c/bindings/ruby/lib/core/exceptions.rb @@ -100,6 +100,12 @@ module Qpid class LinkError < ProtonError end +class SSLError < TransportError +end + +class SSLUnavailableError < SSLError +end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3f460aac/proton-c/bindings/ruby/lib/core/ssl.rb -- diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb new file mode 100644 index 000..9c4a3e9 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/ssl.rb @@ -0,0 +1,160 @@ +#-- +# 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 + + # The SSL support for Transport. + # + # A Transport may be configured ot use SLL for encryption and/or + # authentication. A Transport can be configured as either the SSL + # client or the server. An SSL client is the party that proctively + # establishes a connection to an SSL server. An SSL server is the + # party that accepts a connection request from the remote SSL client. + # + # If either the client or the server needs to identify itself with the + # remote node, it must have its SSL certificate configured. + # + # @see SSLDomain#credentials For setting the SSL certificate. + # + # If either the client or the server needs to verify the identify of the + # remote node, it must have its database of trusted CAs configured. + # + # @see SSLDomain#trusted_ca_db Setting the CA database. + # + # An SSL server connection may allow the remote client to connect without + # SS (i.e., "in the clear"). + # + # @see SSLDomain#allow_unsecured_client Allowing unsecured clients. + # + # The level of verification required of the remote may be configured. + # + # @see SSLDomain#peer_authentication Setting peer authentication. + # + # Support for SSL client session resume is provided as well. + # + # @see SSLDomain + # @see #resume_status + # + class SSL + +# Session resume state is unkonnwn or not supported. +RESUME_UNKNOWN = Cproton::PN_SSL_RESUME_UNKNOWN +# Session renegotiated and not resumed. +RESUME_NEW = Cproton::PN_SSL_RESUME_NEW +# Session resumed from the previous session. +RESUME_REUSED = Cproton::PN_SSL_RESUME_REUSED + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_ssl" + +# @!attribute peer_hostname +# +# @return [String] The peer hostname. +proton_accessor :peer_hostname + +# @private +include Util::ErrorHandler + +can_raise_error :peer_hostname=, :error_class => SSLError + +# Returns whether SSL is supported. +# +# @return [Boolea
[19/25] qpid-proton git commit: PROTON-799: Added the SASL class to the Ruby engine APIs.
PROTON-799: Added the SASL 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/43236348 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/43236348 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/43236348 Branch: refs/heads/ruby-engine-apis Commit: 432363483a3be71f2dba15a1466b61d0735d4cba Parents: eb95452 Author: Darryl L. Pierce Authored: Tue Jan 20 16:09:30 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/sasl.rb | 94 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 95 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43236348/proton-c/bindings/ruby/lib/core/sasl.rb -- diff --git a/proton-c/bindings/ruby/lib/core/sasl.rb b/proton-c/bindings/ruby/lib/core/sasl.rb new file mode 100644 index 000..7870652 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/sasl.rb @@ -0,0 +1,94 @@ +#-- +# 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 + + # The SASL layer is responsible for establishing an authenticated and/or + # encrypted tunnel over which AMQP frames are passed between peers. + # + # The peer acting as the SASL client must provide authentication + # credentials. + # + # The peer acting as the SASL server must provide authentication against the + # received credentials. + # + # @example + # # SCENARIO: the remote endpoint has not initialized their connection + # # then the local endpoint, acting as a SASL server, decides + # # to allow an anonymous connection. + # # + # # The SASL layer locally assumes the role of server and then + # # enables anonymous authentication for the remote endpoint. + # # + # sasl = @transport.sasl + # sasl.server + # sasl.mechanisms("ANONYMOUS") + # sasl.done(Qpid::Proton::SASL::OK) + # + class SASL + +# Negotation has not completed. +NONE = Cproton::PN_SASL_NONE +# Authentication succeeded. +OK = Cproton::PN_SASL_OK +# Authentication failed due to bad credentials. +AUTH = Cproton::PN_SASL_AUTH + +# Constructs a new instance for the given transport. +# +# @param transport [Transport] The transport. +# +# @private A SASL should be fetched only from its Transport +# +def initialize(transport) + @impl = Cproton.pn_sasl(transport.impl) +end + +# Sets the acceptable SASL mechanisms. +# +# @param mechanisms [String] The space-delimited set of mechanisms. +# +# @example Use anonymous SASL authentication. +# @sasl.mechanisms("GSSAPI CRAM-MD5 PLAIN") +# +def mechanisms(mechanisms) + Cproton.pn_sasl_mechanisms(@impl, mechanisms) +end + +# Returns the outcome of the SASL negotiation. +# +# @return [Fixnum] The outcome. +# +def outcome + outcome = Cprotn.pn_sasl_outcome(@impl) + return nil if outcome == NONE + outcome +end + +# Set the condition of the SASL negotiation. +# +# @param outcome [Fixnum] The outcome. +# +def done(outcome) + Cproton.pn_sasl_done(@impl, outcome) +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43236348/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 2a57b32..3ac0b9e 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -63,6 +63,7 @@ require "core/link" require "core/sender" require "core/receiver" require "core/connection" +require "core/sasl" # Messenger API classes require "messenger/filters" - To unsubscribe, e-mail: commits-unsubscr...@qpid
[03/25] qpid-proton git commit: PROTON-799: Added the Delivery class to the Ruby engine APIs.
PROTON-799: Added the Delivery 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/933530bb Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/933530bb Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/933530bb Branch: refs/heads/ruby-engine-apis Commit: 933530bbab05e84d9d9c307577bd8dc51184cb7a Parents: 2eb09d4 Author: Darryl L. Pierce Authored: Tue Jan 20 11:10:34 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/delivery.rb | 271 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 272 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/933530bb/proton-c/bindings/ruby/lib/core/delivery.rb -- diff --git a/proton-c/bindings/ruby/lib/core/delivery.rb b/proton-c/bindings/ruby/lib/core/delivery.rb new file mode 100644 index 000..5c0b25c --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/delivery.rb @@ -0,0 +1,271 @@ +#-- +# 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 Delivery maintains detail on the delivery of data to an endpoint. + # + # A Delivery has a single parent Qpid::Proton::Link + # + # @example + # + # # SCENARIO: An event comes in notifying that data has been delivered to + # # the local endpoint. A Delivery object can be used to check + # # the details of the delivery. + # + # delivery = @event.delivery + # if delivery.readable? && !delivery.partial? + # # decode the incoming message + # msg = Qpid::Proton::Message.new + # msg.decode(link.receive(delivery.pending)) + # end + # + class Delivery + +# @private +include Util::Wrapper + +# @private +def self.wrap(impl) # :nodoc: + return nil if impl.nil? + self.fetch_instance(impl, :pn_delivery_attachments) || Delivery.new(impl) +end + +# @private +def initialize(impl) + @impl = impl + @local = Disposition.new(Cproton.pn_delivery_local(impl), true) + @remote = Disposition.new(Cproton.pn_delivery_remote(impl), false) + self.class.store_instance(self, :pn_delivery_attachments) +end + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_delivery" + +# @!attribute [r] tag +# +# @return [String] The tag for the delivery. +# +proton_caller :tag + +# @!attribute [r] writable? +# +# A delivery is considered writable if it is the current delivery on an +# outgoing link, and the link has positive credit. +# +# @return [Boolean] Returns if a delivery is writable. +# +proton_caller :writable? + +# @!attribute [r] readable? +# +# A delivery is considered readable if it is the current delivery on an +# incoming link. +# +# @return [Boolean] Returns if a delivery is readable. +# +proton_caller :readable? +# @!attribute [r] updated? +# +# A delivery is considered updated whenever the peer communicates a new +# disposition for the dlievery. Once a delivery becomes updated, it will +# remain so until cleared. +# +# @return [Boolean] Returns if a delivery is updated. +# +# @see #clear +# +proton_caller :updated? + +# @!method clear +# +# Clear the updated flag for a delivery. +# +proton_caller :clear + +# @!attribute [r] pending +# +# @return [Fixnum] Return the amount of pending message data for the +# delivery. +# +proton_caller :pending + +# @!attribute [r] partial? +# +# @return [Boolean] Returns if the delivery has only partial message data. +# +proton_caller :partial? + +# @!attribute [r] settled? +# +# @return [Boolean] Returns if the delivery is remotely settled. +# +proton_caller :settled? + + +# @!method settle +# +# Settles a del
[09/25] qpid-proton git commit: PROTON-799: Added the UUID mixin for the Ruby reactive APIs.
PROTON-799: Added the UUID mixin for the Ruby reactive 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/bd01492b Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bd01492b Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bd01492b Branch: refs/heads/ruby-engine-apis Commit: bd01492b28cdad5a2f9d3a558534611eb0754c19 Parents: 681de76 Author: Darryl L. Pierce Authored: Thu Feb 26 11:29:07 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 3 +++ proton-c/bindings/ruby/lib/util/uuid.rb | 32 ++ 2 files changed, 35 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bd01492b/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 bcc7edd..80565dd 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -22,6 +22,8 @@ require "date" if RUBY_VERSION < "1.9" require "kconv" +else + require "securerandom" end # Exception classes @@ -33,6 +35,7 @@ require "util/error_handler" require "util/constants" require "util/swig_helper" require "util/engine" +require "util/uuid" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bd01492b/proton-c/bindings/ruby/lib/util/uuid.rb -- diff --git a/proton-c/bindings/ruby/lib/util/uuid.rb b/proton-c/bindings/ruby/lib/util/uuid.rb new file mode 100644 index 000..882715b --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/uuid.rb @@ -0,0 +1,32 @@ +#-- +# 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::Util + + module UUID + +def generate_uuid + # generate a UUID based on what APIs are available with the current + # version of Ruby + SecureRandom.uuid +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[16/25] qpid-proton git commit: PROTON-799: Added the Connection class to the Ruby engine APIs.
PROTON-799: Added the Connection 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/adc49301 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/adc49301 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/adc49301 Branch: refs/heads/ruby-engine-apis Commit: adc49301d1b558d3130db65da0351b7129507608 Parents: c0248d2 Author: Darryl L. Pierce Authored: Fri Jan 16 15:13:04 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/connection.rb | 328 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 329 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/adc49301/proton-c/bindings/ruby/lib/core/connection.rb -- diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb new file mode 100644 index 000..252193d --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/connection.rb @@ -0,0 +1,328 @@ +#-- +# 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 Connection option has at most one Qpid::Proton::Transport instance. + # + class Connection < Endpoint + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_connection" + +# @!attribute hostname +# +# @return [String] The AMQP hostname for the connection. +# +proton_accessor :hostname + +# @private +proton_reader :attachments + +attr_accessor :overrides +attr_accessor :session_policy + +# @private +include Util::Wrapper + +# @private +def self.wrap(impl) + return nil if impl.nil? + + self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl) +end + +# 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. +# +# @param impl [pn_connection_t] The pn_connection_t struct. +# +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 + +def overrides? + !@overrides.nil? +end + +def session_policy? + !@session_policy.nil? +end + +# This method is used when working within the context of an event. +# +# @return [Connection] The connection itself. +# +def connection + self +end + +# The Transport to which this connection is bound. +# +# @return [Transport] The transport, or nil if the Connection is unbound. +# +def transport + Transport.wrap(Cproton.pn_connection_transport(@impl)) +end + +# 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. +# +# @param collector [Event::Collector] The event collector. +# +def collect(collector) + if collector.nil? +Cproton.pn_connection_collect(@impl, nil) + else +Cproton.pn_connection_collect(@impl, collector.impl) + end + @collector = collector +end
[06/25] qpid-proton git commit: PROTON-799: Created a utility module for the Ruby Engine APIs.
PROTON-799: Created a utility module for 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/681de761 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/681de761 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/681de761 Branch: refs/heads/ruby-engine-apis Commit: 681de761ca17fa4e8a26859a47836ee253101e33 Parents: 779d72c Author: Darryl L. Pierce Authored: Tue Feb 24 13:38:50 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/engine.rb | 82 ++ 2 files changed, 83 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/681de761/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 f1b17ea..bcc7edd 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -32,6 +32,7 @@ require "util/version" require "util/error_handler" require "util/constants" require "util/swig_helper" +require "util/engine" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/681de761/proton-c/bindings/ruby/lib/util/engine.rb -- diff --git a/proton-c/bindings/ruby/lib/util/engine.rb b/proton-c/bindings/ruby/lib/util/engine.rb new file mode 100644 index 000..53aa672 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/engine.rb @@ -0,0 +1,82 @@ +#-- +# 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::Util + + # @private + module Engine + +# Convenience method to receive messages from a delivery. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# @param message [Qpid::Proton::Message] The message to use. +# +# @return [Qpid::Proton::Message] the message +# +def self.receive_message(delivery, msg = nil) + msg = Qpid::Proton::Message.new if msg.nil? + msg.decode(delivery.link.receive(delivery.pending)) + delivery.link.advance + return msg +end + +def data_to_object(data_impl) # :nodoc: + object = nil + unless data_impl.nil? +data = Qpid::Proton::Codec::Data.new(data_impl) +data.rewind +data.next +object = data.object +data.rewind + end + return object +end + +def object_to_data(object, data_impl) # :nodoc: + unless object.nil? +data = Data.new(data_impl) +data.object = object + end +end + +def condition_to_object(condition) # :nodoc: + result = nil + if Cproton.pn_condition_is_set(condition) +result = Condition.new(Cproton.pn_condition_get_name(condition), + Cproton.pn_condition_get_description(condition), + data_to_object(Cproton.pn_condition_info(condition))) + end + return result +end + +def object_to_condition(object, condition) # :nodoc: + Cproton.pn_condition_clear(condition) + unless object.nil? +Cproton.pn_condition_set_name(condition, object.name) +Cproton.pn_condition_set_description(condition, object.description) +info = Data.new(Cproton.pn_condition_info(condition)) +if object.info? + info.object = object.info +end + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[07/25] qpid-proton git commit: PROTON-799: Added the Disposition class to the Ruby engine APIs.
PROTON-799: Added the Disposition 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/2eb09d4f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2eb09d4f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2eb09d4f Branch: refs/heads/ruby-engine-apis Commit: 2eb09d4fab72239981e7d6eac67c23b407b47b79 Parents: 8044d18 Author: Darryl L. Pierce Authored: Tue Jan 20 14:31:59 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/disposition.rb | 158 proton-c/bindings/ruby/lib/core/exceptions.rb | 10 ++ 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/2eb09d4f/proton-c/bindings/ruby/lib/core/disposition.rb -- diff --git a/proton-c/bindings/ruby/lib/core/disposition.rb b/proton-c/bindings/ruby/lib/core/disposition.rb new file mode 100644 index 000..20dafd7 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/disposition.rb @@ -0,0 +1,158 @@ +#-- +# 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 + + # Disposition records the current state and/or final outcome of a transfer. + # + # Every delivery contains both a local and a remote disposition. The local + # disposition holds the local state of the delivery, and the remote + # disposition holds the *last known* remote state of the delivery. + # + class Disposition + +include Util::Constants + +# Indicates the delivery was received. +self.add_constant(:RECEIVED, Cproton::PN_RECEIVED) +# Indicates the delivery was accepted. +self.add_constant(:ACCEPTED, Cproton::PN_ACCEPTED) +# Indicates the delivery was rejected. +self.add_constant(:REJECTED, Cproton::PN_REJECTED) +# Indicates the delivery was released. +self.add_constant(:RELEASED, Cproton::PN_RELEASED) +# Indicates the delivery was modified. +self.add_constant(:MODIFIED, Cproton::PN_MODIFIED) + +# @private +include Util::Engine + +attr_reader :impl + +# @private +def initialize(impl, local) + @impl = impl + @local = local + @data = nil + @condition = nil + @annotations = nil +end + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_disposition" + +# @!attribute section_number +# +# @return [Fixnum] The section number of the disposition. +# +proton_accessor :section_number + +# @!attribute section_offset +# +# @return [Fixnum] The section offset of the disposition. +# +proton_accessor :section_offset + +# @!attribute failed? +# +# @return [Boolean] The failed flag. +# +proton_accessor :failed, :is_or_get => :is + +# @!attribute undeliverable? +# +# @return [Boolean] The undeliverable flag. +# +proton_accessor :undeliverable, :is_or_get => :is + +# Sets the data for the disposition. +# +# @param data [Codec::Data] The data. +# +# @raise [AttributeError] If the disposition is remote. +# +def data=(data) + raise AttributeError.new("data attribute is read-only") unless @local + @data = data +end + +# Returns the data for the disposition. +# +# @return [Codec::Data] The data. +# +def data + if @local +@data + else +data_to_object(Cproton.pn_disposition_data(@impl)) + end +end + +# Sets the annotations for the disposition. +# +# @param annotations [Codec::Data] The annotations. +# +# @raise [AttributeError] If the disposition is remote. +# +def annotations=(annotations) + raise AttributeError.new("annotations attribute is read-only") unless @local + @annotations = annotations +end + +# Returns the annotations for the disposition. +# +# @return [Codec::Data] The
[24/25] qpid-proton git commit: PROTON-799: Added the SASLError and TransportError errors to Ruby.
PROTON-799: Added the SASLError and TransportError errors 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/eb95452b Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/eb95452b Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/eb95452b Branch: refs/heads/ruby-engine-apis Commit: eb95452b9bf59d43f17a08c770e3a94f4c0c5afc Parents: adc4930 Author: Darryl L. Pierce Authored: Tue Jan 20 16:09:45 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 5 + 1 file changed, 5 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/eb95452b/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 8dead61..714830b 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 instances of SASL +# +class SASLError < TransportError +end + # Raised by Session. # class SessionError < ProtonError - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[22/25] qpid-proton git commit: PROTON-799: Adjusted the Ruby error macro
PROTON-799: Adjusted the Ruby error macro Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ac28eddb Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ac28eddb Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ac28eddb Branch: refs/heads/ruby-engine-apis Commit: ac28eddb9f07c2bf7b06db78891338b34251e06c Parents: e61ae22 Author: Darryl L. Pierce Authored: Thu Feb 19 14:28:54 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/util/error_handler.rb | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ac28eddb/proton-c/bindings/ruby/lib/util/error_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/util/error_handler.rb b/proton-c/bindings/ruby/lib/util/error_handler.rb index 2f43609..da51214 100644 --- a/proton-c/bindings/ruby/lib/util/error_handler.rb +++ b/proton-c/bindings/ruby/lib/util/error_handler.rb @@ -41,7 +41,9 @@ module Qpid::Proton::Util end end -def can_raise_error(method_names, error_class = nil) +def can_raise_error(method_names, options = {}) + error_class = options[:error_class] + below = options[:below] || 0 # coerce the names to be an array Array(method_names).each do |method_name| # if the method doesn't already exist then queue this aliasing @@ -49,12 +51,12 @@ module Qpid::Proton::Util @@to_be_wrapped ||= [] @@to_be_wrapped << method_name else - create_exception_handler_wrapper(method_name, error_class) + create_exception_handler_wrapper(method_name, error_class, below) end end end -def create_exception_handler_wrapper(method_name, error_class = nil) +def create_exception_handler_wrapper(method_name, error_class = nil, below = 0) original_method_name = method_name.to_s wrapped_method_name = "_excwrap_#{original_method_name}" alias_method wrapped_method_name, original_method_name @@ -63,7 +65,8 @@ module Qpid::Proton::Util # calls to Class.send interfere with Messenger.send method = self.method(wrapped_method_name.to_sym) rc = method.call(*args, &block) -check_for_error(rc, error_class) +check_for_error(rc, error_class) if rc < below +return rc end end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[12/25] qpid-proton git commit: PROTON-799: Added the Terminus class to the Ruby engine APIs.
PROTON-799: Added the Terminus 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/8044d189 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8044d189 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8044d189 Branch: refs/heads/ruby-engine-apis Commit: 8044d189dcc1346eca1ad282ac83d5ea0bf1d500 Parents: 6c13caf Author: Darryl L. Pierce Authored: Mon Jan 19 15:15:49 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/terminus.rb | 218 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 219 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8044d189/proton-c/bindings/ruby/lib/core/terminus.rb -- diff --git a/proton-c/bindings/ruby/lib/core/terminus.rb b/proton-c/bindings/ruby/lib/core/terminus.rb new file mode 100644 index 000..4bd22d7 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/terminus.rb @@ -0,0 +1,218 @@ +#-- +# 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 + + # Represents an endpoint for an AMQP connection.. + # + # An AMQP terminus acts as either a source or a target for messages, + # but never as both. Every Link is associated iwth both a source and + # a target Terminus that is negotiated during link establishment. + # + # A terminus is composed of an AMQP address along with a number of + # other properties defining the quality of service and behavior of + # the Link. + # + class Terminus + +# Indicates a non-existent source or target terminus. +UNSPECIFIED = Cproton::PN_UNSPECIFIED +# Indicates a source for messages. +SOURCE = Cproton::PN_SOURCE +# Indicates a target for messages. +TARGET = Cproton::PN_TARGET +# A special target identifying a transaction coordinator. +COORDINATOR = Cproton::PN_COORDINATOR + +# The terminus is orphaned when the parent link is closed. +EXPIRE_WITH_LINK = Cproton::PN_EXPIRE_WITH_LINK +# The terminus is orphaned whent he parent sessio is closed. +EXPIRE_WITH_SESSION = Cproton::PN_EXPIRE_WITH_SESSION +# The terminus is orphaned when the parent connection is closed. +EXPIRE_WITH_CONNECTION = Cproton::PN_EXPIRE_WITH_CONNECTION +# The terminus is never considered orphaned. +EXPIRE_NEVER = Cproton::PN_EXPIRE_NEVER + +# Indicates a non-durable Terminus. +NONDURABLE = Cproton::PN_NONDURABLE +# Indicates a Terminus with durably held configuration, but +# not the delivery state. +CONFIGURATION = Cproton::PN_CONFIGURATION +# Indicates a Terminus with both durably held configuration and +# durably held delivery states. +DELIVERIES = Cproton::PN_DELIVERIES + +# The behavior is defined by the nod.e +DIST_MODE_UNSPECIFIED = Cproton::PN_DIST_MODE_UNSPECIFIED +# The receiver gets all messages. +DIST_MODE_COPY = Cproton::PN_DIST_MODE_COPY +# The receives compete for messages. +DIST_MODE_MOVE = Cproton::PN_DIST_MODE_MOVE + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_terminus" + +# @!attribute type +# +# @return [Fixnum] The terminus type. +# +# @see SOURCE +# @see TARGET +# @see COORDINATOR +# +proton_accessor :type + +# @!attribute address +# +# @return [String] The terminus address. +# +proton_accessor :address + +# @!attribute durability +# +# @return [Fixnum] The durability mode of the terminus. +# +# @see NONDURABLE +# @see CONFIGURATION +# @see DELIVERIES +# +proton_accessor :durability + +# @!attribute expiry_policy +# +# @return [Fixnum] The expiry policy. +# +# @see EXPIRE_WITH_LINK +# @see EXPIRE_WITH_SESSION +# @see EXPIRE_WITH_CONNECTION +# @see EXPIRE_NEVER +# +proton_accessor :expiry_policy + +# @!attribute timeout +
[14/25] qpid-proton git commit: PROTON-799: Test for the Wrapper and rbkey system
PROTON-799: Test for the Wrapper and rbkey system Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ed9ecab0 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ed9ecab0 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ed9ecab0 Branch: refs/heads/ruby-engine-apis Commit: ed9ecab074d87a2e37c3a1e91eaa0091763361f7 Parents: ac28edd Author: Darryl L. Pierce Authored: Thu May 14 15:57:02 2015 -0400 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- examples/ruby/wrapper_test.rb | 82 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 83 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ed9ecab0/examples/ruby/wrapper_test.rb -- diff --git a/examples/ruby/wrapper_test.rb b/examples/ruby/wrapper_test.rb new file mode 100644 index 000..ca7e250 --- /dev/null +++ b/examples/ruby/wrapper_test.rb @@ -0,0 +1,82 @@ +#-- +# 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. +#++ + +require 'qpid_proton' + +def how_many_transports?(expected) + count = ObjectSpace.each_object(Qpid::Proton::Transport).count + if expected.min == expected.max +expectation = "#{expected.min}" + else +expectation = "#{expected.min} <= count <= #{expected.max}" + end + puts "Transport count: found #{count}, expected #{expectation} (#{expected.include?(count) ? 'Good' : 'Bad'})" +end + +transport = Qpid::Proton::Transport.new +timpl = transport.impl + +puts "=" +puts "= Storing my original transport =" +puts "=" +puts " Stored transport=#{transport} (#{Cproton.pni_address_of(timpl).to_s(16)})" +how_many_transports?(1..1) +puts "=" +transport.instance_eval { @first_name = "Darryl"; @last_name = "Pierce", @instance_id = 717 } +transport = nil + + +puts "" +max = 1000 +puts "Creating #{max} instances of Transport" +(0...max).each do |which| + t = Qpid::Proton::Transport.new + t.instance_eval { @instance_id = which } + t = nil +end + +puts "" +puts "" +puts "= Retrieving my original transport =" +puts "" +transport = Qpid::Proton::Transport.wrap(timpl) +puts "Retrieved transport=#{transport} (#{Cproton.pni_address_of(timpl).to_s(16)})" +how_many_transports?(1..1001) +puts "" +puts "My transport attributes:" +puts transport + +transport = nil +GC.start +how_many_transports?(1..1) + +puts "" +puts "==" +puts "= Throwing away the Transport object =" +puts "==" +transport = nil +timpl.instance_eval { @proton_wrapper = nil } +GC.start +begin + transport = Qpid::Proton::Transport.wrap(timpl) + puts "!!! This should fail!" +rescue Qpid::Proton::ProtonError => error + puts "Good, it failed..." +end +how_many_transports?(0..0) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ed9ecab0/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 58b95d0..467d959 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -19,6 +19,7 @@ require "cproton" require "date" +require "weakref" if RUBY_VERSION < "1.9" require "kconv" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[20/25] qpid-proton git commit: PROTON-799: Added the Event classes to the Ruby engine APIs.
PROTON-799: Added the Event classes 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/059d552f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/059d552f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/059d552f Branch: refs/heads/ruby-engine-apis Commit: 059d552f62f4506d2fa597696845c60f497e4df7 Parents: 0d42056 Author: Darryl L. Pierce Authored: Tue Feb 3 17:17:18 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:50 2015 -0400 -- proton-c/bindings/ruby/lib/event/event.rb | 296 proton-c/bindings/ruby/lib/event/event_base.rb | 91 ++ proton-c/bindings/ruby/lib/event/event_type.rb | 71 + proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + 4 files changed, 461 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/059d552f/proton-c/bindings/ruby/lib/event/event.rb -- diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb new file mode 100644 index 000..dd5d869 --- /dev/null +++ b/proton-c/bindings/ruby/lib/event/event.rb @@ -0,0 +1,296 @@ +#-- +# 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 + + module Event + +# @private +def self.event_type(const_name, method_name = nil) # :nodoc: + unless Cproton.const_defined?(const_name) +raise RuntimeError.new("no such constant: #{const_name}") + end + + const_value = Cproton.const_get(const_name) + method_name = "on_#{const_name.to_s[3..-1]}".downcase if method_name.nil? + + EventType.new(const_value, method_name) +end + +# Defined as a programming convenience. No even of this type will ever +# be generated. +NONE = event_type(:PN_EVENT_NONE) + +# A timer event has occurred. +TIMER_TASK = event_type(:PN_TIMER_TASK) + +# A connection has been created. This is the first even that will ever +# be issued for a connection. +CONNECTION_INIT = event_type(:PN_CONNECTION_INIT) +# A conneciton has been bound toa transport. +CONNECTION_BOUND = event_type(:PN_CONNECTION_BOUND) +# A connection has been unbound from its transport. +CONNECTION_UNBOUND = event_type(:PN_CONNECTION_UNBOUND) +# A local connection endpoint has been opened. +CONNECTION_LOCAL_OPEN = event_type(:PN_CONNECTION_LOCAL_OPEN) +# A local connection endpoint has been closed. +CONNECTION_LOCAL_CLOSE = event_type(:PN_CONNECTION_LOCAL_CLOSE) +# A remote endpoint has opened its connection. +CONNECTION_REMOTE_OPEN = event_type(:PN_CONNECTION_REMOTE_OPEN) +# A remote endpoint has closed its connection. +CONNECTION_REMOTE_CLOSE = event_type(:PN_CONNECTION_REMOTE_CLOSE) +# A connection has been freed and any outstanding processing has been +# completed. This is the final event htat will ever be issued for a +# connection +CONNECTION_FINAL = event_type(:PN_CONNECTION_FINAL) + +# A session has been created. This is the first event that will ever be +# issues for a session. +SESSION_INIT = event_type(:PN_SESSION_INIT) +# A local session endpoint has been opened. +SESSION_LOCAL_OPEN = event_type(:PN_SESSION_LOCAL_OPEN) +# A local session endpoint has been closed. +SESSION_LOCAL_CLOSE = event_type(:PN_SESSION_LOCAL_CLOSE) +# A remote endpoint has opened its session. +SESSION_REMOTE_OPEN = event_type(:PN_SESSION_REMOTE_OPEN) +# A remote endpoint has closed its session. +SESSION_REMOTE_CLOSE = event_type(:PN_SESSION_REMOTE_CLOSE) +# A session has been freed and any outstanding processing has been +# completed. This is the final event that will ever be issued for a +# session +SESSION_FINAL = event_type(:PN_SESSION_FINAL) + +# A link has been created. This is the first event that will ever be +# issued for a link. +LINK_INIT = event_type(:PN_LINK_INIT) +# A local link endpoint has been open
[02/25] qpid-proton git commit: PROTON-799: Added the Link class to the Ruby engine APIs.
PROTON-799: Added the Link 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/c2f62c10 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c2f62c10 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c2f62c10 Branch: refs/heads/ruby-engine-apis Commit: c2f62c1075c7f0db9c893f6b9089efa502d03357 Parents: 933530b Author: Darryl L. Pierce Authored: Mon Jan 19 14:55:56 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/core/link.rb | 387 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 388 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c2f62c10/proton-c/bindings/ruby/lib/core/link.rb -- diff --git a/proton-c/bindings/ruby/lib/core/link.rb b/proton-c/bindings/ruby/lib/core/link.rb new file mode 100644 index 000..86a307a --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/link.rb @@ -0,0 +1,387 @@ +#-- +# 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 + + # The base for both Sender and Receiver, providing common functionality + # between both ends. + # + # A Link has a single parent Qpid::Proton::Session instance. + # + class Link < Endpoint + +# The sender will send all deliveries initially unsettled. +SND_UNSETTLED = Cproton::PN_SND_UNSETTLED +# The sender will send all deliveries settled to the receiver. +SND_SETTLED = Cproton::PN_SND_SETTLED +# The sender may send a mixture of settled and unsettled deliveries. +SND_MIXED = Cproton::PN_SND_MIXED + +# The receiver will settle deliveries regardless of what the sender does. +RCV_FIRST = Cproton::PN_RCV_FIRST +# The receiver will only settle deliveries after the sender settles. +RCV_SECOND = Cproton::PN_RCV_SECOND + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_link" + +# @!attribute [r] state +# +# Returns the endpoint state flags. +# +proton_caller :state + +# @!method open +# +# Opens the link. Once this operation has completed, the state flag will be +# set. +# +# @see Endpoint::LOCAL_ACTIVE +proton_caller :open + +# @!method close +# +# Closes the link. +# +# Once this operation has completed, the state flag will be set. +# This may be called without first calling #open, which is the equivalent to +# calling #open and then #close. +# +# @see Endpoint::LOCAL_CLOSED +proton_caller :close + +# @!method detach +# +# Detaches the link. +proton_caller :detach + +# Advance the current delivery to the next on the link. +# +# For sending links, this operation is used to finish sending message data +# for the current outgoing delivery and move on to the next outgoing +# delivery (if any). +# +# For receiving links, this operatoin is used to finish accessing message +# data from the current incoming delivery and move on to the next incoming +# delivery (if any). +# +# @return [Boolean] True if the current delivery was changed. +# +# @see #current +# +proton_caller :advance + +proton_caller :unsettled + +# @!attribute [r] credit +# +# Returns the credit balance for a link. +# +# Links use a credit based flow control scheme. Every receiver maintains a +# credit balance that corresponds to the number of deliveries that the +# receiver can accept at any given moment. +# +# As more capacity becomes available at the receiver, it adds credit to this +# balance and communicates the new balance to the sender. Whenever a +# delivery is sent/received, the credit balance maintained by the link is +# decremented by one. +# +# Once the credit balance at the sender reaches zero, the sender must pause +# sending until more credit
[10/25] qpid-proton git commit: PROTON-799: Added the Condition class to the Ruby engine APIs.
PROTON-799: Added the Condition 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/b2ea93bb Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b2ea93bb Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b2ea93bb Branch: refs/heads/ruby-engine-apis Commit: b2ea93bb8dd59e88bb176d6bd5917e31216e486f Parents: bd01492 Author: Darryl L. Pierce Authored: Mon Feb 16 15:33:30 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb| 1 + proton-c/bindings/ruby/lib/util/condition.rb | 45 +++ 2 files changed, 46 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b2ea93bb/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 80565dd..99d9dfc 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -34,6 +34,7 @@ require "util/version" require "util/error_handler" require "util/constants" require "util/swig_helper" +require "util/condition" require "util/engine" require "util/uuid" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b2ea93bb/proton-c/bindings/ruby/lib/util/condition.rb -- diff --git a/proton-c/bindings/ruby/lib/util/condition.rb b/proton-c/bindings/ruby/lib/util/condition.rb new file mode 100644 index 000..b8fd94b --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/condition.rb @@ -0,0 +1,45 @@ +#-- +# 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::Util + + class Condition + +def initialize(name, description = nil, info = nil) + @name = name + @description = description + @info = info +end + +# @private +def to_s + "Condition(#{@name}, #{@description}, #{@info})" +end + +# @private +def ==(other) + ((other.class = self.class) && + (other.name == self.name) && + (other.description == self.description) && + (other.info == self.info)) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[13/25] qpid-proton git commit: PROTON-799: Added the Session class to the Ruby engine APIs.
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/6c13caf5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6c13caf5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6c13caf5 Branch: refs/heads/ruby-engine-apis Commit: 6c13caf5c55261ac9f8db0536a155f2684c474e7 Parents: 642d319 Author: Darryl L. Pierce Authored: Tue Jan 20 10:37:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed May 20 11:34:49 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/6c13caf5/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/6c13caf5/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 000..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. +# +# W
[10/34] qpid-proton git commit: PROTON-799: Added the pn_rbkey_t type to the Ruby APIs.
PROTON-799: Added the pn_rbkey_t type to the Ruby APIs. The pn_rbkey_t type provides a way, from Ruby, to attach pure Ruby objects to Proton structs by means of an attachment. The type holds a reference to an registry object, a method to invoke on that object, and the value to pass to that method when invoked. This method is then called when the rbkey is finalized, with the goal of removing the referenced Ruby object so it can be safely garbage collected. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ff805e1e Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ff805e1e Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ff805e1e Branch: refs/heads/master Commit: ff805e1e5b234712dddc3e2cd7d892edd0b9187c Parents: 0530d1a Author: Darryl L. Pierce Authored: Fri Mar 6 09:36:35 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 22 +++ proton-c/bindings/ruby/ruby.i | 82 ++ 2 files changed, 104 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ff805e1e/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 da9983c..28a83aa 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -53,3 +53,25 @@ require "messenger/tracker_status" require "messenger/tracker" require "messenger/selectable" require "messenger/messenger" + +module Qpid::Proton + # @private + def self.registry +@registry ||= {} + end + + # @private + def self.add_to_registry(key, value) +self.registry[key] = value + end + + # @private + def self.get_from_registry(key) +self.registry[key] + end + + # @private + def self.delete_from_registry(key) +self.registry.delete(key) + end +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ff805e1e/proton-c/bindings/ruby/ruby.i -- diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i index 7205f57..50f9abe 100644 --- a/proton-c/bindings/ruby/ruby.i +++ b/proton-c/bindings/ruby/ruby.i @@ -465,4 +465,86 @@ bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZ %ignore pn_messenger_recv; %ignore pn_messenger_work; +%inline %{ + +#define CID_pn_rbkey CID_pn_void + +typedef struct { + void *registry; + char *method; + char *key_value; +} pn_rbkey_t; + +void pn_rbkey_initialize(pn_rbkey_t *rbkey) { + assert(rbkey); + rbkey->registry = NULL; + rbkey->method = NULL; + rbkey->key_value = NULL; +} + +void pn_rbkey_finalize(pn_rbkey_t *rbkey) { + if(rbkey && rbkey->registry && rbkey->method && rbkey->key_value) { +rb_funcall((VALUE )rbkey->registry, rb_intern(rbkey->method), 1, rb_str_new2(rbkey->key_value)); + } + if(rbkey->key_value) { +free(rbkey->key_value); +rbkey->key_value = NULL; + } +} + +#define pn_rbkey_inspect NULL +#define pn_rbkey_compare NULL +#define pn_rbkey_hashcode NULL + +PN_CLASSDEF(pn_rbkey) + +void pn_rbkey_set_registry(pn_rbkey_t *rbkey, void *registry) { + assert(rbkey); + rbkey->registry = registry; +} + +void *pn_rbkey_get_registry(pn_rbkey_t *rbkey) { + assert(rbkey); + return rbkey->registry; +} + +void pn_rbkey_set_method(pn_rbkey_t *rbkey, char *method) { + assert(rbkey); + rbkey->method = method; +} + +char *pn_rbkey_get_method(pn_rbkey_t *rbkey) { + assert(rbkey); + return rbkey->method; +} + +void pn_rbkey_set_key_value(pn_rbkey_t *rbkey, char *key_value) { + assert(rbkey); + rbkey->key_value = malloc(strlen(key_value) + 1); + strncpy(rbkey->key_value, key_value, strlen(key_value) + 1); +} + +char *pn_rbkey_get_key_value(pn_rbkey_t *rbkey) { + assert(rbkey); + return rbkey->key_value; +} + +pn_rbkey_t *pni_void2rbkey(void *object) { + return (pn_rbkey_t *)object; +} + +VALUE pn_void2rb(void *object) { + return (VALUE )object; +} + +void *pn_rb2void(VALUE object) { + return (void *)object; +} + +VALUE pni_address_of(void *object) { + return ULL2NUM((unsigned long )object); +} + +%} + %include "proton/cproton.i" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[02/34] qpid-proton git commit: PROTON-799: Updated the Ruby namespaces.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/messenger/tracker_status.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb index 81c9ea3..6eea9ce 100644 --- a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb +++ b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb @@ -17,57 +17,53 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Messenger - module Proton # :nodoc: + # TrackerStatus contains symbols that represent the status value for a + # Tracker. + # + class TrackerStatus -# TrackerStatus contains symbols that represent the status value for a -# Tracker. -# -class TrackerStatus - -def initialize value, name # :nodoc: - @value = value - @name = name -end - -def value # :nodoc: - @value -end - -def to_s # :nodoc: - @name.to_s -end +def initialize value, name # :nodoc: + @value = value + @name = name +end - def self.by_name(name) # :nodoc: - @by_name[name.to_sym] unless name.nil? -end +def value # :nodoc: + @value +end -def self.by_value(value) # :nodoc: - @by_value[value] unless value.nil? -end +def to_s # :nodoc: + @name.to_s +end -private +def self.by_name(name) # :nodoc: + @by_name[name.to_sym] unless name.nil? +end -def self.add_item(key, value) # :nodoc: - @by_name ||= {} - @by_name[key] = TrackerStatus.new value, key - @by_value ||= {} - @by_value[value] = @by_name[key] -end +def self.by_value(value) # :nodoc: + @by_value[value] unless value.nil? +end -def self.const_missing(key) # :nodoc: - @by_name[key] -end +private -self.add_item :UNKNOWN, Cproton::PN_STATUS_UNKNOWN -self.add_item :PENDING, Cproton::PN_STATUS_PENDING -self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED -self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED -self.add_item :SETTLED, Cproton::PN_STATUS_SETTLED +def self.add_item(key, value) # :nodoc: + @by_name ||= {} + @by_name[key] = TrackerStatus.new value, key + @by_value ||= {} + @by_value[value] = @by_name[key] +end +def self.const_missing(key) # :nodoc: + @by_name[key] end +self.add_item :UNKNOWN, Cproton::PN_STATUS_UNKNOWN +self.add_item :PENDING, Cproton::PN_STATUS_PENDING +self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED +self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED +self.add_item :SETTLED, Cproton::PN_STATUS_SETTLED + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/array.rb -- diff --git a/proton-c/bindings/ruby/lib/types/array.rb b/proton-c/bindings/ruby/lib/types/array.rb index a4294a3..5677295 100644 --- a/proton-c/bindings/ruby/lib/types/array.rb +++ b/proton-c/bindings/ruby/lib/types/array.rb @@ -22,38 +22,37 @@ # to a Qpid::Proton::Data instance. #++ -module Qpid # :nodoc: - - module Proton # :nodoc: - -# Holds the information for an AMQP Array compound type. -# -# It holds the type for the array and the descriptor if the -# array is described. -# -class ArrayHeader - attr_reader :type - attr_reader :descriptor - - def initialize(type, descriptor = nil) -@type = type -@descriptor = descriptor - end +module Qpid::Proton::Types - # Returns true if the array is described. - def described? -!@descriptor.nil? - end + # Holds the information for an AMQP Array compound type. + # + # It holds the type for the array and the descriptor if the + # array is described. + # + # @private + # + class ArrayHeader +attr_reader :type +attr_reader :descriptor - def ==(that) -((@type == that.type) && (@descriptor == that.descriptor)) - end +def initialize(type, descriptor = nil) + @type = type + @descriptor = descriptor +end + +# Returns true if the array is described. +def described? + !@descriptor.nil? end +def ==(that) + ((@type == that.type) && (@descriptor == that.descriptor)) +end end end +# @private class Array # :nodoc: # Used to declare an array as an AMQP array. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/described.rb -- diff --git a/proton-c/bindings/ruby/lib/types/described.rb b/proton-c/bindings/ruby/lib/types/described.rb index 98679c2..ca9fa24 100644 --- a/prot
[04/34] qpid-proton git commit: PROTON-799: Updated the Ruby namespaces.
PROTON-799: Updated the Ruby namespaces. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/31c3a764 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/31c3a764 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/31c3a764 Branch: refs/heads/master Commit: 31c3a76403ce3f31e96ff11deca99be2cdbc2da9 Parents: 81a5449 Author: Darryl L. Pierce Authored: Wed Apr 29 16:08:50 2015 -0400 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:20 2015 -0400 -- examples/ruby/messenger/client.rb |2 +- examples/ruby/messenger/mailserver.rb |3 +- examples/ruby/messenger/passive_recv.rb |2 +- examples/ruby/messenger/recv.rb |2 +- examples/ruby/messenger/send.rb |2 +- proton-c/bindings/ruby/lib/codec/data.rb| 1487 ++ proton-c/bindings/ruby/lib/codec/mapping.rb | 247 ++- proton-c/bindings/ruby/lib/core/exceptions.rb |4 +- proton-c/bindings/ruby/lib/core/message.rb | 1060 +++-- proton-c/bindings/ruby/lib/messenger/filters.rb | 59 +- .../bindings/ruby/lib/messenger/messenger.rb| 1222 +++--- .../bindings/ruby/lib/messenger/selectable.rb | 200 ++- .../bindings/ruby/lib/messenger/subscription.rb | 24 +- proton-c/bindings/ruby/lib/messenger/tracker.rb | 24 +- .../ruby/lib/messenger/tracker_status.rb| 76 +- proton-c/bindings/ruby/lib/types/array.rb | 47 +- proton-c/bindings/ruby/lib/types/described.rb | 69 +- proton-c/bindings/ruby/lib/types/hash.rb|3 +- proton-c/bindings/ruby/lib/types/strings.rb | 67 +- .../bindings/ruby/lib/util/error_handler.rb | 139 +- proton-c/bindings/ruby/lib/util/version.rb | 16 +- 21 files changed, 2420 insertions(+), 2335 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/examples/ruby/messenger/client.rb -- diff --git a/examples/ruby/messenger/client.rb b/examples/ruby/messenger/client.rb index 571744c..a2c2564 100644 --- a/examples/ruby/messenger/client.rb +++ b/examples/ruby/messenger/client.rb @@ -68,7 +68,7 @@ def log(text) printf "#{Time.new}: #{text}\n" if $options[:verbose] end -msgr = Qpid::Proton::Messenger.new +msgr = Qpid::Proton::Messenger::Messenger.new msgr.start msg = Qpid::Proton::Message.new http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/examples/ruby/messenger/mailserver.rb -- diff --git a/examples/ruby/messenger/mailserver.rb b/examples/ruby/messenger/mailserver.rb index 2d353ca..594a0e3 100644 --- a/examples/ruby/messenger/mailserver.rb +++ b/examples/ruby/messenger/mailserver.rb @@ -50,7 +50,7 @@ def log(text) STDOUT.puts "#{Time.new}: #{text}" if $options[:verbose] end -msgr = Qpid::Proton::Messenger.new +msgr = Qpid::Proton::Messenger::Messenger.new msgr.start $options[:address].each {|addr| msgr.subscribe(addr)} @@ -82,4 +82,3 @@ loop do end msgr.stop - http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/examples/ruby/messenger/passive_recv.rb -- diff --git a/examples/ruby/messenger/passive_recv.rb b/examples/ruby/messenger/passive_recv.rb index a3625ac..d1fa854 100644 --- a/examples/ruby/messenger/passive_recv.rb +++ b/examples/ruby/messenger/passive_recv.rb @@ -31,7 +31,7 @@ end addresses = ["~0.0.0.0"] if addresses.empty? -messenger = Qpid::Proton::Messenger.new +messenger = Qpid::Proton::Messenger::Messenger.new messenger.passive = true begin http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/examples/ruby/messenger/recv.rb -- diff --git a/examples/ruby/messenger/recv.rb b/examples/ruby/messenger/recv.rb index 4e464f1..960de4d 100644 --- a/examples/ruby/messenger/recv.rb +++ b/examples/ruby/messenger/recv.rb @@ -31,7 +31,7 @@ end addresses = ["~0.0.0.0"] if addresses.empty? -messenger = Qpid::Proton::Messenger.new +messenger = Qpid::Proton::Messenger::Messenger.new begin messenger.start http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/examples/ruby/messenger/send.rb -- diff --git a/examples/ruby/messenger/send.rb b/examples/ruby/messenger/send.rb index 81ce733..bdbeb4d 100644 --- a/examples/ruby/messenger/send.rb +++ b/examples/ruby/messenger/send.rb @@ -37,7 +37,7 @@ end options[:address] = "0.0.0.0" unless options[:address] messages << "Hello world!" if messages.empty? -messenger = Qpid::Proton::Messenger.new +messenger = Qpid::Proton:
[08/34] qpid-proton git commit: PROTON-799: Added the Condition class to the Ruby engine APIs.
PROTON-799: Added the Condition 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/b846f253 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b846f253 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b846f253 Branch: refs/heads/master Commit: b846f25336afd4ee8b77473158e9ccc11c0ebedc Parents: 8344ba6 Author: Darryl L. Pierce Authored: Mon Feb 16 15:33:30 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb| 1 + proton-c/bindings/ruby/lib/util/condition.rb | 45 +++ 2 files changed, 46 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b846f253/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 80565dd..99d9dfc 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -34,6 +34,7 @@ require "util/version" require "util/error_handler" require "util/constants" require "util/swig_helper" +require "util/condition" require "util/engine" require "util/uuid" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b846f253/proton-c/bindings/ruby/lib/util/condition.rb -- diff --git a/proton-c/bindings/ruby/lib/util/condition.rb b/proton-c/bindings/ruby/lib/util/condition.rb new file mode 100644 index 000..b8fd94b --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/condition.rb @@ -0,0 +1,45 @@ +#-- +# 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::Util + + class Condition + +def initialize(name, description = nil, info = nil) + @name = name + @description = description + @info = info +end + +# @private +def to_s + "Condition(#{@name}, #{@description}, #{@info})" +end + +# @private +def ==(other) + ((other.class = self.class) && + (other.name == self.name) && + (other.description == self.description) && + (other.info == self.info)) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[01/34] qpid-proton git commit: PROTON-799: Added the object/object= methods to Ruby Data class
Repository: qpid-proton Updated Branches: refs/heads/master 78b4873f5 -> cedb47633 PROTON-799: Added the object/object= methods to Ruby Data class Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8359e417 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8359e417 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8359e417 Branch: refs/heads/master Commit: 8359e417626043008932c183713e6f7d764d Parents: 31c3a76 Author: Darryl L. Pierce Authored: Mon Feb 16 15:33:08 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:20 2015 -0400 -- proton-c/bindings/ruby/lib/codec/data.rb | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8359e417/proton-c/bindings/ruby/lib/codec/data.rb -- diff --git a/proton-c/bindings/ruby/lib/codec/data.rb b/proton-c/bindings/ruby/lib/codec/data.rb index 69e9ed1..efefa99 100644 --- a/proton-c/bindings/ruby/lib/codec/data.rb +++ b/proton-c/bindings/ruby/lib/codec/data.rb @@ -96,13 +96,13 @@ module Qpid::Proton::Codec end # destructor - ObjectSpace.define_finalizer(self, self.class.finalize!(@data)) + ObjectSpace.define_finalizer(self, self.class.finalize!(@data, @free)) end # @private -def self.finalize!(data) +def self.finalize!(data, free) proc { -Cproton.pn_data_free(data) if @free +Cproton.pn_data_free(data) if free } end @@ -441,6 +441,27 @@ module Qpid::Proton::Codec null end +# Puts an arbitrary object type. +# +# The Data instance will determine which AMQP type is appropriate and will +# use that to encode the object. +# +# @param object [Object] The value. +# +def object=(object) + Mapping.for_class(object.class).put(self, object) +end + +# Gets the current node, based on how it was encoded. +# +# @return [Object] The current node. +# +def object + type = self.type + return nil if type.nil? + type.get(data) +end + # Checks if the current node is null. # # @return [Boolean] True if the node is null. - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[30/34] qpid-proton git commit: PROTON-799: Added the SASLError and TransportError errors to Ruby.
PROTON-799: Added the SASLError and TransportError errors 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/8f38c7ab Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8f38c7ab Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8f38c7ab Branch: refs/heads/master Commit: 8f38c7ab02801bbf400f6fca4cb274d9df776059 Parents: 5d9505d Author: Darryl L. Pierce Authored: Tue Jan 20 16:09:45 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 5 + 1 file changed, 5 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8f38c7ab/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 8dead61..714830b 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 instances of SASL +# +class SASLError < TransportError +end + # Raised by Session. # class SessionError < ProtonError - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[24/34] qpid-proton git commit: PROTON-799: Added the Transport class to the Ruby engine APIs.
PROTON-799: Added the Transport 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/cf0e1094 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cf0e1094 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cf0e1094 Branch: refs/heads/master Commit: cf0e1094193e54df6b5086430255ae59b616cf56 Parents: a813f6a Author: Darryl L. Pierce Authored: Wed Jan 14 09:31:46 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 5 + proton-c/bindings/ruby/lib/core/transport.rb | 412 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 3 files changed, 418 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf0e1094/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 2695709..94d2957 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 instances of Transport. +# +class TransportError < ProtonError +end + # Raised by instances of SASL # class SASLError < TransportError http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf0e1094/proton-c/bindings/ruby/lib/core/transport.rb -- diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb new file mode 100644 index 000..206f97d --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/transport.rb @@ -0,0 +1,412 @@ +#-- +# 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 transport is used by a connection to interface with the network. + # + # A transport is associated with, at most, one Connection. + # + # == Client And Server Mode + # + # Initially, a transport is configured to be a client tranpsort. It can be + # configured to act as a server when it is created. + # + # A client transport initiates outgoing connections. + # + # A client transport must be configured with the protocol layers to use and + # cannot configure itself automatically. + # + # A server transport accepts incoming connections. It can automatically + # configure itself to include the various protocol layers depending on the + # incoming protocol headers. + # + # == Tracing Data + # + # Data can be traced into and out of the transport programmatically by setting + # the #trace level to one of the defined trace values (TRACE_RAW, TRACE_FRM or + # TRACE_DRV). Tracing can also be turned off programmatically by setting the + # #trace level to TRACE_OFF. + # + # @example + # + # # turns on frame tracing + # @transport.trace = Qpid::Proton::Transport::TRACE_FRM + # + # # ... do something where the frames are of interest, such as debugging + # + # # turn tracing off again + # @transport.trace = Qpid::Proton::Transport::TRACE_NONE + # + # Tracing can also be enabled from the command line by defining the similarly + # named environment variable before starting a Proton application: + # + # @example + # + # # enable tracing from the command line + # PN_TRACE_FRM=1 ruby my_proton_app.rb + # + class Transport + +# @private +include Util::Engine + +# Turn logging off entirely. +TRACE_OFF = Cproton::PN_TRACE_OFF +# Log raw binary data into/out of the transport. +TRACE_RAW = Cproton::PN_TRACE_RAW +# Log frames into/out of the transport. +TRACE_FRM = Cproton::PN_TRACE_FRM +# Log driver related events; i.e., initialization, end of stream, etc. +TRACE_DRV = Cproton::PN_TRACE_DRV + +# @private +CLIENT = 1 +# @private +SERVER = 2 + +# @private +include Util::SwigHelper
[15/34] qpid-proton git commit: PROTON-799: Added the Wrapper mixin to the Ruby engine APIs.
PROTON-799: Added the Wrapper mixin 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/38ce7eec Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/38ce7eec Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/38ce7eec Branch: refs/heads/master Commit: 38ce7eec6ec2e0ba818ac9df6f6da696ef358b62 Parents: b846f25 Author: Darryl L. Pierce Authored: Fri Jan 16 16:06:44 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:22 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/wrapper.rb | 124 2 files changed, 125 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38ce7eec/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 99d9dfc..507b61f 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -35,6 +35,7 @@ require "util/error_handler" require "util/constants" require "util/swig_helper" require "util/condition" +require "util/wrapper" require "util/engine" require "util/uuid" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38ce7eec/proton-c/bindings/ruby/lib/util/wrapper.rb -- diff --git a/proton-c/bindings/ruby/lib/util/wrapper.rb b/proton-c/bindings/ruby/lib/util/wrapper.rb new file mode 100644 index 000..a2df413 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/wrapper.rb @@ -0,0 +1,124 @@ +#-- +# 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::Util + + # @private + module Wrapper + +# @private +def impl=(impl) + @impl = impl +end + +# @private +def impl + @impl +end + +def self.registry + @registry ||= {} +end + +def self.included(base) + base.extend(ClassMethods) +end + +# Adds methods to the target class for storing and retrieving pure Ruby +# wrappers to underlying Proton structures. +# +# Such wrappers are stored in a registry using a key. The key is then +# attached to the Proton structure as a record. That record lives for as +# long as the Proton structure lives, and when the structure is released +# the record acts as hook to also delete the Ruby wrapper object from the +# registry. +# +# @private +# +module ClassMethods + + # @private + def get_key(impl) +("%032x" % Cproton.pni_address_of(impl)) + end + + # Stores the given object for later retrieval. + # + # @param object [Object] The object. + # @param attachment_method [Symbol] The Proton attachment method. + # + def store_instance(object, attachment_method = nil) +# ensure the impl has a reference to the wrapper object +object.impl.instance_eval { @proton_wrapper = object } +registry_key = get_key(object.impl) +unless attachment_method.nil? + record = Cproton.__send__(attachment_method, object.impl) + rbkey = Cproton.pn_rbkey_new + Cproton.pn_rbkey_set_registry(rbkey, Cproton.pn_rb2void(Qpid::Proton::Util::Wrapper.registry)) + Cproton.pn_rbkey_set_method(rbkey, "delete") + Cproton.pn_rbkey_set_key_value(rbkey, registry_key) + Cproton.pn_record_def(record, RBCTX, Cproton.pn_rbkey__class()); + Cproton.pn_record_set(record, RBCTX, rbkey) +end +Qpid::Proton::Util::Wrapper.registry[registry_key] = object + end + + # Retrieves the wrapper object with the supplied Proton struct. + # + # @param impl [Object] The wrapper for the Proton struct. + # @param attachment_method [Symbol] The Proton attachment method. + # + # @return [Object] The Ruby wrapper object. + # + def fetch_instance(impl, attachment_meth
[21/34] qpid-proton git commit: PROTON-799: Added the Disposition class to the Ruby engine APIs.
PROTON-799: Added the Disposition 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/6057afec Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6057afec Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6057afec Branch: refs/heads/master Commit: 6057afec7fc9ef926818b4697f21ee14295696f7 Parents: 6a4e6a6 Author: Darryl L. Pierce Authored: Tue Jan 20 14:31:59 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/disposition.rb | 158 proton-c/bindings/ruby/lib/core/exceptions.rb | 10 ++ 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/6057afec/proton-c/bindings/ruby/lib/core/disposition.rb -- diff --git a/proton-c/bindings/ruby/lib/core/disposition.rb b/proton-c/bindings/ruby/lib/core/disposition.rb new file mode 100644 index 000..20dafd7 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/disposition.rb @@ -0,0 +1,158 @@ +#-- +# 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 + + # Disposition records the current state and/or final outcome of a transfer. + # + # Every delivery contains both a local and a remote disposition. The local + # disposition holds the local state of the delivery, and the remote + # disposition holds the *last known* remote state of the delivery. + # + class Disposition + +include Util::Constants + +# Indicates the delivery was received. +self.add_constant(:RECEIVED, Cproton::PN_RECEIVED) +# Indicates the delivery was accepted. +self.add_constant(:ACCEPTED, Cproton::PN_ACCEPTED) +# Indicates the delivery was rejected. +self.add_constant(:REJECTED, Cproton::PN_REJECTED) +# Indicates the delivery was released. +self.add_constant(:RELEASED, Cproton::PN_RELEASED) +# Indicates the delivery was modified. +self.add_constant(:MODIFIED, Cproton::PN_MODIFIED) + +# @private +include Util::Engine + +attr_reader :impl + +# @private +def initialize(impl, local) + @impl = impl + @local = local + @data = nil + @condition = nil + @annotations = nil +end + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_disposition" + +# @!attribute section_number +# +# @return [Fixnum] The section number of the disposition. +# +proton_accessor :section_number + +# @!attribute section_offset +# +# @return [Fixnum] The section offset of the disposition. +# +proton_accessor :section_offset + +# @!attribute failed? +# +# @return [Boolean] The failed flag. +# +proton_accessor :failed, :is_or_get => :is + +# @!attribute undeliverable? +# +# @return [Boolean] The undeliverable flag. +# +proton_accessor :undeliverable, :is_or_get => :is + +# Sets the data for the disposition. +# +# @param data [Codec::Data] The data. +# +# @raise [AttributeError] If the disposition is remote. +# +def data=(data) + raise AttributeError.new("data attribute is read-only") unless @local + @data = data +end + +# Returns the data for the disposition. +# +# @return [Codec::Data] The data. +# +def data + if @local +@data + else +data_to_object(Cproton.pn_disposition_data(@impl)) + end +end + +# Sets the annotations for the disposition. +# +# @param annotations [Codec::Data] The annotations. +# +# @raise [AttributeError] If the disposition is remote. +# +def annotations=(annotations) + raise AttributeError.new("annotations attribute is read-only") unless @local + @annotations = annotations +end + +# Returns the annotations for the disposition. +# +# @return [Codec::Data] The annotations
[14/34] qpid-proton git commit: PROTON-799: Created a utility module for the Ruby Engine APIs.
PROTON-799: Created a utility module for 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/bab61a22 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bab61a22 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bab61a22 Branch: refs/heads/master Commit: bab61a22af652e743e2b4a561ee782dae4cdfb38 Parents: 3a64230 Author: Darryl L. Pierce Authored: Tue Feb 24 13:38:50 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/engine.rb | 82 ++ 2 files changed, 83 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bab61a22/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 f1b17ea..bcc7edd 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -32,6 +32,7 @@ require "util/version" require "util/error_handler" require "util/constants" require "util/swig_helper" +require "util/engine" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bab61a22/proton-c/bindings/ruby/lib/util/engine.rb -- diff --git a/proton-c/bindings/ruby/lib/util/engine.rb b/proton-c/bindings/ruby/lib/util/engine.rb new file mode 100644 index 000..53aa672 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/engine.rb @@ -0,0 +1,82 @@ +#-- +# 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::Util + + # @private + module Engine + +# Convenience method to receive messages from a delivery. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# @param message [Qpid::Proton::Message] The message to use. +# +# @return [Qpid::Proton::Message] the message +# +def self.receive_message(delivery, msg = nil) + msg = Qpid::Proton::Message.new if msg.nil? + msg.decode(delivery.link.receive(delivery.pending)) + delivery.link.advance + return msg +end + +def data_to_object(data_impl) # :nodoc: + object = nil + unless data_impl.nil? +data = Qpid::Proton::Codec::Data.new(data_impl) +data.rewind +data.next +object = data.object +data.rewind + end + return object +end + +def object_to_data(object, data_impl) # :nodoc: + unless object.nil? +data = Data.new(data_impl) +data.object = object + end +end + +def condition_to_object(condition) # :nodoc: + result = nil + if Cproton.pn_condition_is_set(condition) +result = Condition.new(Cproton.pn_condition_get_name(condition), + Cproton.pn_condition_get_description(condition), + data_to_object(Cproton.pn_condition_info(condition))) + end + return result +end + +def object_to_condition(object, condition) # :nodoc: + Cproton.pn_condition_clear(condition) + unless object.nil? +Cproton.pn_condition_set_name(condition, object.name) +Cproton.pn_condition_set_description(condition, object.description) +info = Data.new(Cproton.pn_condition_info(condition)) +if object.info? + info.object = object.info +end + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[16/34] qpid-proton git commit: PROTON-799: Added the Delivery class to the Ruby engine APIs.
PROTON-799: Added the Delivery 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/aa04b944 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/aa04b944 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/aa04b944 Branch: refs/heads/master Commit: aa04b944cac70a83533083d64007f652e9e299cf Parents: 6057afe Author: Darryl L. Pierce Authored: Tue Jan 20 11:10:34 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/delivery.rb | 271 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 272 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aa04b944/proton-c/bindings/ruby/lib/core/delivery.rb -- diff --git a/proton-c/bindings/ruby/lib/core/delivery.rb b/proton-c/bindings/ruby/lib/core/delivery.rb new file mode 100644 index 000..5c0b25c --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/delivery.rb @@ -0,0 +1,271 @@ +#-- +# 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 Delivery maintains detail on the delivery of data to an endpoint. + # + # A Delivery has a single parent Qpid::Proton::Link + # + # @example + # + # # SCENARIO: An event comes in notifying that data has been delivered to + # # the local endpoint. A Delivery object can be used to check + # # the details of the delivery. + # + # delivery = @event.delivery + # if delivery.readable? && !delivery.partial? + # # decode the incoming message + # msg = Qpid::Proton::Message.new + # msg.decode(link.receive(delivery.pending)) + # end + # + class Delivery + +# @private +include Util::Wrapper + +# @private +def self.wrap(impl) # :nodoc: + return nil if impl.nil? + self.fetch_instance(impl, :pn_delivery_attachments) || Delivery.new(impl) +end + +# @private +def initialize(impl) + @impl = impl + @local = Disposition.new(Cproton.pn_delivery_local(impl), true) + @remote = Disposition.new(Cproton.pn_delivery_remote(impl), false) + self.class.store_instance(self, :pn_delivery_attachments) +end + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_delivery" + +# @!attribute [r] tag +# +# @return [String] The tag for the delivery. +# +proton_caller :tag + +# @!attribute [r] writable? +# +# A delivery is considered writable if it is the current delivery on an +# outgoing link, and the link has positive credit. +# +# @return [Boolean] Returns if a delivery is writable. +# +proton_caller :writable? + +# @!attribute [r] readable? +# +# A delivery is considered readable if it is the current delivery on an +# incoming link. +# +# @return [Boolean] Returns if a delivery is readable. +# +proton_caller :readable? +# @!attribute [r] updated? +# +# A delivery is considered updated whenever the peer communicates a new +# disposition for the dlievery. Once a delivery becomes updated, it will +# remain so until cleared. +# +# @return [Boolean] Returns if a delivery is updated. +# +# @see #clear +# +proton_caller :updated? + +# @!method clear +# +# Clear the updated flag for a delivery. +# +proton_caller :clear + +# @!attribute [r] pending +# +# @return [Fixnum] Return the amount of pending message data for the +# delivery. +# +proton_caller :pending + +# @!attribute [r] partial? +# +# @return [Boolean] Returns if the delivery has only partial message data. +# +proton_caller :partial? + +# @!attribute [r] settled? +# +# @return [Boolean] Returns if the delivery is remotely settled. +# +proton_caller :settled? + + +# @!method settle +# +# Settles a delivery. +
[12/34] qpid-proton git commit: PROTON-799: Added a constants value mixin to the Ruby bindings.
PROTON-799: Added a constants value mixin to the Ruby bindings. The purpose of this mixin is to make it easier to create classes that represent constant values from the Proton C code. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/57deee4d Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/57deee4d Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/57deee4d Branch: refs/heads/master Commit: 57deee4d6e5336b783b9ec14c8abb3107f707d39 Parents: 8359e41 Author: Darryl L. Pierce Authored: Tue Feb 10 15:22:05 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb| 1 + proton-c/bindings/ruby/lib/util/constants.rb | 85 +++ 2 files changed, 86 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/57deee4d/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 e8fab77..e90df84 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -30,6 +30,7 @@ require "core/exceptions" # Utility classes require "util/version" require "util/error_handler" +require "util/constants" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/57deee4d/proton-c/bindings/ruby/lib/util/constants.rb -- diff --git a/proton-c/bindings/ruby/lib/util/constants.rb b/proton-c/bindings/ruby/lib/util/constants.rb new file mode 100644 index 000..50225e6 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/constants.rb @@ -0,0 +1,85 @@ +#-- +# 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::Util + + # Provides a means for defining constant values within the namespace + # of a class. + # + # If the class has defined the class method, :post_add_constant, then that + # method will be invoked after each new item is added. It must be defined + # *before* any constants are defined. + # + # Example + # + # class GrammarComponent + # + # include Qpid::Proton::Constants + # + # def self.post_add_constant(key, value) + # @terminal << value if value.terminal? + # @nonterminal << value if !value.terminal? && !value.rule + # @rule << value if value.rule + # end + # + # self.add_constant :LEFT_PARENTHESIS, new GrammarComponent("(", :terminal) + # self.add_constant :RIGHT_PARENTHESIS, new GrammarComponent(")", :terminal) + # self.add_constant :ELEMENT, new GrammarComponent("E", :rule) + # + # def initialize(component, type) + # @component = component + # @type = type + # end + # + # def terminal?; @type == :terminal; end + # + # def rule?; @type == :rule; end + # + # end + # + # @private + # + module Constants + +def self.included(base) + base.extend ClassMethods +end + +module ClassMethods + + def add_constant(key, value) +self.const_set(key, value) + +@pn_by_value ||= {} +@pn_by_value[value] = key + +if self.respond_to? :post_add_constant + self.post_add_constant(key, value) +end + end + + def by_value(value) +(@pn_by_value || {})[value] + end + +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[28/34] qpid-proton git commit: PROTON-799: Added the SASL class to the Ruby engine APIs.
PROTON-799: Added the SASL 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/152129ad Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/152129ad Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/152129ad Branch: refs/heads/master Commit: 152129ad3bdc51d21412d2fc2f2c99ca7bb036b1 Parents: 8f38c7a Author: Darryl L. Pierce Authored: Tue Jan 20 16:09:30 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/core/sasl.rb | 94 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 95 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/152129ad/proton-c/bindings/ruby/lib/core/sasl.rb -- diff --git a/proton-c/bindings/ruby/lib/core/sasl.rb b/proton-c/bindings/ruby/lib/core/sasl.rb new file mode 100644 index 000..7870652 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/sasl.rb @@ -0,0 +1,94 @@ +#-- +# 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 + + # The SASL layer is responsible for establishing an authenticated and/or + # encrypted tunnel over which AMQP frames are passed between peers. + # + # The peer acting as the SASL client must provide authentication + # credentials. + # + # The peer acting as the SASL server must provide authentication against the + # received credentials. + # + # @example + # # SCENARIO: the remote endpoint has not initialized their connection + # # then the local endpoint, acting as a SASL server, decides + # # to allow an anonymous connection. + # # + # # The SASL layer locally assumes the role of server and then + # # enables anonymous authentication for the remote endpoint. + # # + # sasl = @transport.sasl + # sasl.server + # sasl.mechanisms("ANONYMOUS") + # sasl.done(Qpid::Proton::SASL::OK) + # + class SASL + +# Negotation has not completed. +NONE = Cproton::PN_SASL_NONE +# Authentication succeeded. +OK = Cproton::PN_SASL_OK +# Authentication failed due to bad credentials. +AUTH = Cproton::PN_SASL_AUTH + +# Constructs a new instance for the given transport. +# +# @param transport [Transport] The transport. +# +# @private A SASL should be fetched only from its Transport +# +def initialize(transport) + @impl = Cproton.pn_sasl(transport.impl) +end + +# Sets the acceptable SASL mechanisms. +# +# @param mechanisms [String] The space-delimited set of mechanisms. +# +# @example Use anonymous SASL authentication. +# @sasl.mechanisms("GSSAPI CRAM-MD5 PLAIN") +# +def mechanisms(mechanisms) + Cproton.pn_sasl_mechanisms(@impl, mechanisms) +end + +# Returns the outcome of the SASL negotiation. +# +# @return [Fixnum] The outcome. +# +def outcome + outcome = Cprotn.pn_sasl_outcome(@impl) + return nil if outcome == NONE + outcome +end + +# Set the condition of the SASL negotiation. +# +# @param outcome [Fixnum] The outcome. +# +def done(outcome) + Cproton.pn_sasl_done(@impl, outcome) +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/152129ad/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 2a57b32..3ac0b9e 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -63,6 +63,7 @@ require "core/link" require "core/sender" require "core/receiver" require "core/connection" +require "core/sasl" # Messenger API classes require "messenger/filters" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
[31/34] qpid-proton git commit: PROTON-799: Added the Event classes to the Ruby engine APIs.
PROTON-799: Added the Event classes 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/740b05ed Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/740b05ed Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/740b05ed Branch: refs/heads/master Commit: 740b05ed54007e50da6dc90ac8089269a9aee5e6 Parents: 3ca8e24 Author: Darryl L. Pierce Authored: Tue Feb 3 17:17:18 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/event/event.rb | 296 proton-c/bindings/ruby/lib/event/event_base.rb | 91 ++ proton-c/bindings/ruby/lib/event/event_type.rb | 71 + proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + 4 files changed, 461 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/740b05ed/proton-c/bindings/ruby/lib/event/event.rb -- diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb new file mode 100644 index 000..dd5d869 --- /dev/null +++ b/proton-c/bindings/ruby/lib/event/event.rb @@ -0,0 +1,296 @@ +#-- +# 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 + + module Event + +# @private +def self.event_type(const_name, method_name = nil) # :nodoc: + unless Cproton.const_defined?(const_name) +raise RuntimeError.new("no such constant: #{const_name}") + end + + const_value = Cproton.const_get(const_name) + method_name = "on_#{const_name.to_s[3..-1]}".downcase if method_name.nil? + + EventType.new(const_value, method_name) +end + +# Defined as a programming convenience. No even of this type will ever +# be generated. +NONE = event_type(:PN_EVENT_NONE) + +# A timer event has occurred. +TIMER_TASK = event_type(:PN_TIMER_TASK) + +# A connection has been created. This is the first even that will ever +# be issued for a connection. +CONNECTION_INIT = event_type(:PN_CONNECTION_INIT) +# A conneciton has been bound toa transport. +CONNECTION_BOUND = event_type(:PN_CONNECTION_BOUND) +# A connection has been unbound from its transport. +CONNECTION_UNBOUND = event_type(:PN_CONNECTION_UNBOUND) +# A local connection endpoint has been opened. +CONNECTION_LOCAL_OPEN = event_type(:PN_CONNECTION_LOCAL_OPEN) +# A local connection endpoint has been closed. +CONNECTION_LOCAL_CLOSE = event_type(:PN_CONNECTION_LOCAL_CLOSE) +# A remote endpoint has opened its connection. +CONNECTION_REMOTE_OPEN = event_type(:PN_CONNECTION_REMOTE_OPEN) +# A remote endpoint has closed its connection. +CONNECTION_REMOTE_CLOSE = event_type(:PN_CONNECTION_REMOTE_CLOSE) +# A connection has been freed and any outstanding processing has been +# completed. This is the final event htat will ever be issued for a +# connection +CONNECTION_FINAL = event_type(:PN_CONNECTION_FINAL) + +# A session has been created. This is the first event that will ever be +# issues for a session. +SESSION_INIT = event_type(:PN_SESSION_INIT) +# A local session endpoint has been opened. +SESSION_LOCAL_OPEN = event_type(:PN_SESSION_LOCAL_OPEN) +# A local session endpoint has been closed. +SESSION_LOCAL_CLOSE = event_type(:PN_SESSION_LOCAL_CLOSE) +# A remote endpoint has opened its session. +SESSION_REMOTE_OPEN = event_type(:PN_SESSION_REMOTE_OPEN) +# A remote endpoint has closed its session. +SESSION_REMOTE_CLOSE = event_type(:PN_SESSION_REMOTE_CLOSE) +# A session has been freed and any outstanding processing has been +# completed. This is the final event that will ever be issued for a +# session +SESSION_FINAL = event_type(:PN_SESSION_FINAL) + +# A link has been created. This is the first event that will ever be +# issued for a link. +LINK_INIT = event_type(:PN_LINK_INIT) +# A local link endpoint has been opened. +LI
[20/34] qpid-proton git commit: PROTON-799: Added the Receiver class to the Ruby engine APIs.
PROTON-799: Added the Receiver 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/706999b3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/706999b3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/706999b3 Branch: refs/heads/master Commit: 706999b3d092bfee390da52eb3f558ddaae72a17 Parents: b4ac3d1 Author: Darryl L. Pierce Authored: Tue Jan 20 09:22:49 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/receiver.rb | 95 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 96 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/706999b3/proton-c/bindings/ruby/lib/core/receiver.rb -- diff --git a/proton-c/bindings/ruby/lib/core/receiver.rb b/proton-c/bindings/ruby/lib/core/receiver.rb new file mode 100644 index 000..ca7c5e1 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/receiver.rb @@ -0,0 +1,95 @@ +#-- +# 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 + + # The receiving endpoint. + # + # @see Sender + # + class Receiver < Link + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_link" + +# @!attribute drain +# +# The drain mode. +# +# If a receiver is in drain mode, then the sending endpoint of a link must +# immediately use up all available credit on the link. If this is not +# possible, the excess credit must be returned by invoking #drained. +# +# Only the receiving endpoint can set the drain mode. +# +# @return [Boolean] True if drain mode is set. +# +proton_accessor :drain + +# @!attribute [r] draining? +# +# Returns if a link is currently draining. +# +# A link is defined to be draining when drain mode is set to true and +# the sender still has excess credit. +# +# @return [Boolean] True if the receiver is currently draining. +# +proton_caller :draining? + +# Grants credit for incoming deliveries. +# +# @param n [Fixnum] The amount to increment the link credit. +# +def flow(n) + Cproton.pn_link_flow(@impl, n) +end + +# Allows receiving up to the specified limit of data from the remote +# endpoint. +# +# Note that large messages can be streamed across the network, so just +# because there is no data to read does not imply the message is complete. +# +# To ensure the entirety of the message data has been read, either call +# #receive until nil is returned, or verify that #partial? is false and +# Delivery#pending is 0. +# +# @param limit [Fixnum] The maximum bytes to receive. +# +# @return [Fixnum, nil] The number of bytes received, or nil if the end of +# the stream was reached.t +# +# @see Deliver#pending To see how much buffer space is needed. +# +# @raise [LinkError] If an error occurs. +# +def receive(limit) + (n, bytes) = Cproton.pn_link_recv(@impl, limit) + return nil if n == Qpid::Proton::Error::EOS + raise LinkError.new("[#{n}]: #{Cproton.pn_link_error(@impl)}") if n < 0 + return bytes +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/706999b3/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 39ef351..ed8532f 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -61,6 +61,7 @@ require "core/disposition" require "core/delivery" require "core/link" require "core/sender" +require "core/receiver" # Messenger API classes require "messenger/filters" - To unsubscribe, e-ma
[18/34] qpid-proton git commit: PROTON-799: Added the Sender class to the Ruby engine APIs.
PROTON-799: Added the Sender 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/b4ac3d17 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b4ac3d17 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b4ac3d17 Branch: refs/heads/master Commit: b4ac3d174024dcb0b7d162400d8988618e02cd76 Parents: b433dd4 Author: Darryl L. Pierce Authored: Tue Jan 20 09:17:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/sender.rb | 76 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 77 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b4ac3d17/proton-c/bindings/ruby/lib/core/sender.rb -- diff --git a/proton-c/bindings/ruby/lib/core/sender.rb b/proton-c/bindings/ruby/lib/core/sender.rb new file mode 100644 index 000..9ddcaa0 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/sender.rb @@ -0,0 +1,76 @@ +#-- +# 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 + + # The sending endpoint. + # + # @see Receiver + # + class Sender < Link + +# @private +include Util::ErrorHandler + +# @private +can_raise_error :stream, :error_class => Qpid::Proton::LinkError + +# Signals the availability of deliveries. +# +# @param n [Fixnum] The number of deliveries potentially available. +# +def offered(n) + Cproton.pn_link_offered(@impl, n) +end + +# Sends the specified data to the remote endpoint. +# +# @param object [Object] The content to send. +# @param tag [Object] The tag +# +# @return [Fixnum] The number of bytes sent. +# +def send(object, tag = nil) + if object.respond_to? :proton_send +object.proton_send(self, tag) + else +stream(object) + end +end + +# Send the specified bytes as part of the current delivery. +# +# @param bytes [Array] The bytes to send. +# +# @return n [Fixnum] The number of bytes sent. +# +def stream(bytes) + Cproton.pn_link_send(@impl, bytes) +end + +def delivery_tag + @tag_count ||= 0 + result = @tag_count.succ + @tag_count = result + return "#{result}" +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b4ac3d17/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 9b3becb..39ef351 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -60,6 +60,7 @@ require "core/terminus" require "core/disposition" require "core/delivery" require "core/link" +require "core/sender" # 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
[06/34] qpid-proton git commit: PROTON-799: Rearranged Ruby library.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81a5449d/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 88f8acd..e8fab77 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -24,19 +24,30 @@ if RUBY_VERSION < "1.9" require "kconv" end -require "qpid_proton/version" -require "qpid_proton/described" -require "qpid_proton/strings" -require "qpid_proton/mapping" -require "qpid_proton/array" -require "qpid_proton/hash" -require "qpid_proton/exceptions" -require "qpid_proton/exception_handling" -require "qpid_proton/filters" -require "qpid_proton/data" -require "qpid_proton/message" -require "qpid_proton/subscription" -require "qpid_proton/tracker_status" -require "qpid_proton/tracker" -require "qpid_proton/selectable" -require "qpid_proton/messenger" +# Exception classes +require "core/exceptions" + +# Utility classes +require "util/version" +require "util/error_handler" + +# Types +require "types/strings" +require "types/hash" +require "types/array" +require "types/described" + +# Codec classes +require "codec/mapping" +require "codec/data" + +# Main Proton classes +require "core/message" + +# Messenger API classes +require "messenger/filters" +require "messenger/subscription" +require "messenger/tracker_status" +require "messenger/tracker" +require "messenger/selectable" +require "messenger/messenger" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81a5449d/proton-c/bindings/ruby/lib/qpid_proton/array.rb -- diff --git a/proton-c/bindings/ruby/lib/qpid_proton/array.rb b/proton-c/bindings/ruby/lib/qpid_proton/array.rb deleted file mode 100644 index a4294a3..000 --- a/proton-c/bindings/ruby/lib/qpid_proton/array.rb +++ /dev/null @@ -1,173 +0,0 @@ -#-- -# 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. -#++ - -#-- -# Patch the Array class to provide methods for adding its contents -# to a Qpid::Proton::Data instance. -#++ - -module Qpid # :nodoc: - - module Proton # :nodoc: - -# Holds the information for an AMQP Array compound type. -# -# It holds the type for the array and the descriptor if the -# array is described. -# -class ArrayHeader - attr_reader :type - attr_reader :descriptor - - def initialize(type, descriptor = nil) -@type = type -@descriptor = descriptor - end - - # Returns true if the array is described. - def described? -!@descriptor.nil? - end - - def ==(that) -((@type == that.type) && (@descriptor == that.descriptor)) - end -end - - end - -end - -class Array # :nodoc: - - # Used to declare an array as an AMQP array. - # - # The value, if defined, is an instance of Qpid::Proton::ArrayHeader - attr_accessor :proton_array_header - - # Returns true if the array is the a Proton described type. - def proton_described? -!@proton_array_header.nil? && @proton_array_header.described? - end - - # Puts the elements of the array into the specified Qpid::Proton::Data object. - def proton_put(data) -raise TypeError, "data object cannot be nil" if data.nil? - -if @proton_array_header.nil? - proton_put_list(data) -else - proton_put_array(data) -end - end - - private - - def proton_put_list(data) -# create a list, then enter it and add each element -data.put_list -data.enter -each do |element| - # get the proton type for the element - mapping = Qpid::Proton::Mapping.for_class(element.class) - # add the element - mapping.put(data, element) -end -# exit the list -data.exit - end - - def proton_put_array(data) -data.put_array(@proton_array_header.described?, @proton_array_header.type) -data.enter -if @proton_array_header.described? - data.symbol = @proton_array_header.descriptor -end - -each do |element| - @proton_array_header.type.put(data, element) -end - -data.exit - end - - class << self - -# Gets the elements of an array or l
[32/34] qpid-proton git commit: PROTON-799: Adjusted the Ruby error macro
PROTON-799: Adjusted the Ruby error macro Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ada57d89 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ada57d89 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ada57d89 Branch: refs/heads/master Commit: ada57d89b0a900b8e8e30e0aec08ae95e145dcf3 Parents: ff235b8 Author: Darryl L. Pierce Authored: Thu Feb 19 14:28:54 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:25 2015 -0400 -- proton-c/bindings/ruby/lib/util/error_handler.rb | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ada57d89/proton-c/bindings/ruby/lib/util/error_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/util/error_handler.rb b/proton-c/bindings/ruby/lib/util/error_handler.rb index 2f43609..da51214 100644 --- a/proton-c/bindings/ruby/lib/util/error_handler.rb +++ b/proton-c/bindings/ruby/lib/util/error_handler.rb @@ -41,7 +41,9 @@ module Qpid::Proton::Util end end -def can_raise_error(method_names, error_class = nil) +def can_raise_error(method_names, options = {}) + error_class = options[:error_class] + below = options[:below] || 0 # coerce the names to be an array Array(method_names).each do |method_name| # if the method doesn't already exist then queue this aliasing @@ -49,12 +51,12 @@ module Qpid::Proton::Util @@to_be_wrapped ||= [] @@to_be_wrapped << method_name else - create_exception_handler_wrapper(method_name, error_class) + create_exception_handler_wrapper(method_name, error_class, below) end end end -def create_exception_handler_wrapper(method_name, error_class = nil) +def create_exception_handler_wrapper(method_name, error_class = nil, below = 0) original_method_name = method_name.to_s wrapped_method_name = "_excwrap_#{original_method_name}" alias_method wrapped_method_name, original_method_name @@ -63,7 +65,8 @@ module Qpid::Proton::Util # calls to Class.send interfere with Messenger.send method = self.method(wrapped_method_name.to_sym) rc = method.call(*args, &block) -check_for_error(rc, error_class) +check_for_error(rc, error_class) if rc < below +return rc end end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[07/34] qpid-proton git commit: PROTON-799: Rearranged Ruby library.
PROTON-799: Rearranged Ruby library. Moved files to match more closely with the new code layout for the project. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/81a5449d Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/81a5449d Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/81a5449d Branch: refs/heads/master Commit: 81a5449d9b4b6a0c46d2bf2cd8e91d8d43fb2347 Parents: 78b4873 Author: Darryl L. Pierce Authored: Fri Feb 20 09:31:03 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:20 2015 -0400 -- proton-c/bindings/ruby/lib/codec/data.rb| 788 +++ proton-c/bindings/ruby/lib/codec/mapping.rb | 170 proton-c/bindings/ruby/lib/core/exceptions.rb | 85 ++ proton-c/bindings/ruby/lib/core/message.rb | 621 +++ proton-c/bindings/ruby/lib/messenger/filters.rb | 67 ++ .../bindings/ruby/lib/messenger/messenger.rb| 702 + .../bindings/ruby/lib/messenger/selectable.rb | 126 +++ .../bindings/ruby/lib/messenger/subscription.rb | 41 + proton-c/bindings/ruby/lib/messenger/tracker.rb | 42 + .../ruby/lib/messenger/tracker_status.rb| 73 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 43 +- proton-c/bindings/ruby/lib/qpid_proton/array.rb | 173 proton-c/bindings/ruby/lib/qpid_proton/data.rb | 788 --- .../bindings/ruby/lib/qpid_proton/described.rb | 66 -- .../ruby/lib/qpid_proton/exception_handling.rb | 127 --- .../bindings/ruby/lib/qpid_proton/exceptions.rb | 85 -- .../bindings/ruby/lib/qpid_proton/filters.rb| 67 -- proton-c/bindings/ruby/lib/qpid_proton/hash.rb | 86 -- .../bindings/ruby/lib/qpid_proton/mapping.rb| 170 .../bindings/ruby/lib/qpid_proton/message.rb| 621 --- .../bindings/ruby/lib/qpid_proton/messenger.rb | 702 - .../bindings/ruby/lib/qpid_proton/selectable.rb | 126 --- .../bindings/ruby/lib/qpid_proton/strings.rb| 65 -- .../ruby/lib/qpid_proton/subscription.rb| 41 - .../bindings/ruby/lib/qpid_proton/tracker.rb| 42 - .../ruby/lib/qpid_proton/tracker_status.rb | 73 -- .../bindings/ruby/lib/qpid_proton/version.rb| 32 - proton-c/bindings/ruby/lib/types/array.rb | 173 proton-c/bindings/ruby/lib/types/described.rb | 66 ++ proton-c/bindings/ruby/lib/types/hash.rb| 86 ++ proton-c/bindings/ruby/lib/types/strings.rb | 65 ++ .../bindings/ruby/lib/util/error_handler.rb | 127 +++ proton-c/bindings/ruby/lib/util/version.rb | 32 + 33 files changed, 3291 insertions(+), 3280 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81a5449d/proton-c/bindings/ruby/lib/codec/data.rb -- diff --git a/proton-c/bindings/ruby/lib/codec/data.rb b/proton-c/bindings/ruby/lib/codec/data.rb new file mode 100644 index 000..b6b3002 --- /dev/null +++ b/proton-c/bindings/ruby/lib/codec/data.rb @@ -0,0 +1,788 @@ +#-- +# 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 # :nodoc: + + module Proton # :nodoc: + +# +DataError+ is raised when an error occurs while encoding +# or decoding data. +class DataError < Exception; end + +# The +Data+ class provides an interface for decoding, extracting, +# creating, and encoding arbitrary AMQP data. A +Data+ object +# contains a tree of AMQP values. Leaf nodes in this tree correspond +# to scalars in the AMQP type system such as INT or STRING. Interior +# nodes in this tree correspond to compound values in the AMQP type +# system such as *LIST*,*MAP*, *ARRAY*, or *DESCRIBED*. The root node +# of the tree is the +Data+ object itself and can have an arbitrary +# number of children. +# +# A +Data+ object maintains the notion of the current sibling node +# and a current parent node. Siblings are ordered within their parent. +# Values are accessed and/or added by using the #next, #prev, +#
[22/34] qpid-proton git commit: PROTON-799: Added the Terminus class to the Ruby engine APIs.
PROTON-799: Added the Terminus 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/6a4e6a66 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6a4e6a66 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6a4e6a66 Branch: refs/heads/master Commit: 6a4e6a66ba4ed8e449104c8064400f930a55 Parents: 4b48f76 Author: Darryl L. Pierce Authored: Mon Jan 19 15:15:49 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/terminus.rb | 218 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 219 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6a4e6a66/proton-c/bindings/ruby/lib/core/terminus.rb -- diff --git a/proton-c/bindings/ruby/lib/core/terminus.rb b/proton-c/bindings/ruby/lib/core/terminus.rb new file mode 100644 index 000..4bd22d7 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/terminus.rb @@ -0,0 +1,218 @@ +#-- +# 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 + + # Represents an endpoint for an AMQP connection.. + # + # An AMQP terminus acts as either a source or a target for messages, + # but never as both. Every Link is associated iwth both a source and + # a target Terminus that is negotiated during link establishment. + # + # A terminus is composed of an AMQP address along with a number of + # other properties defining the quality of service and behavior of + # the Link. + # + class Terminus + +# Indicates a non-existent source or target terminus. +UNSPECIFIED = Cproton::PN_UNSPECIFIED +# Indicates a source for messages. +SOURCE = Cproton::PN_SOURCE +# Indicates a target for messages. +TARGET = Cproton::PN_TARGET +# A special target identifying a transaction coordinator. +COORDINATOR = Cproton::PN_COORDINATOR + +# The terminus is orphaned when the parent link is closed. +EXPIRE_WITH_LINK = Cproton::PN_EXPIRE_WITH_LINK +# The terminus is orphaned whent he parent sessio is closed. +EXPIRE_WITH_SESSION = Cproton::PN_EXPIRE_WITH_SESSION +# The terminus is orphaned when the parent connection is closed. +EXPIRE_WITH_CONNECTION = Cproton::PN_EXPIRE_WITH_CONNECTION +# The terminus is never considered orphaned. +EXPIRE_NEVER = Cproton::PN_EXPIRE_NEVER + +# Indicates a non-durable Terminus. +NONDURABLE = Cproton::PN_NONDURABLE +# Indicates a Terminus with durably held configuration, but +# not the delivery state. +CONFIGURATION = Cproton::PN_CONFIGURATION +# Indicates a Terminus with both durably held configuration and +# durably held delivery states. +DELIVERIES = Cproton::PN_DELIVERIES + +# The behavior is defined by the nod.e +DIST_MODE_UNSPECIFIED = Cproton::PN_DIST_MODE_UNSPECIFIED +# The receiver gets all messages. +DIST_MODE_COPY = Cproton::PN_DIST_MODE_COPY +# The receives compete for messages. +DIST_MODE_MOVE = Cproton::PN_DIST_MODE_MOVE + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_terminus" + +# @!attribute type +# +# @return [Fixnum] The terminus type. +# +# @see SOURCE +# @see TARGET +# @see COORDINATOR +# +proton_accessor :type + +# @!attribute address +# +# @return [String] The terminus address. +# +proton_accessor :address + +# @!attribute durability +# +# @return [Fixnum] The durability mode of the terminus. +# +# @see NONDURABLE +# @see CONFIGURATION +# @see DELIVERIES +# +proton_accessor :durability + +# @!attribute expiry_policy +# +# @return [Fixnum] The expiry policy. +# +# @see EXPIRE_WITH_LINK +# @see EXPIRE_WITH_SESSION +# @see EXPIRE_WITH_CONNECTION +# @see EXPIRE_NEVER +# +proton_accessor :expiry_policy + +# @!attribute timeout +# +
[27/34] qpid-proton git commit: PROTON-799: Added the ClassWrapper mixin for the Ruby engine APIs.
PROTON-799: Added the ClassWrapper mixin for the Ruby engine APIs. This mixin enables mapping an underlying C library engine class to the appropriate Ruby class type. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3ca8e249 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3ca8e249 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3ca8e249 Branch: refs/heads/master Commit: 3ca8e2495f8fbbd558e8fc0398f8c9c3dbf81a1a Parents: cf0e109 Author: Darryl L. Pierce Authored: Wed Feb 4 09:35:31 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + .../bindings/ruby/lib/util/class_wrapper.rb | 52 2 files changed, 53 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3ca8e249/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 16394f9..9060b54 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -36,6 +36,7 @@ require "util/constants" require "util/swig_helper" require "util/condition" require "util/wrapper" +require "util/class_wrapper" require "util/engine" require "util/uuid" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3ca8e249/proton-c/bindings/ruby/lib/util/class_wrapper.rb -- diff --git a/proton-c/bindings/ruby/lib/util/class_wrapper.rb b/proton-c/bindings/ruby/lib/util/class_wrapper.rb new file mode 100644 index 000..134f655 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/class_wrapper.rb @@ -0,0 +1,52 @@ +#-- +# 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::Util + + # This mixin provides a method for mapping from an underlying Proton + # C library class to a Ruby class. + # + # @private + # + module ClassWrapper + +WRAPPERS = + { +"pn_void" => proc {|x| Cproton.pn_void2rb(x)}, +"pn_rbref" => proc {|x| Cproton.pn_void2rb(x)}, +"pn_connection" => proc {|x| Qpid::Proton::Connection.wrap(Cproton.pn_cast_pn_connection(x))}, +"pn_session" => proc {|x| Qpid::Proton::Session.wrap(Cproton.pn_cast_pn_session(x))}, +"pn_link" => proc {|x| Qpid::Proton::Link.wrap(Cproton.pn_cast_pn_link(x))}, +"pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))}, +"pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))}, +"pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))}, + } + +def class_wrapper(clazz, c_impl, &block) + proc_func = WRAPPERS[clazz] + if !proc_func.nil? +proc_func.yield(c_impl) + elsif block_given? +yield(c_impl) + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[09/34] qpid-proton git commit: PROTON-799: Added the Collector class to the Ruby engine APIs.
PROTON-799: Added the Collector 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/3a642303 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3a642303 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3a642303 Branch: refs/heads/master Commit: 3a642303fd2c82d907e12405b1b813fe672a4aa9 Parents: ff805e1 Author: Darryl L. Pierce Authored: Tue Jan 6 13:51:34 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/event/collector.rb | 148 + proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + proton-c/bindings/ruby/ruby.i | 9 ++ 3 files changed, 160 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3a642303/proton-c/bindings/ruby/lib/event/collector.rb -- diff --git a/proton-c/bindings/ruby/lib/event/collector.rb b/proton-c/bindings/ruby/lib/event/collector.rb new file mode 100644 index 000..c86b0f2 --- /dev/null +++ b/proton-c/bindings/ruby/lib/event/collector.rb @@ -0,0 +1,148 @@ +#-- +# 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::Event + + # A Collector is used to register interest in events produced by one + # or more Connection objects. + # + # == Events + # + # @see Qpid::Proton::Event The list of predefined events. + # + # @example + # + # conn = Qpid::Proton::Connection.new + # coll = Qpid::Proton::Event::Collector.new + # conn.collect(coll) + # + # # transport setup not included here for brevity + # + # loop do + # + # # wait for an event and then perform the following + # + # event = collector.peek + # + # unless event.nil? + #case event.type + # + #when Qpid::Proton::Event::CONNECTION_REMOTE_CLOSE + # conn = event.context # the context here is the connection + # # the remote connection closed, so only close our side if it's + # # still open + # if !(conn.state & Qpid::Proton::Endpoint::LOCAL_CLOSED) + #conn.close + # end + # + #when Qpid::proton::Event::SESSION_REMOTE_OPEN + # session = event.session # the context here is the session + # # the remote session is now open, so if the local session is + # # uninitialized, then open it + # if session.state & Qpid::Proton::Endpoint::LOCAL_UNINIT + #session.incoming_capacity = 100 + #session.open + # end + # + #end + # + # # remove the processed event and get the next event + # # the loop will exit when we have no more events to process + # collector.pop + # event = collector.peek + # + # end + # + class Collector + +# @private +attr_reader :impl + +# Creates a new Collector. +# +def initialize + @impl = Cproton.pn_collector + ObjectSpace.define_finalizer(self, self.class.finalize!(@impl)) +end + +# @private +def self.finalize!(impl) + proc { +Cproton.pn_collector_free(impl) + } +end + +# Releases the collector. +# +# Once in a released state, a collector will drain any internally queued +# events, shrink its memory footprint to a minimu, and discard any newly +# created events. +# +def release + Cproton.pn_collector_release(@impl) +end + +# Place a new event on the collector. +# +# This operation will create a new event of the given type and context +# and return a new Event instance. In some cases an event of a given +# type can be elided. When this happens, this operation will return +# nil. +# +# @param context [Object] The event context. +# @param event_type [EventType] The event type. +# +# @return [Event] the event if it was queued +# @return [nil] if it was elided +# +def put(context, event_type) + Cpr
[26/34] qpid-proton git commit: PROTON-799: Added the engine_send and engine_recv examples to Ruby.
PROTON-799: Added the engine_send and engine_recv examples 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/f5f94310 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f5f94310 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f5f94310 Branch: refs/heads/master Commit: f5f943107f7cd76fcb23634f83cb516975be6dfb Parents: 740b05e Author: Darryl L. Pierce Authored: Tue Jan 13 16:27:57 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- examples/ruby/engine_recv.rb | 158 examples/ruby/engine_send.rb | 143 + examples/ruby/lib/driver.rb| 69 ++ examples/ruby/lib/qpid_examples.rb | 28 ++ examples/ruby/lib/selectable.rb| 120 5 files changed, 518 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f5f94310/examples/ruby/engine_recv.rb -- diff --git a/examples/ruby/engine_recv.rb b/examples/ruby/engine_recv.rb new file mode 100644 index 000..1529964 --- /dev/null +++ b/examples/ruby/engine_recv.rb @@ -0,0 +1,158 @@ +#-- +# 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. +#++ + +require "qpid_examples" +require "optparse" + +DEFAULT_PORT = 5672 + +options = { + :port => DEFAULT_PORT, + :debug => false, + :verbose => false, +} + +OptionParser.new do |opts| + opts.banner = "Usage: engine_recv.rb [options]" + + opts.on("-p [port]", "--port [port]", + "The port to use (def. #{DEFAULT_PORT})") do |port| +options[:port] = port + end + + opts.on("-v", "--verbose", + "Enable verbose output") do +options[:verbose] = true + end + + opts.on("-d", + "--debug", "Enable debugging") do +options[:debug] = true + end + + opts.parse! +end + +server = TCPServer.new('localhost', options[:port]) + +last_time = Time.now + +message_count = 0 +driver = Driver.new + +collector = Qpid::Proton::Event::Collector.new + +loop do + begin +client = server.accept_nonblock + rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR, Errno::EWOULDBLOCK => error + + end + + unless client.nil? +puts "Connection from #{client.peeraddr.last}" +connection = Qpid::Proton::Connection.new +connection.collect(collector) +transport = Qpid::Proton::Transport.new(Qpid::Proton::Transport::SERVER) +transport.bind(connection) +selectable = Selectable.new(transport, client) +driver.add(selectable) + end + + # let the driver process data + driver.process + + event = collector.peek + + while !event.nil? +puts "EVENT: #{event}" if options[:debug] + +case event.type +when Qpid::Proton::Event::CONNECTION_INIT + conn = event.connection + if conn.state & Qpid::Proton::Endpoint::REMOTE_UNINIT +conn.transport.sasl.done(Qpid::Proton::SASL::OK) + end + +when Qpid::Proton::Event::CONNECTION_BOUND + conn = event.connection + if conn.state & Qpid::Proton::Endpoint::LOCAL_UNINIT +conn.open + end + +when Qpid::Proton::Event::CONNECTION_REMOTE_CLOSE + conn = event.context + if !(conn.state & Qpid::Proton::Endpoint::LOCAL_CLOSED) +conn.close + end + +when Qpid::Proton::Event::SESSION_REMOTE_OPEN + session = event.session + if session.state & Qpid::Proton::Endpoint::LOCAL_UNINIT +session.incoming_capacity = 100 +session.open + end + +when Qpid::Proton::Event::SESSION_REMOTE_CLOSE + session = event.session + if !(session.state & Qpid::Proton::Endpoint::LOCAL_CLOSED) +session.close + end + +when Qpid::Proton::Event::LINK_REMOTE_OPEN + link = event.link + if link.state & Qpid::Proton::Endpoint::LOCAL_UNINIT +link.open +link.flow 400 + end + +when Qpid::Proton::Event::LINK_REMOTE_CLOSE + link = event.context + if !(link.state & Qpid::Proton::Endpoint::LOCAL_CLOS
[33/34] qpid-proton git commit: PROTON-799: Test for the Wrapper and rbkey system
PROTON-799: Test for the Wrapper and rbkey system Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cedb4763 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cedb4763 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cedb4763 Branch: refs/heads/master Commit: cedb476332fd3c73409563b74d17107463a0edcd Parents: ada57d8 Author: Darryl L. Pierce Authored: Thu May 14 15:57:02 2015 -0400 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:25 2015 -0400 -- examples/ruby/wrapper_test.rb | 82 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 83 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cedb4763/examples/ruby/wrapper_test.rb -- diff --git a/examples/ruby/wrapper_test.rb b/examples/ruby/wrapper_test.rb new file mode 100644 index 000..ca7e250 --- /dev/null +++ b/examples/ruby/wrapper_test.rb @@ -0,0 +1,82 @@ +#-- +# 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. +#++ + +require 'qpid_proton' + +def how_many_transports?(expected) + count = ObjectSpace.each_object(Qpid::Proton::Transport).count + if expected.min == expected.max +expectation = "#{expected.min}" + else +expectation = "#{expected.min} <= count <= #{expected.max}" + end + puts "Transport count: found #{count}, expected #{expectation} (#{expected.include?(count) ? 'Good' : 'Bad'})" +end + +transport = Qpid::Proton::Transport.new +timpl = transport.impl + +puts "=" +puts "= Storing my original transport =" +puts "=" +puts " Stored transport=#{transport} (#{Cproton.pni_address_of(timpl).to_s(16)})" +how_many_transports?(1..1) +puts "=" +transport.instance_eval { @first_name = "Darryl"; @last_name = "Pierce", @instance_id = 717 } +transport = nil + + +puts "" +max = 1000 +puts "Creating #{max} instances of Transport" +(0...max).each do |which| + t = Qpid::Proton::Transport.new + t.instance_eval { @instance_id = which } + t = nil +end + +puts "" +puts "" +puts "= Retrieving my original transport =" +puts "" +transport = Qpid::Proton::Transport.wrap(timpl) +puts "Retrieved transport=#{transport} (#{Cproton.pni_address_of(timpl).to_s(16)})" +how_many_transports?(1..1001) +puts "" +puts "My transport attributes:" +puts transport + +transport = nil +GC.start +how_many_transports?(1..1) + +puts "" +puts "==" +puts "= Throwing away the Transport object =" +puts "==" +transport = nil +timpl.instance_eval { @proton_wrapper = nil } +GC.start +begin + transport = Qpid::Proton::Transport.wrap(timpl) + puts "!!! This should fail!" +rescue Qpid::Proton::ProtonError => error + puts "Good, it failed..." +end +how_many_transports?(0..0) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cedb4763/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 58b95d0..467d959 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -19,6 +19,7 @@ require "cproton" require "date" +require "weakref" if RUBY_VERSION < "1.9" require "kconv" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[29/34] qpid-proton git commit: PROTON-799: Added the Connection class to the Ruby engine APIs.
PROTON-799: Added the Connection 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/5d9505d9 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5d9505d9 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5d9505d9 Branch: refs/heads/master Commit: 5d9505d959ddab13aefadac1fb3c0c11c700 Parents: 706999b Author: Darryl L. Pierce Authored: Fri Jan 16 15:13:04 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/core/connection.rb | 328 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 329 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d9505d9/proton-c/bindings/ruby/lib/core/connection.rb -- diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb new file mode 100644 index 000..252193d --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/connection.rb @@ -0,0 +1,328 @@ +#-- +# 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 Connection option has at most one Qpid::Proton::Transport instance. + # + class Connection < Endpoint + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_connection" + +# @!attribute hostname +# +# @return [String] The AMQP hostname for the connection. +# +proton_accessor :hostname + +# @private +proton_reader :attachments + +attr_accessor :overrides +attr_accessor :session_policy + +# @private +include Util::Wrapper + +# @private +def self.wrap(impl) + return nil if impl.nil? + + self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl) +end + +# 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. +# +# @param impl [pn_connection_t] The pn_connection_t struct. +# +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 + +def overrides? + !@overrides.nil? +end + +def session_policy? + !@session_policy.nil? +end + +# This method is used when working within the context of an event. +# +# @return [Connection] The connection itself. +# +def connection + self +end + +# The Transport to which this connection is bound. +# +# @return [Transport] The transport, or nil if the Connection is unbound. +# +def transport + Transport.wrap(Cproton.pn_connection_transport(@impl)) +end + +# 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. +# +# @param collector [Event::Collector] The event collector. +# +def collect(collector) + if collector.nil? +Cproton.pn_connection_collect(@impl, nil) + else +Cproton.pn_connection_collect(@impl, collector.impl) + end + @collector = collector +end + +# Ge
[23/34] qpid-proton git commit: PROTON-799: Added the Session class to the Ruby engine APIs.
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/4b48f76b Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4b48f76b Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4b48f76b Branch: refs/heads/master Commit: 4b48f76b543c6c58068207c92e9891a847612fd8 Parents: 1b96d12 Author: Darryl L. Pierce Authored: Tue Jan 20 10:37:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 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/4b48f76b/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/4b48f76b/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 000..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 wi
[25/34] qpid-proton git commit: PROTON-799: Added the SSL classes to the Ruby engine APIs.
PROTON-799: Added the SSL classes 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/a813f6a1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a813f6a1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a813f6a1 Branch: refs/heads/master Commit: a813f6a1d432692b4dc3802f6981c01c363545f1 Parents: 152129a Author: Darryl L. Pierce Authored: Wed Apr 29 16:45:05 2015 -0400 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:24 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 6 + proton-c/bindings/ruby/lib/core/ssl.rb | 160 proton-c/bindings/ruby/lib/core/ssl_details.rb | 33 proton-c/bindings/ruby/lib/core/ssl_domain.rb | 156 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 3 + proton-c/bindings/ruby/ruby.i | 14 ++ 6 files changed, 372 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a813f6a1/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 714830b..2695709 100644 --- a/proton-c/bindings/ruby/lib/core/exceptions.rb +++ b/proton-c/bindings/ruby/lib/core/exceptions.rb @@ -100,6 +100,12 @@ module Qpid class LinkError < ProtonError end +class SSLError < TransportError +end + +class SSLUnavailableError < SSLError +end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a813f6a1/proton-c/bindings/ruby/lib/core/ssl.rb -- diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb new file mode 100644 index 000..9c4a3e9 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/ssl.rb @@ -0,0 +1,160 @@ +#-- +# 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 + + # The SSL support for Transport. + # + # A Transport may be configured ot use SLL for encryption and/or + # authentication. A Transport can be configured as either the SSL + # client or the server. An SSL client is the party that proctively + # establishes a connection to an SSL server. An SSL server is the + # party that accepts a connection request from the remote SSL client. + # + # If either the client or the server needs to identify itself with the + # remote node, it must have its SSL certificate configured. + # + # @see SSLDomain#credentials For setting the SSL certificate. + # + # If either the client or the server needs to verify the identify of the + # remote node, it must have its database of trusted CAs configured. + # + # @see SSLDomain#trusted_ca_db Setting the CA database. + # + # An SSL server connection may allow the remote client to connect without + # SS (i.e., "in the clear"). + # + # @see SSLDomain#allow_unsecured_client Allowing unsecured clients. + # + # The level of verification required of the remote may be configured. + # + # @see SSLDomain#peer_authentication Setting peer authentication. + # + # Support for SSL client session resume is provided as well. + # + # @see SSLDomain + # @see #resume_status + # + class SSL + +# Session resume state is unkonnwn or not supported. +RESUME_UNKNOWN = Cproton::PN_SSL_RESUME_UNKNOWN +# Session renegotiated and not resumed. +RESUME_NEW = Cproton::PN_SSL_RESUME_NEW +# Session resumed from the previous session. +RESUME_REUSED = Cproton::PN_SSL_RESUME_REUSED + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_ssl" + +# @!attribute peer_hostname +# +# @return [String] The peer hostname. +proton_accessor :peer_hostname + +# @private +include Util::ErrorHandler + +can_raise_error :peer_hostname=, :error_class => SSLError + +# Returns whether SSL is supported. +# +# @return [Boolean] True if
[19/34] qpid-proton git commit: PROTON-799: Added the Endpoint class to the Ruby engine APIs.
PROTON-799: Added the Endpoint 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/1b96d12a Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1b96d12a Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1b96d12a Branch: refs/heads/master Commit: 1b96d12a21673030532e077e93c391c26cf9982f Parents: 38ce7ee Author: Darryl L. Pierce Authored: Mon Jan 19 10:20:33 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/endpoint.rb | 115 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 116 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b96d12a/proton-c/bindings/ruby/lib/core/endpoint.rb -- diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb new file mode 100644 index 000..cbf1015 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/endpoint.rb @@ -0,0 +1,115 @@ +#-- +# 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 + + # Endpoint is the parent classes for Link and Session. + # + # It provides a namespace for constant values that relate to the current + # state of both links and sessions. + # + # @example + # + # conn = Qpid::Proton::Connection.new + # puts "Local connection flags : #{conn.state || Qpid::Proton::Endpoint::LOCAL_MASK}" + # puts "Remote connection flags: #{conn.state || Qpid::Proton::Endpoint::REMOTE_MASK}" + # + class Endpoint + +# The local connection is uninitialized. +LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT +# The local connection is active. +LOCAL_ACTIVE = Cproton::PN_LOCAL_ACTIVE +# The local connection is closed. +LOCAL_CLOSED = Cproton::PN_LOCAL_CLOSED + +# The remote connection is unitialized. +REMOTE_UNINIT = Cproton::PN_REMOTE_UNINIT +# The remote connection is active. +REMOTE_ACTIVE = Cproton::PN_REMOTE_ACTIVE +# The remote connection is closed. +REMOTE_CLOSED = Cproton::PN_REMOTE_CLOSED + +# Bitmask for the local-only flags. +LOCAL_MASK = Cproton::PN_LOCAL_UNINIT | + Cproton::PN_LOCAL_ACTIVE | + Cproton::PN_LOCAL_CLOSED + +# Bitmask for the remote-only flags. +REMOTE_MASK = Cproton::PN_REMOTE_UNINIT | + Cproton::PN_REMOTE_ACTIVE | + Cproton::PN_REMOTE_CLOSED + +# @private +include Util::Engine + +# @private +def initialize + @condition = nil +end + +# @private +def _update_condition + object_to_condition(@condition, self._local_condition) +end + +# @private +def remote_condition + condition_to_object(self._remote_condition) +end + +# Return the transport associated with this endpoint. +# +# @return [Transport] The transport. +# +def transport + self.connection.transport +end + +def local_uninit? + check_state(LOCAL_UNINIT) +end + +def local_active? + check_state(LOCAL_ACTIVE) +end + +def local_closed? + check_state(LOCAL_CLOSED) +end + +def remote_uninit? + check_state(REMOTE_UNINIT) +end + +def remote_active? + check_state(REMOTE_ACTIVE) +end + +def remote_closed? + check_state(REMOTE_CLOSED) +end + +def check_state(state_mask) + !(self.state & state_mask).zero? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1b96d12a/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 507b61f..fff9b0b 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -54,6 +54,7 @@ require "event/collector" # Main Proton classes require "core/message" +require
[34/34] qpid-proton git commit: PROTON-799: Added yardopts
PROTON-799: Added yardopts Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ff235b88 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ff235b88 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ff235b88 Branch: refs/heads/master Commit: ff235b88e5bf9a7a5c123f669377da4b0c03a2c9 Parents: f5f9431 Author: Darryl L. Pierce Authored: Mon Feb 9 16:54:14 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:25 2015 -0400 -- proton-c/bindings/ruby/.yardopts | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ff235b88/proton-c/bindings/ruby/.yardopts -- diff --git a/proton-c/bindings/ruby/.yardopts b/proton-c/bindings/ruby/.yardopts new file mode 100644 index 000..bea5abe --- /dev/null +++ b/proton-c/bindings/ruby/.yardopts @@ -0,0 +1 @@ +--no-private lib/**/*.rb - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[03/34] qpid-proton git commit: PROTON-799: Updated the Ruby namespaces.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/core/message.rb -- diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb index 144990b..0b89016 100644 --- a/proton-c/bindings/ruby/lib/core/message.rb +++ b/proton-c/bindings/ruby/lib/core/message.rb @@ -17,605 +17,617 @@ # under the License. #++ -module Qpid # :nodoc: - - module Proton # :nodoc: +module Qpid::Proton + + # A Message represents an addressable quantity of data. + # + # Message Body + # + # The message body can be set using the #body= method. The message will + # then attempt to determine how exactly to encode the content. + # + # Examples + # + # To create a message for sending: + # + # # send a simple text message + # msg = Qpid::Proton::Message.new + # msg.body = "STATE: update" + # + # # send a binary chunk of data + # data = File.binread("/home/qpid/binfile.tar.gz") + # msg = Qpid::Proton::Message.new + # msg.body = Qpid::Proton::BinaryString.new(data) + # + class Message + +# @private +def proton_send(sender, tag = nil) + dlv = sender.delivery(tag || sender.delivery_tag) + encoded = self.encode + sender.stream(encoded) + sender.advance + dlv.settle if sender.snd_settle_mode == Link::SND_SETTLED + return dlv +end -# A Message represents an addressable quantity of data. -# -# Message Body -# -# The message body can be set using the #body= method. The message will -# then attempt to determine how exactly to encode the content. +# Decodes a message from supplied AMQP data and returns the number +# of bytes consumed. # -# Examples -# -# To create a message for sending: +# Options # -# # send a simple text message -# msg = Qpid::Proton::Message.new -# msg.body = "STATE: update" +# * encoded - the encoded data # -# # send a binary chunk of data -# data = File.binread("/home/qpid/binfile.tar.gz") -# msg = Qpid::Proton::Message.new -# msg.body = Qpid::Proton::BinaryString.new(data) -# -class Message +def decode(encoded) + check(Cproton.pn_message_decode(@impl, encoded, encoded.length)) - # Decodes a message from supplied AMQP data and returns the number - # of bytes consumed. - # - # Options - # - # * encoded - the encoded data - # - def decode(encoded) -check(Cproton.pn_message_decode(@impl, encoded, encoded.length)) + post_decode +end -post_decode +def post_decode # :nodoc: + # decode elements from the message + @properties = {} + props = Codec::Data.new(Cproton::pn_message_properties(@impl)) + if props.next +@properties = props.type.get(props) end - - def post_decode # :nodoc: -# decode elements from the message -@properties = {} -props = Qpid::Proton::Data.new(Cproton::pn_message_properties(@impl)) -if props.next - @properties = props.type.get(props) -end -@instructions = nil -insts = Qpid::Proton::Data.new(Cproton::pn_message_instructions(@impl)) -if insts.next - @instructions = insts.type.get(insts) -end -@annotations = nil -annts = Qpid::Proton::Data.new(Cproton::pn_message_annotations(@impl)) -if annts.next - @annotations = annts.type.get(annts) -end -@body = nil -body = Qpid::Proton::Data.new(Cproton::pn_message_body(@impl)) -if body.next - @body = body.type.get(body) -end + @instructions = nil + insts = Codec::Data.new(Cproton::pn_message_instructions(@impl)) + if insts.next +@instructions = insts.type.get(insts) end - - # Encodes the message. - def encode -pre_encode -size = 16 -loop do - error, data = Cproton::pn_message_encode(@impl, size) - if error == Qpid::Proton::Error::OVERFLOW -size *= 2 - else -check(error) -return data - end -end + @annotations = nil + annts = Codec::Data.new(Cproton::pn_message_annotations(@impl)) + if annts.next +@annotations = annts.type.get(annts) + end + @body = nil + body = Codec::Data.new(Cproton::pn_message_body(@impl)) + if body.next +@body = body.type.get(body) end +end - def pre_encode # :nodoc: -# encode elements from the message -props = Qpid::Proton::Data.new(Cproton::pn_message_properties(@impl)) -props.clear -Qpid::Proton::Mapping.for_class(@properties.class).put(props, @properties) unless @properties.empty? -insts = Qpid::Proton::Data.new(Cproton::pn_message_instructions(@
[17/34] qpid-proton git commit: PROTON-799: Added the Link class to the Ruby engine APIs.
PROTON-799: Added the Link 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/b433dd41 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b433dd41 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b433dd41 Branch: refs/heads/master Commit: b433dd41c97c89ee126965c6be4e7431574d7b6a Parents: aa04b94 Author: Darryl L. Pierce Authored: Mon Jan 19 14:55:56 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:23 2015 -0400 -- proton-c/bindings/ruby/lib/core/link.rb | 387 + proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 388 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b433dd41/proton-c/bindings/ruby/lib/core/link.rb -- diff --git a/proton-c/bindings/ruby/lib/core/link.rb b/proton-c/bindings/ruby/lib/core/link.rb new file mode 100644 index 000..86a307a --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/link.rb @@ -0,0 +1,387 @@ +#-- +# 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 + + # The base for both Sender and Receiver, providing common functionality + # between both ends. + # + # A Link has a single parent Qpid::Proton::Session instance. + # + class Link < Endpoint + +# The sender will send all deliveries initially unsettled. +SND_UNSETTLED = Cproton::PN_SND_UNSETTLED +# The sender will send all deliveries settled to the receiver. +SND_SETTLED = Cproton::PN_SND_SETTLED +# The sender may send a mixture of settled and unsettled deliveries. +SND_MIXED = Cproton::PN_SND_MIXED + +# The receiver will settle deliveries regardless of what the sender does. +RCV_FIRST = Cproton::PN_RCV_FIRST +# The receiver will only settle deliveries after the sender settles. +RCV_SECOND = Cproton::PN_RCV_SECOND + +# @private +include Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_link" + +# @!attribute [r] state +# +# Returns the endpoint state flags. +# +proton_caller :state + +# @!method open +# +# Opens the link. Once this operation has completed, the state flag will be +# set. +# +# @see Endpoint::LOCAL_ACTIVE +proton_caller :open + +# @!method close +# +# Closes the link. +# +# Once this operation has completed, the state flag will be set. +# This may be called without first calling #open, which is the equivalent to +# calling #open and then #close. +# +# @see Endpoint::LOCAL_CLOSED +proton_caller :close + +# @!method detach +# +# Detaches the link. +proton_caller :detach + +# Advance the current delivery to the next on the link. +# +# For sending links, this operation is used to finish sending message data +# for the current outgoing delivery and move on to the next outgoing +# delivery (if any). +# +# For receiving links, this operatoin is used to finish accessing message +# data from the current incoming delivery and move on to the next incoming +# delivery (if any). +# +# @return [Boolean] True if the current delivery was changed. +# +# @see #current +# +proton_caller :advance + +proton_caller :unsettled + +# @!attribute [r] credit +# +# Returns the credit balance for a link. +# +# Links use a credit based flow control scheme. Every receiver maintains a +# credit balance that corresponds to the number of deliveries that the +# receiver can accept at any given moment. +# +# As more capacity becomes available at the receiver, it adds credit to this +# balance and communicates the new balance to the sender. Whenever a +# delivery is sent/received, the credit balance maintained by the link is +# decremented by one. +# +# Once the credit balance at the sender reaches zero, the sender must pause +# sending until more credit is obtaine
[11/34] qpid-proton git commit: PROTON-799: Created a wrapper helper module for Ruby bindings.
PROTON-799: Created a wrapper helper module for Ruby bindings. This module provides methods to make it easier to write wrapper methods for the underlying Proton C libraries, reducing a lot of boilerplate coding and removing the potential for bugs due to typos. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0530d1a1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0530d1a1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0530d1a1 Branch: refs/heads/master Commit: 0530d1a194c1e94e347a9fb04fa8e5380bf2db1a Parents: 57deee4 Author: Darryl L. Pierce Authored: Tue Feb 10 15:22:50 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/messenger/filters.rb | 2 +- .../bindings/ruby/lib/messenger/selectable.rb | 2 +- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/swig_helper.rb | 114 +++ 4 files changed, 117 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0530d1a1/proton-c/bindings/ruby/lib/messenger/filters.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/filters.rb b/proton-c/bindings/ruby/lib/messenger/filters.rb index e2b50bc..0ab3407 100644 --- a/proton-c/bindings/ruby/lib/messenger/filters.rb +++ b/proton-c/bindings/ruby/lib/messenger/filters.rb @@ -17,7 +17,7 @@ # under the License. #++ -module Qpid::Proton +module Qpid::Proton::Messenger # @private module Filters http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0530d1a1/proton-c/bindings/ruby/lib/messenger/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb index 36b5761..9a61317 100644 --- a/proton-c/bindings/ruby/lib/messenger/selectable.rb +++ b/proton-c/bindings/ruby/lib/messenger/selectable.rb @@ -25,7 +25,7 @@ module Qpid::Proton::Messenger # @private class Selectable -include Qpid::Proton::Filters +include Filters call_before :check_is_initialized, :fileno, :capacity, :pending, :deadline, http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0530d1a1/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 e90df84..da9983c 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -31,6 +31,7 @@ require "core/exceptions" require "util/version" require "util/error_handler" require "util/constants" +require "util/swig_helper" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0530d1a1/proton-c/bindings/ruby/lib/util/swig_helper.rb -- diff --git a/proton-c/bindings/ruby/lib/util/swig_helper.rb b/proton-c/bindings/ruby/lib/util/swig_helper.rb new file mode 100644 index 000..d60e9e4 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/swig_helper.rb @@ -0,0 +1,114 @@ +#-- +# 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::Util + + # Provides helper functions for writing wrapper functions for the + # underlying C APIs. + # + # Before defining any mutators the class must define the name of the + # prefix for methods with the constant PROTON_METOD_PREFIX. + # + # == Mutators, Setters And Getters + # + # There are three types of wrappers that are supported: + # + # [proton_writer] Defines a set-only method for the named attribute. + # [proton_reader] Defines a get-only method for the named attribute. + # [proton_accessor] Defines both a set- and a get-method for the named + # attribute. + # [proton_caller] A simple wrapper for calling an underlying m
[05/34] qpid-proton git commit: PROTON-799: Rearranged Ruby library.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81a5449d/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb -- diff --git a/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb b/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb deleted file mode 100644 index 5a16c50..000 --- a/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb +++ /dev/null @@ -1,702 +0,0 @@ -# -# 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 # :nodoc: - - module Proton # :nodoc: - -# The +Messenger+ class defines a high level interface for -# sending and receiving Messages. Every Messenger contains -# a single logical queue of incoming messages and a single -# logical queue of outgoing messages. These messages in these -# queues may be destined for, or originate from, a variety of -# addresses. -# -# The messenger interface is single-threaded. All methods -# except one ( #interrupt ) are intended to be used from within -# the messenger thread. -# -# === Sending & Receiving Messages -# -# The Messenger class works in conjuction with the Message class. The -# Message class is a mutable holder of message content. -# -# The put method copies its Message to the outgoing queue, and may -# send queued messages if it can do so without blocking. The send -# method blocks until it has sent the requested number of messages, -# or until a timeout interrupts the attempt. -# -# Similarly, the recv method receives messages into the incoming -# queue, and may block as it attempts to receive the requested number -# of messages, or until timeout is reached. It may receive fewer -# than the requested number. The get method pops the -# eldest Message off the incoming queue and copies it into the Message -# object that you supply. It will not block. -# -# The blocking attribute allows you to turn off blocking behavior entirely, -# in which case send and recv will do whatever they can without -# blocking, and then return. You can then look at the number -# of incoming and outgoing messages to see how much outstanding work -# still remains. -# -class Messenger - - include Qpid::Proton::ExceptionHandling - - can_raise_exception [:send, :receive, :password=, :start, :stop, - :perform_put, :perform_get, :interrupt, - :route, :rewrite, :accept, :reject, - :incoming_window=, :outgoing_window=] - - # Creates a new +Messenger+. - # - # The +name+ parameter is optional. If one is not provided then - # a unique name is generated. - # - # Options - # - # * name - the name (def. nil) - # - def initialize(name = nil) -@impl = Cproton.pn_messenger(name) -@selectables = {} -ObjectSpace.define_finalizer(self, self.class.finalize!(@impl)) - end - - def self.finalize!(impl) # :nodoc: -proc { - Cproton.pn_messenger_free(impl) -} - end - - # Returns the name. - # - def name -Cproton.pn_messenger_name(@impl) - end - - # This property contains the password for the Messenger.private_key - # file, or +nil+ if the file is not encrypted. - # - # Arguments - # - # * password - the password - # - def password=(password) -Cproton.pn_messenger_set_password(@impl, password) - end - - # Returns the password property for the Messenger.private_key file. - # - def password -Cproton.pn_messenger_get_password(@impl) - end - - # Sets the timeout period, in milliseconds. - # - # A negative timeout period implies an infinite timeout. - # - # Options - # - # * timeout - the timeout period - # - def timeout=(timeout) -raise TypeError.new("invalid timeout: #{timeout}") if timeout.nil? -Cproton.pn_messenger_set_timeout(@impl, timeout) - end - - # Returns the timeout period - # - def timeout -Cproton.pn_messenger_g
[13/34] qpid-proton git commit: PROTON-799: Added the UUID mixin for the Ruby reactive APIs.
PROTON-799: Added the UUID mixin for the Ruby reactive 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/8344ba64 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8344ba64 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8344ba64 Branch: refs/heads/master Commit: 8344ba64e5abc33bb31f42d2982b7550c7d49a10 Parents: bab61a2 Author: Darryl L. Pierce Authored: Thu Feb 26 11:29:07 2015 -0500 Committer: Darryl L. Pierce Committed: Wed Jun 3 16:29:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 3 +++ proton-c/bindings/ruby/lib/util/uuid.rb | 32 ++ 2 files changed, 35 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8344ba64/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 bcc7edd..80565dd 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -22,6 +22,8 @@ require "date" if RUBY_VERSION < "1.9" require "kconv" +else + require "securerandom" end # Exception classes @@ -33,6 +35,7 @@ require "util/error_handler" require "util/constants" require "util/swig_helper" require "util/engine" +require "util/uuid" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8344ba64/proton-c/bindings/ruby/lib/util/uuid.rb -- diff --git a/proton-c/bindings/ruby/lib/util/uuid.rb b/proton-c/bindings/ruby/lib/util/uuid.rb new file mode 100644 index 000..882715b --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/uuid.rb @@ -0,0 +1,32 @@ +#-- +# 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::Util + + module UUID + +def generate_uuid + # generate a UUID based on what APIs are available with the current + # version of Ruby + SecureRandom.uuid +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
Git Push Summary
Repository: qpid-proton Updated Branches: refs/heads/ruby-engine-apis [deleted] ed9ecab07 - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[2/4] qpid-proton git commit: PROTON-897: Enhance the Ruby examples and README file.
PROTON-897: Enhance the Ruby examples and README file. Added README.md with the goal of turning the examples into a simple conversation about how to use the Ruby examples. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ac4731f1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ac4731f1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ac4731f1 Branch: refs/heads/master Commit: ac4731f194a4054525938699475d41398f86fdcb Parents: 89ef63b Author: Darryl L. Pierce Authored: Tue May 26 15:33:04 2015 -0400 Committer: Darryl L. Pierce Committed: Thu Jun 4 08:28:46 2015 -0400 -- examples/ruby/messenger/README.md | 163 + 1 file changed, 163 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ac4731f1/examples/ruby/messenger/README.md -- diff --git a/examples/ruby/messenger/README.md b/examples/ruby/messenger/README.md new file mode 100644 index 000..7cc8dee --- /dev/null +++ b/examples/ruby/messenger/README.md @@ -0,0 +1,163 @@ +## Simple Messenger Examples + +The Messenger APIs, contained in the Qpid::Proton::Messenger class, represent the simplest means for sending and receive messages. An application need only create an instance of Messenger to have an endpoint for sending and receiving messages. + +Example applications, currently located in the messenger subdirectory, include: + +* **send.rb** - Sends one or more messages to a specific address. +* **recv.rb** - Listens for messages sent to one or more addresses. + +### Sending A Simple Message Directly (Without A Broker) + +The goal of this example is to demonstrate how to send and receive messages directly between applications. To do that we've broken out the examples into two applciations: **send.rb** and **recv.rb**. + +First we need to start the receiver who will listen for an incoming connection: + +``` + $ ruby recv.rb ~0.0.0.0: +``` + +**NOTE:** Be sure to include the **tilda (~)** at the beginning of each address to be used. This tells the Messenger that it's going to be listening for connections on that port. And be sure to pick a free port for each of the addresses used. + +Now you can send messages with: + +``` + $ ruby send.rb -a 0.0.0.0: "Hello world" +``` + +**NOTE:** Here you *don't* use a **tilda (~)** at the beginning of the address since you're specifying the receiver address rather than the address on which to listen. + +On the receiver side you should see something like: + +``` +Address: 0.0.0.0: +Subject: How are you? +Body: This is a test. +Properties: {"sent"=>1432651492, "hostname"=>"mcpierce-laptop"} +Instructions: {"fold"=>"yes", "spindle"=>"no", "mutilate"=>"no"} +Annotations: {"version"=>1.0, "pill"=>"RED"} + +``` + +This tells us the message we received as expected. + +### Sending A Simple Message Through A Broker + +To send a message via an intermediary, such as the Qpid broker, we need to give both the sender and the receiver a little bit more information, such as the hostname and port for the broker and the name of the queue where messages will be sent and received. + +If you're using the Qpid broker, this can be done using the **qpid-config** +tool. Simply start your broker and then create our queue, which we'll call "examples": + +``` + $ qpid-config add queue examples +``` + +As of this point you can begin sending messages *without* starting the receiver. This is the benefit of using a broker, the ability to have something store messages for retrieval. + +Now let's send a bunch of messages to the queue using **send.rb**: + +``` + $ for which in $(seq 1 10); do ruby send.rb --address amqp://localhost/examples "This is test ${which}."; done +``` + +This example sends 10 messages to the our queue on the broker, where they will stay until retrieved. + +With this scenario we needed to specify the hostname of the broker and also the name of the queue in the address. After the sending completes you can verify the content of the queue using the **qpid-stat** command: + +``` +$ qpid-stat -q +Queues + queue dur autoDel excl msg msgIn msgOut bytes bytesIn bytesOut cons bind + = + examples1010 02.65k 2.65k 0 0 1 + fa4b8acb-03b6-4cff-9277-eeb2efe3c88a:0.0 YY
[4/4] qpid-proton git commit: PROTON-898: Update Ruby bindings to use pn_selectable_get_fd
PROTON-898: Update Ruby bindings to use pn_selectable_get_fd Also removed references to pending and capacity. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/caaabb7b Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/caaabb7b Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/caaabb7b Branch: refs/heads/master Commit: caaabb7bd225aae8d3699ce138ef43c1083782a6 Parents: b49e518 Author: Darryl L. Pierce Authored: Mon Jun 1 13:48:09 2015 -0400 Committer: Darryl L. Pierce Committed: Thu Jun 4 09:11:58 2015 -0400 -- examples/ruby/messenger/nonblocking_recv.rb| 7 ++- proton-c/bindings/ruby/lib/messenger/selectable.rb | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/caaabb7b/examples/ruby/messenger/nonblocking_recv.rb -- diff --git a/examples/ruby/messenger/nonblocking_recv.rb b/examples/ruby/messenger/nonblocking_recv.rb index 2868b52..09dc3f9 100644 --- a/examples/ruby/messenger/nonblocking_recv.rb +++ b/examples/ruby/messenger/nonblocking_recv.rb @@ -76,8 +76,6 @@ loop do write_array.delete(sel) sel.free else - sel.capacity - sel.pending if !sel.registered? read_array << sel write_array << sel @@ -102,8 +100,8 @@ loop do result.flatten.each do |io| sel = selectables[io.fileno] -sel.writable if sel.pending > 0 -sel.readable if sel.capacity > 0 +sel.writable +sel.readable end end @@ -145,4 +143,3 @@ loop do end messenger.stop - http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/caaabb7b/proton-c/bindings/ruby/lib/messenger/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb index 9a61317..ec5174f 100644 --- a/proton-c/bindings/ruby/lib/messenger/selectable.rb +++ b/proton-c/bindings/ruby/lib/messenger/selectable.rb @@ -44,7 +44,7 @@ module Qpid::Proton::Messenger # This can be used in conjunction with the IO class. # def fileno - Cproton.pn_selectable_fd(@impl) + Cproton.pn_selectable_get_fd(@impl) end def to_io - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[1/4] qpid-proton git commit: PROTON-897: Renamed passive_recv.rb to nonblocking_recv.rb
Repository: qpid-proton Updated Branches: refs/heads/master 89ef63b46 -> caaabb7bd PROTON-897: Renamed passive_recv.rb to nonblocking_recv.rb The name is a little more specific as to what the example shows. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/267072da Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/267072da Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/267072da Branch: refs/heads/master Commit: 267072da7de4d24cad7f9838b917160b3135bd13 Parents: ac4731f Author: Darryl L. Pierce Authored: Mon Jun 1 11:36:15 2015 -0400 Committer: Darryl L. Pierce Committed: Thu Jun 4 08:28:46 2015 -0400 -- examples/ruby/messenger/nonblocking_recv.rb | 140 +++ examples/ruby/messenger/passive_recv.rb | 140 --- 2 files changed, 140 insertions(+), 140 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/267072da/examples/ruby/messenger/nonblocking_recv.rb -- diff --git a/examples/ruby/messenger/nonblocking_recv.rb b/examples/ruby/messenger/nonblocking_recv.rb new file mode 100644 index 000..d1fa854 --- /dev/null +++ b/examples/ruby/messenger/nonblocking_recv.rb @@ -0,0 +1,140 @@ +#!/usr/bin/env ruby +# +# 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. + +require 'qpid_proton' +require 'optparse' + +addresses = [] + +OptionParser.new do |opts| + opts.banner = "Usage: recv.rb ... " + opts.parse! + + addresses = ARGV +end + +addresses = ["~0.0.0.0"] if addresses.empty? + +messenger = Qpid::Proton::Messenger::Messenger.new +messenger.passive = true + +begin + messenger.start +rescue ProtonError => error + puts "ERROR: #{error.message}" + puts error.backtrace.join("\n") + exit +end + +addresses.each do |address| + begin +messenger.subscribe(address) + rescue Qpid::Proton::ProtonError => error +puts "ERROR: #{error.message}" +exit + end +end + +msg = Qpid::Proton::Message.new + +read_array = [] +write_array = [] +selectables = {} + +loop do + + # wait for incoming messages + sel = messenger.selectable + while !sel.nil? +if sel.terminal? + selectables.delete(sel.fileno) + read_array.delete(sel) + write_array.delete(sel) + sel.free +else + sel.capacity + sel.pending + if !sel.registered? +read_array << sel +write_array << sel +selectables[sel.fileno] = sel +sel.registered = true + end +end +sel = messenger.selectable + end + + unless selectables.empty? +rarray = []; read_array.each {|fd| rarray << fd.to_io } +warray = []; write_array.each {|fd| warray << fd.to_io } + +if messenger.deadline > 0.0 + result = IO.select(rarray, warray, nil, messenger.deadline) +else + result = IO.select(rarray, warray) +end + +unless result.nil? && result.empty? + result.flatten.each do |io| +sel = selectables[io.fileno] + +sel.writable if sel.pending > 0 +sel.readable if sel.capacity > 0 + end +end + +begin + messenger.receive(10) +rescue Qpid::Proton::ProtonError => error + puts "ERROR: #{error.message}" + exit +end + +while messenger.incoming.nonzero? + begin +messenger.get(msg) + rescue Qpid::Proton::Error => error +puts "ERROR: #{error.message}" +exit + end + + puts "Address: #{msg.address}" + subject = msg.subject || "(no subject)" + puts "Subject: #{subject}" + puts "Body: #{msg.body}" + puts "Properties: #{msg.properties}" + puts "Instructions: #{msg.instructions}" + puts "Annotations: #{msg.annotations}" + + if msg.reply_to +puts "=== Sending a reply to #{msg.reply_to}" +reply = Qpid::Proton::Message.new +reply.address = msg.reply_to +reply.subject = "RE: #{msg.subject}" +reply.content = "Thanks for the message!" + +messenger.put(reply) +messenger.send + en
[3/4] qpid-proton git commit: PROTON-897: Enhanced the Ruby nonblocking_recv.rb example
PROTON-897: Enhanced the Ruby nonblocking_recv.rb example Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b49e5185 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b49e5185 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b49e5185 Branch: refs/heads/master Commit: b49e5185c3ffe4a935ba51e4ce4a0e6f5f3ec172 Parents: 267072d Author: Darryl L. Pierce Authored: Thu Jun 4 08:29:09 2015 -0400 Committer: Darryl L. Pierce Committed: Thu Jun 4 08:29:09 2015 -0400 -- examples/ruby/messenger/nonblocking_recv.rb | 34 +++- 1 file changed, 21 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b49e5185/examples/ruby/messenger/nonblocking_recv.rb -- diff --git a/examples/ruby/messenger/nonblocking_recv.rb b/examples/ruby/messenger/nonblocking_recv.rb index d1fa854..2868b52 100644 --- a/examples/ruby/messenger/nonblocking_recv.rb +++ b/examples/ruby/messenger/nonblocking_recv.rb @@ -20,6 +20,14 @@ require 'qpid_proton' require 'optparse' +Thread.new do + print "This is a side thread:\n" + loop do +print "The time is now #{Time.new.strftime('%I:%M:%S')}.\n" +sleep 1 + end +end + addresses = [] OptionParser.new do |opts| @@ -37,8 +45,8 @@ messenger.passive = true begin messenger.start rescue ProtonError => error - puts "ERROR: #{error.message}" - puts error.backtrace.join("\n") + print "ERROR: #{error.message}\n" + print error.backtrace.join("\n") exit end @@ -46,7 +54,7 @@ addresses.each do |address| begin messenger.subscribe(address) rescue Qpid::Proton::ProtonError => error -puts "ERROR: #{error.message}" +print "ERROR: #{error.message}\n" exit end end @@ -102,7 +110,7 @@ loop do begin messenger.receive(10) rescue Qpid::Proton::ProtonError => error - puts "ERROR: #{error.message}" + print "ERROR: #{error.message}\n" exit end @@ -110,24 +118,24 @@ loop do begin messenger.get(msg) rescue Qpid::Proton::Error => error -puts "ERROR: #{error.message}" +print "ERROR: #{error.message}\n" exit end - puts "Address: #{msg.address}" + print "Address: #{msg.address}\n" subject = msg.subject || "(no subject)" - puts "Subject: #{subject}" - puts "Body: #{msg.body}" - puts "Properties: #{msg.properties}" - puts "Instructions: #{msg.instructions}" - puts "Annotations: #{msg.annotations}" + print "Subject: #{subject}\n" + print "Body: #{msg.body}\n" + print "Properties: #{msg.properties}\n" + print "Instructions: #{msg.instructions}\n" + print "Annotations: #{msg.annotations}\n" if msg.reply_to -puts "=== Sending a reply to #{msg.reply_to}" +print "=== Sending a reply to #{msg.reply_to}\n" reply = Qpid::Proton::Message.new reply.address = msg.reply_to reply.subject = "RE: #{msg.subject}" -reply.content = "Thanks for the message!" +reply.body = "Thanks for the message!" messenger.put(reply) messenger.send - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[16/31] qpid-proton git commit: PROTON-781: Added the URL class to the Ruby core APIs.
PROTON-781: Added the URL class to the Ruby core 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/5504a7ab Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5504a7ab Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5504a7ab Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 5504a7abca68cd303fc8273b438c5a08d9d1b36e Parents: 953ba96 Author: Darryl L. Pierce Authored: Wed Mar 4 16:36:39 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/core/url.rb| 77 ++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 78 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5504a7ab/proton-c/bindings/ruby/lib/core/url.rb -- diff --git a/proton-c/bindings/ruby/lib/core/url.rb b/proton-c/bindings/ruby/lib/core/url.rb new file mode 100644 index 000..a68811a --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/url.rb @@ -0,0 +1,77 @@ +#-- +# 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 + + class URL + +attr_reader :scheme +attr_reader :username +attr_reader :password +attr_reader :host +attr_reader :port +attr_reader :path + +def initialize(url = nil, options = {}) + options[:defaults] = true + + if url +@url = Cproton.pn_url_parse(url) +if @url.nil? + raise ArgumentError.new("invalid url: #{url}") +end + else +@url = Cproton.pn_url + end + @scheme = Cproton.pn_url_get_scheme(@url) + @username = Cproton.pn_url_get_username(@url) + @password = Cproton.pn_url_get_password(@url) + @host = Cproton.pn_url_get_host(@url) + @port = Cproton.pn_url_get_port(@url) + @path = Cproton.pn_url_get_path(@url) + defaults +end + +def port=(port) + if port.nil? +Cproton.pn_url_set_port(@url, nil) + else +Cproton.pn_url_set_port(@url, port) + end +end + +def port + Cproton.pn_url_get_port(@url).to_i +end + +def to_s + "#{@scheme}://#{@username.nil? ? '' : @username}#{@password.nil? ? '' : '@' + @password + ':'}#{@host}:#{@port}/#{@path}" +end + +private + +def defaults + @scheme = @scheme || "ampq" + @host = @host || "0.0.0.0" + @port = @port || 5672 +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5504a7ab/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 33fe9b6..11a555f 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -78,6 +78,7 @@ require "core/ssl_details" require "core/ssl" require "core/transport" require "core/base_handler" +require "core/url" # Messenger API classes require "messenger/subscription" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[15/31] qpid-proton git commit: PROTON-781: Added the Reactor mixin to the Ruby reactive APIs.
PROTON-781: Added the Reactor mixin to the Ruby reactive 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/5fc194ad Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5fc194ad Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5fc194ad Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 5fc194adfea522fa36031f7648986e271357a7f7 Parents: f69b972 Author: Darryl L. Pierce Authored: Wed Mar 4 16:37:12 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/reactor.rb | 32 + 2 files changed, 33 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5fc194ad/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 03f5632..33fe9b6 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -42,6 +42,7 @@ require "util/engine" require "util/uuid" require "util/timeout" require "util/handler" +require "util/reactor" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5fc194ad/proton-c/bindings/ruby/lib/util/reactor.rb -- diff --git a/proton-c/bindings/ruby/lib/util/reactor.rb b/proton-c/bindings/ruby/lib/util/reactor.rb new file mode 100644 index 000..0bcb557 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/reactor.rb @@ -0,0 +1,32 @@ +#-- +# 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::Util + + module Reactor + +def create_session(connection, handler = nil) + session = connection.session + session.open + return session +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[30/31] qpid-proton git commit: PROTON-781: Ruby registry and memory management testing
PROTON-781: Ruby registry and memory management testing Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/81c5cbd1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/81c5cbd1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/81c5cbd1 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 81c5cbd178141c959662a1c776a1df98556a90e0 Parents: 3d94612 Author: Darryl L. Pierce Authored: Fri May 8 10:54:13 2015 -0400 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- examples/ruby/registry_test.rb | 76 + 1 file changed, 76 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/81c5cbd1/examples/ruby/registry_test.rb -- diff --git a/examples/ruby/registry_test.rb b/examples/ruby/registry_test.rb new file mode 100644 index 000..b4b1f6c --- /dev/null +++ b/examples/ruby/registry_test.rb @@ -0,0 +1,76 @@ +#-- +# 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. +#++ + +require 'qpid_proton' +require 'weakref' + +def show_registry(registry) + registry.each_pair do |key, value| +registry.delete(key) if value.weakref_alive? + end + puts "The contents of the registry: size=#{registry.size}" +end + +def show_object_count(clazz) + puts "There are #{ObjectSpace.each_object(clazz).count} instances of #{clazz}." +end + +impl = Cproton.pn_transport +implclazz = impl.class +transport = Qpid::Proton::Transport.wrap(impl) + +puts "Initial setup:" +show_object_count(Qpid::Proton::Transport) +show_object_count(implclazz) + +transport = nil + +show_registry(Qpid::Proton.registry) + +ObjectSpace.garbage_collect + +puts "After garbage collection:" +show_object_count(Qpid::Proton::Transport) +show_object_count(implclazz) + +MAXCOUNT=10 +(1..MAXCOUNT).each do |which| + nimpl = Cproton.pn_transport + Cproton.pn_incref(nimpl) + transport = Qpid::Proton::Transport.wrap(nimpl) + transport = Qpid::Proton::Transport.wrap(nimpl) +end + +transport = nil + +puts "After creating #{MAXCOUNT} instances" +show_object_count(Qpid::Proton::Transport) +show_object_count(implclazz) +show_registry(Qpid::Proton.registry) + +ObjectSpace.garbage_collect + +transport = Qpid::Proton::Transport.wrap(impl) + +puts "After garbage collection:" +puts "impl=#{impl}" +puts "transport=#{transport}" +show_object_count(Qpid::Proton::Transport) +show_object_count(implclazz) +show_registry(Qpid::Proton.registry) - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[07/31] qpid-proton git commit: PROTON-781: Added the CFlowController class to the Ruby reactive APIs.
PROTON-781: Added the CFlowController class to the Ruby reactive 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/b65cd5e1 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b65cd5e1 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b65cd5e1 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: b65cd5e1c7f1525d00226fe6332b1da4762e31e4 Parents: 43970df Author: Darryl L. Pierce Authored: Wed Feb 25 13:29:22 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- .../ruby/lib/handler/c_flow_controller.rb | 33 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 34 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b65cd5e1/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb new file mode 100644 index 000..377cc2f --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb @@ -0,0 +1,33 @@ +#-- +# 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::Handler + + # @private + class CFlowController < Qpid::Proton::Handler::WrappedHandler + +include Qpid::Proton::Util::Wrapper + +def initialize(window = 1024) + super(Cproton.pn_flowcontroller(window)) +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b65cd5e1/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 08e60b9..e14ff9d 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -86,6 +86,7 @@ require "handler/c_adaptor" require "handler/wrapped_handler" require "handler/acking" require "handler/endpoint_state_handler" +require "handler/c_flow_controller" module Qpid::Proton # @private - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[19/31] qpid-proton git commit: PROTON-781: Added reactor support to the Ruby Event class.
PROTON-781: Added reactor support to the Ruby Event class. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1383abf3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1383abf3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1383abf3 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 1383abf33d5874c7f482f67734b1c7c4343163f8 Parents: 1573e5b Author: Darryl L. Pierce Authored: Mon May 18 15:02:18 2015 -0400 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/event/event.rb | 38 -- 1 file changed, 30 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1383abf3/proton-c/bindings/ruby/lib/event/event.rb -- diff --git a/proton-c/bindings/ruby/lib/event/event.rb b/proton-c/bindings/ruby/lib/event/event.rb index dd5d869..e839f63 100644 --- a/proton-c/bindings/ruby/lib/event/event.rb +++ b/proton-c/bindings/ruby/lib/event/event.rb @@ -37,6 +37,13 @@ module Qpid::Proton # be generated. NONE = event_type(:PN_EVENT_NONE) +# A reactor has been started. +REACTOR_INIT = event_type(:PN_REACTOR_INIT) +# A reactor has no more events to process. +REACTOR_QUIESCED = event_type(:PN_REACTOR_QUIESCED) +# A reactor has been stopred. +REACTOR_FINAL = event_type(:PN_REACTOR_FINAL) + # A timer event has occurred. TIMER_TASK = event_type(:PN_TIMER_TASK) @@ -199,17 +206,32 @@ module Qpid::Proton # def dispatch(handler, type = nil) type = @type if type.nil? -#notify any and all attached handlers -if handler.respond_to?(:handlers?) && handler.handlers? - handler.handlers.each {|hndlr| self.dispatch(hndlr, type)} -end -if handler.respond_to?(type.method) - handler.__send__(type.method, self) -elsif handler.respond_to?(:on_unhandled) - handler.on_unhandled(self) +if handler.is_a?(Qpid::Proton::Handler::WrappedHandler) + Cproton.pn_handler_dispatch(handler.impl, @impl, type.number) +else + result = Qpid::Proton::Event.dispatch(handler, type.method, self) + if (result != "DELEGATED") && handler.respond_to?(:handlers) +handler.handlers.each do |hndlr| + self.dispatch(hndlr) +end + end end end + # Returns the reactor for this event. + # + # @return [Reactor, nil] The reactor. + # + def reactor +impl = Cproton.pn_event_reactor(@impl) +Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl) + end + + def container +impl = Cproton.pn_event_reactor(@impl) +Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl) + end + # Returns the transport for this event. # # @return [Transport, nil] The transport. - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[11/31] qpid-proton git commit: PROTON-781: Added OutgoingMessageHandler to the Ruby reactive APIs.
PROTON-781: Added OutgoingMessageHandler to the Ruby reactive 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/9eaa62ae Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9eaa62ae Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9eaa62ae Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 9eaa62ae275d619b0332af7da9f95f5298891d10 Parents: 498225e Author: Darryl L. Pierce Authored: Thu Feb 26 09:59:18 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- .../lib/handler/outgoing_message_handler.rb | 98 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 99 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9eaa62ae/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb new file mode 100644 index 000..056a131 --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb @@ -0,0 +1,98 @@ +#-- +# 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::Handler + + # A utility for simpler and more intuitive handling of delivery events + # related to outgoing messages. + # + class OutgoingMessageHandler < Qpid::Proton::BaseHandler + +def initialize(auto_settle = true, delegate = nil) + @auto_settle = auto_settle + @delegate = delegate +end + +def on_link_flow(event) + self.on_sendable(event) if event.link.sender? && event.link.credit > 0 +end + +def on_delivery(event) + delivery = event.delivery + if delivery.link.sender? && delivery.updated? +if delivery.remote_accepted? + self.on_accepted(event) +elsif delivery.remote_rejected? + self.on_rejected(event) +elsif delivery.remote_released? || delivery.remote_modified? + self.on_released(event) +end +self.on_settled(event) if delivery.settled? +delivery.settle if @auto_settle + end +end + +# Called when the sender link has credit and messages and be transferred. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_sendable(event) + Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil? +end + +# Called when the remote peer accepts a sent message. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_accepted(event) + Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil? +end + +# Called when the remote peer rejects a sent message. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_rejected(event) + Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil? +end + +# Called when the remote peer releases an outgoing message. +# +# Note that this may be in resposnse to either the REELAASE or MODIFIED +# state as defined by the AMQP specification. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_released(event) + Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil? +end + +# Called when the remote peer has settled the outgoing message. +# +# This is the point at which it should never be retransmitted. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_settled(event) + Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9eaa62ae/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.
[21/31] qpid-proton git commit: PROTON-781: Added the Handler mixin to the Ruby reactive APIs.
PROTON-781: Added the Handler mixin to the Ruby reactive 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/f69b9727 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f69b9727 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f69b9727 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: f69b9727f85768c07a46cd3759cc3c7bb342472c Parents: 5b72338 Author: Darryl L. Pierce Authored: Wed Mar 4 08:06:19 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/handler.rb | 41 + 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f69b9727/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 0c84f20..03f5632 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -41,6 +41,7 @@ require "util/class_wrapper" require "util/engine" require "util/uuid" require "util/timeout" +require "util/handler" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f69b9727/proton-c/bindings/ruby/lib/util/handler.rb -- diff --git a/proton-c/bindings/ruby/lib/util/handler.rb b/proton-c/bindings/ruby/lib/util/handler.rb new file mode 100644 index 000..e7d07b1 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/handler.rb @@ -0,0 +1,41 @@ +#-- +# 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::Util + + # @private + module Handler + +def chandler(handler, on_error) + return nil if handler.nil? + + if handler.instance_of?(Qpid::Proton::Handler::WrappedHandler) +impl = handler.impl +Cproton.pn_incref(impl) +return impl + else +cadaptor = Qpid::Proton::Handler::CAdaptor.new(handler, on_error) +rbhandler = Cproton.pn_rbhandler(cadaptor) +return rbhandler + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[28/31] qpid-proton git commit: PROTON-781: Added Reactor and Task to the ClassWrapper
PROTON-781: Added Reactor and Task to the ClassWrapper Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/953ba96f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/953ba96f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/953ba96f Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 953ba96fab906233a5522ce61881d7f5110375d1 Parents: 5fc194a Author: Darryl L. Pierce Authored: Wed Mar 4 10:54:54 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/util/class_wrapper.rb | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/953ba96f/proton-c/bindings/ruby/lib/util/class_wrapper.rb -- diff --git a/proton-c/bindings/ruby/lib/util/class_wrapper.rb b/proton-c/bindings/ruby/lib/util/class_wrapper.rb index 134f655..dec16e9 100644 --- a/proton-c/bindings/ruby/lib/util/class_wrapper.rb +++ b/proton-c/bindings/ruby/lib/util/class_wrapper.rb @@ -36,6 +36,8 @@ module Qpid::Proton::Util "pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))}, "pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))}, "pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))}, +"pn_reactor" => proc {|x| Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_cast_pn_reactor(x))}, +"pn_task" => proc {|x| Qpid::Proton::Reactor::Task.wrap(Cproton.pn_cast_pn_task(x))}, } def class_wrapper(clazz, c_impl, &block) - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[01/31] qpid-proton git commit: PROTON-781: Added the Task class to the Ruby reactor APIs.
Repository: qpid-proton Updated Branches: refs/heads/PROTON-781-ruby-reactor-apis [created] f63454c5c PROTON-781: Added the Task class to the Ruby reactor 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/44d062c4 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/44d062c4 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/44d062c4 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 44d062c43979c2147a8c2ebe9d3e3c885c0b6869 Parents: 271b3a0 Author: Darryl L. Pierce Authored: Mon Feb 23 16:19:33 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 3 ++ proton-c/bindings/ruby/lib/reactor/task.rb | 39 + 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/44d062c4/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 a60a028..f3da844 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -92,6 +92,9 @@ require "handler/outgoing_message_handler" require "handler/c_flow_controller" require "handler/messaging_handler" +# Reactor classes +require "reactor/task" + module Qpid::Proton # @private def self.registry http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/44d062c4/proton-c/bindings/ruby/lib/reactor/task.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/task.rb b/proton-c/bindings/ruby/lib/reactor/task.rb new file mode 100644 index 000..6818ed2 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/task.rb @@ -0,0 +1,39 @@ +#-- +# 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 Task + +# @private +include Qpid::Proton::Util::Wrapper + +def self.wrap(impl) + return nil if impl.nil? + self.fetch_instance(impl, :pn_task_attachments) || Task.new(impl) +end + +def initialize(impl) + @impl = impl + self.class.store_instance(self, :pn_task_attachments) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[02/31] qpid-proton git commit: PROTON-781: Added the BaseHandler class to the Ruby reactive APIs.
PROTON-781: Added the BaseHandler class to the Ruby reactive APIs. This is the Ruby analog to the Handler class from Python. It needed to be renamed, though, since it's in the Qpid::Proton namespace but would collide with the Qpid::Proton::Handler namespace. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/31791164 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/31791164 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/31791164 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 3179116427fcac4c4ff24cbae1e70965b09d955f Parents: b65cd5e Author: Darryl L. Pierce Authored: Wed Feb 25 13:30:30 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/core/base_handler.rb | 31 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 32 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31791164/proton-c/bindings/ruby/lib/core/base_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/core/base_handler.rb b/proton-c/bindings/ruby/lib/core/base_handler.rb new file mode 100644 index 000..9a7ece4 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/base_handler.rb @@ -0,0 +1,31 @@ +#-- +# 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 + + class BaseHandler + +# Override to process unhandled events. +# +def on_unhandled(method, *args) +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31791164/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 e14ff9d..ef7f300 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -74,6 +74,7 @@ require "core/ssl_domain" require "core/ssl_details" require "core/ssl" require "core/transport" +require "core/base_handler" # Messenger API classes require "messenger/subscription" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[12/31] qpid-proton git commit: PROTON-781: Added IncomingMessageHandler to the Ruby reactive APIs.
PROTON-781: Added IncomingMessageHandler to the Ruby reactive 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/498225e7 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/498225e7 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/498225e7 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 498225e77c61aa3e9bf642c63b1c66d6cde47357 Parents: 3179116 Author: Darryl L. Pierce Authored: Thu Feb 26 09:23:00 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/core/exceptions.rb | 10 +++ .../lib/handler/incoming_message_handler.rb | 74 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 3 files changed, 85 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/498225e7/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 94d2957..75d6552 100644 --- a/proton-c/bindings/ruby/lib/core/exceptions.rb +++ b/proton-c/bindings/ruby/lib/core/exceptions.rb @@ -111,6 +111,16 @@ module Qpid class SSLUnavailableError < SSLError end +# Raised when a message is rejected. +# +class Reject < ProtonError +end + +# Raised when a message is released. +# +class Release < ProtonError +end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/498225e7/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb b/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb new file mode 100644 index 000..ced84a2 --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/incoming_message_handler.rb @@ -0,0 +1,74 @@ +#-- +# 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::Handler + + # A utility for simpler and more intuitive handling of delivery events + # related to incoming messages. + # + class IncomingMessageHandler < Qpid::Proton::BaseHandler + +include Acking + +def initialize(auto_accept = true, delegate = nil) + @delegate = delegate + @auto_accept = auto_accept +end + +def on_delivery(event) + delivery = event.delivery + return unless delivery.link.receiver? + if delivery.readable? && !delivery.partial? +event.message = Qpid::Proton::Util::Engine.receive_message(delivery) +if event.link.local_closed? + if @auto_accept +delivery.update(Qpid::Proton::Disposition::RELEASED) +delivery.settle + end +else + begin +self.on_message(event) +if @auto_accept + delivery.update(Qpid::Proton::Disposition::ACCEPTED) + delivery.settle +end + rescue Qpid::Proton::Reject +delivery.update(Qpid::Proton::Disposition::REJECTED) +delivery.settle + rescue Qpid::Proton::Release +delivery.update(Qpid::Proton::Disposition::MODIFIED) +delivery.settle + end +end + elsif delivery.updated? && delivery.settled? +self.on_settled(event) + end +end + +def on_message(event) + Qpid::Proton::Event.dispatch(@delegate, :on_message, event) if !@delegate.nil? +end + +def on_settled(event) + Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/498225e7/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 ef7f300..1fbf710 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c
[23/31] qpid-proton git commit: PROTON-781: Added SessionPerConnection to the Ruby reactive APIs.
PROTON-781: Added SessionPerConnection to the Ruby reactive 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/aa8222e0 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/aa8222e0 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/aa8222e0 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: aa8222e093c2035b9d21042d1fb58c85bec643a8 Parents: ca7f8f9 Author: Darryl L. Pierce Authored: Wed Mar 4 16:40:01 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + .../ruby/lib/reactor/session_per_connection.rb | 45 2 files changed, 46 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aa8222e0/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 661927e..f40c608 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -105,6 +105,7 @@ require "reactor/global_overrides" require "reactor/urls" require "reactor/connector" require "reactor/backoff" +require "reactor/session_per_connection" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/aa8222e0/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb b/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb new file mode 100644 index 000..f8180c0 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb @@ -0,0 +1,45 @@ +#-- +# 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 SessionPerConnection + +include Qpid::Proton::Util::Reactor + +def initialize + @default_session = nil +end + +def session(connection) + if @default_session.nil? +@default_session = self.create_session +@default_session.context = self + end + return @default_session +end + +def on_session_remote_close(event) + event.connection.close + @default_session = nil +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[17/31] qpid-proton git commit: PROTON-781: Added Acceptor to the Ruby reactive APIs.
PROTON-781: Added Acceptor to the Ruby reactive 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/0f45ba0f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0f45ba0f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0f45ba0f Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 0f45ba0f614438720cd16ba53d9e89e017b5779d Parents: 44d062c Author: Darryl L. Pierce Authored: Fri Feb 27 10:14:57 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/acceptor.rb | 41 + 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f45ba0f/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 f3da844..bffd4d1 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -94,6 +94,7 @@ require "handler/messaging_handler" # Reactor classes require "reactor/task" +require "reactor/acceptor" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f45ba0f/proton-c/bindings/ruby/lib/reactor/acceptor.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/acceptor.rb b/proton-c/bindings/ruby/lib/reactor/acceptor.rb new file mode 100644 index 000..83e0596 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/acceptor.rb @@ -0,0 +1,41 @@ +#-- +# 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 Acceptor + +include Qpid::Proton::Util::Wrapper + +def initialize(impl) + @impl = impl + self.class.store_instance(self) +end + +def set_ssl_domain(ssl_domain) + Cproton.pn_acceptor_set_ssl_domain(@impl, ssl_domain.impl) +end + +def close + Cproton.pn_acceptor_close(@impl) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[05/31] qpid-proton git commit: PROTON-781: Added the WrappedHandler class to the Ruby reactor APIs.
PROTON-781: Added the WrappedHandler class to the Ruby reactor 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/e77477b9 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e77477b9 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e77477b9 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: e77477b93b27a32eebc52dbde5c6793c5e6e42b6 Parents: d921c6b Author: Darryl L. Pierce Authored: Mon Feb 23 16:18:01 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/handler/c_adaptor.rb | 47 .../ruby/lib/handler/wrapped_handler.rb | 76 proton-c/bindings/ruby/lib/qpid_proton.rb | 4 ++ proton-c/bindings/ruby/ruby.i | 53 ++ 4 files changed, 180 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e77477b9/proton-c/bindings/ruby/lib/handler/c_adaptor.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/c_adaptor.rb b/proton-c/bindings/ruby/lib/handler/c_adaptor.rb new file mode 100644 index 000..ef4852e --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/c_adaptor.rb @@ -0,0 +1,47 @@ +#-- +# 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::Handler + + # @private + class CAdaptor + +def initialize(handler, on_error = nil) + @handler = handler + @on_error = on_error +end + +def dispatch(cevent, ctype) + event = Qpid::Proton::Event::Event.wrap(cevent, ctype) + # TODO add a variable to enable this programmatically + # print "EVENT: #{event} going to #{@handler}\n" + event.dispatch(@handler) +end + +def exception(error) + if @on_error.nil? +raise error + else +@on_error.call(error) + end +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e77477b9/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb b/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb new file mode 100644 index 000..6d55dee --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/wrapped_handler.rb @@ -0,0 +1,76 @@ +#-- +# 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::Handler + + class WrappedHandler + +# @private +include Qpid::Proton::Util::Wrapper + +def self.wrap(impl, on_error = nil) + return nil if impl.nil? + + result = self.fetch_instance(impl) || WrappedHandler.new(impl) + result.on_error = on_error + return result +end + +include Qpid::Proton::Util::Handler + +def initialize(impl_or_constructor) + if impl_or_constructor.is_a?(Method) +@impl = impl_or_constructor.call + else +@impl = impl_or_constructor +Cproton.pn_incref(@impl) + end + @on_error = nil + self.class.store_instance(self) +end + +def add(handler) + return if handler.nil? + + impl = chandler(handler, self.method(:_on_error)) + Cproton.pn_handler_add(@impl, impl) + Cproton.pn_decref(impl) +end + +
[27/31] qpid-proton git commit: PROTON-781: Added SSLConfig to the Ruby reactive APIs.
PROTON-781: Added SSLConfig to the Ruby reactive 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/cb84a677 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cb84a677 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cb84a677 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: cb84a677606a3265c73ec9ae07f3c96e964aa143 Parents: 1383abf Author: Darryl L. Pierce Authored: Thu Feb 26 11:28:04 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + .../bindings/ruby/lib/reactor/ssl_config.rb | 41 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cb84a677/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 f8703e7..d8783bc 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -96,6 +96,7 @@ require "handler/messaging_handler" require "reactor/task" require "reactor/acceptor" require "reactor/reactor" +require "reactor/ssl_config" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cb84a677/proton-c/bindings/ruby/lib/reactor/ssl_config.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/ssl_config.rb b/proton-c/bindings/ruby/lib/reactor/ssl_config.rb new file mode 100644 index 000..56fec71 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/ssl_config.rb @@ -0,0 +1,41 @@ +#-- +# 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 SSLConfig + +def initialize + @client = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_CLIENT) + @server = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_SERVER) +end + +def set_credentials(cert_file, key_file, password) + @client.set_credentials(cert_file, key_file, password) + @server.set_credentials(cert_file, key_file, password) +end + +def set_trusted_ca_db(certificate_db) + @client.set_trusted_ca_db(certificate_db) + @server.set_trusted_ca_db(certificate_db) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[04/31] qpid-proton git commit: PROTON-781: Deleted the Ruby Filter mixin.
PROTON-781: Deleted the Ruby Filter mixin. It was only used by Selectable, which is being refactored based on the new underlying C Selectable type. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/4dffce64 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4dffce64 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4dffce64 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 4dffce64ff5f4e706043686fce781580322b7acb Parents: e77477b Author: Darryl L. Pierce Authored: Tue Feb 24 10:55:25 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/messenger/filters.rb | 64 .../bindings/ruby/lib/messenger/selectable.rb | 6 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 - 3 files changed, 71 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4dffce64/proton-c/bindings/ruby/lib/messenger/filters.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/filters.rb b/proton-c/bindings/ruby/lib/messenger/filters.rb deleted file mode 100644 index 0ab3407..000 --- a/proton-c/bindings/ruby/lib/messenger/filters.rb +++ /dev/null @@ -1,64 +0,0 @@ -#-- -# 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::Messenger - - # @private - module Filters - -def self.included(base) - base.class_eval do -extend ClassMethods - end -end - -module ClassMethods - - def method_added(method_name) -@@hooked_methods ||= [] -return if @@hooked_methods.include?(method_name) -@@hooked_methods << method_name -hooks = @@before_hooks[method_name] -return if hooks.nil? -orig_method = instance_method(method_name) -define_method(method_name) do |*args, &block| - hooks = @@before_hooks[method_name] - hooks.each do |hook| -method(hook).call - end - - orig_method.bind(self).call(*args, &block) -end - end - - def call_before(before_method, *methods) -@@before_hooks ||= {} -methods.each do |method| - hooks = @@before_hooks[method] || [] - raise "Repeat filter: #{before_method}" if hooks.include? before_method - hooks << before_method - @@before_hooks[method] = hooks -end - end - -end - - end - -end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4dffce64/proton-c/bindings/ruby/lib/messenger/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb index ec5174f..da1a3d5 100644 --- a/proton-c/bindings/ruby/lib/messenger/selectable.rb +++ b/proton-c/bindings/ruby/lib/messenger/selectable.rb @@ -25,12 +25,6 @@ module Qpid::Proton::Messenger # @private class Selectable -include Filters - -call_before :check_is_initialized, -:fileno, :capacity, :pending, :deadline, -:readable, :writable, :expired, -:registered=, :registered? def initialize(messenger, impl) # :nodoc: @messenger = messenger http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4dffce64/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 2791538..21f96a1 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -75,7 +75,6 @@ require "core/ssl" require "core/transport" # Messenger API classes -require "messenger/filters" require "messenger/subscription" require "messenger/tracker_status" require "messenger/tracker" - To unsubscribe, e-mail: commits-unsubscr...@qpid.a
[09/31] qpid-proton git commit: PROTON-781: Added the Acking mixin to the Ruby reactive APIs.
PROTON-781: Added the Acking mixin to the Ruby reactive APIs. The Acking mixin provides methods for handling the settling of messages based on reactive callbacks. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9ff3e048 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9ff3e048 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9ff3e048 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 9ff3e048d3f4a0af8bfa76806025f14b6f501f39 Parents: 340a9da Author: Darryl L. Pierce Authored: Wed Feb 25 13:27:30 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/handler/acking.rb | 70 +++ proton-c/bindings/ruby/lib/qpid_proton.rb| 1 + 2 files changed, 71 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9ff3e048/proton-c/bindings/ruby/lib/handler/acking.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/acking.rb b/proton-c/bindings/ruby/lib/handler/acking.rb new file mode 100644 index 000..2c94cfe --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/acking.rb @@ -0,0 +1,70 @@ +#-- +# 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::Handler + + # Mixing that provides methods for acknowledging a delivery. + # + module Acking + +# Accept the receivered message. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# +def accept(delivery) + self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED) +end + +# Rejects a received message that is considered invalid or unprocessable. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# +def reject(delivery) + self.settle(delivery, Qpid::Proton::Delivery::REJECTED) +end + +# Releases a received message, making it available at the source for any +# other interested receiver. +# +# @param delivery [Qpid::Proton::Delivery] The delivery +# @param delivered [Boolean] True if this was considered a delivery +# attempt. +# +def release(delivery, delivered = true) + if delivered +self.settle(delivery, Qpid::Proton::Delivery::MODIFIED) + else +self.settle(delivery, Qpid::Proton::Delivery::RELEASED) + end +end + +# Settles the specified delivery. Updates the delivery state if a state +# is specified. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# @param state [Fixnum] The delivery state. +# +def settle(delivery, state = nil) + delivery.update(state) unless state.nil? + delivery.settle +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9ff3e048/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 a4b3391..8db28f3 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -84,6 +84,7 @@ require "messenger/messenger" # Handler classes require "handler/c_adaptor" require "handler/wrapped_handler" +require "handler/acking" module Qpid::Proton # @private - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[24/31] qpid-proton git commit: PROTON-781: Added Container to the Ruby reactive APIs.
PROTON-781: Added Container to the Ruby reactive 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/b8ba5acb Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b8ba5acb Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b8ba5acb Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: b8ba5acb285d8f540dbf2226bb97cb564e8c09ff Parents: aa8222e Author: Darryl L. Pierce Authored: Thu Feb 26 10:26:11 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/container.rb | 272 +++ 2 files changed, 273 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b8ba5acb/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 f40c608..ba1e66e 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -106,6 +106,7 @@ require "reactor/urls" require "reactor/connector" require "reactor/backoff" require "reactor/session_per_connection" +require "reactor/container" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b8ba5acb/proton-c/bindings/ruby/lib/reactor/container.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/container.rb b/proton-c/bindings/ruby/lib/reactor/container.rb new file mode 100644 index 000..93b49bb --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/container.rb @@ -0,0 +1,272 @@ +#-- +# 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 + + # @private + class InternalTransactionHandler < Qpid::Proton::Handler::OutgoingMessageHandler + +def initialize + super +end + +def on_settled(event) + if event.delivery.respond_to? :transaction +event.transaction = event.delivery.transaction +event.delivery.transaction.handle_outcome(event) + end +end + + end + + + # A representation of the AMQP concept of a container which, loosely + # speaking, is something that establishes links to or from another + # container on which messages are transferred. + # + # This is an extension to the Reactor classthat adds convenience methods + # for creating instances of Qpid::Proton::Connection, Qpid::Proton::Sender + # and Qpid::Proton::Receiver. + # + # @example + # + class Container < Reactor + +include Qpid::Proton::Util::Reactor + +include Qpid::Proton::Util::UUID + +attr_accessor :container_id +attr_accessor :global_handler + +def initialize(handlers, options = {}) + super(handlers, options) + + # only do the following if we're creating a new instance + if !options.has_key?(:impl) +@ssl = SSLConfig.new +if options[:global_handler] + self.global_handler = GlobalOverrides.new(options[:global_handler]) +else + # very ugly, but using self.global_handler doesn't work in the constructor + ghandler = Reactor.instance_method(:global_handler).bind(self).call + ghandler = GlobalOverrides.new(ghandler) + Reactor.instance_method(:global_handler=).bind(self).call(ghandler) +end +@trigger = nil +@container_id = generate_uuid + end +end + +# Initiates the establishment of an AMQP connection. +# +# @param options [Hash] A hash of named arguments. +# +def connect(options = {}) + conn = self.connection(options[:handler]) + conn.container = self.container_id || generate_uuid + connector = Connector.new(conn) + conn.overrides = connector + if !options[:url].nil? +connector.address = URLs.new([options[:url]]) + elsif !options[:urls].nil? +connector.address = URLs.new(options[:urls]) +
[29/31] qpid-proton git commit: PROTON-781: Added Connector to the Ruby reactive APIs.
PROTON-781: Added Connector to the Ruby reactive 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/58519ad8 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/58519ad8 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/58519ad8 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 58519ad865746177c48f9d3bc05183948e7974de Parents: 4c09ae2 Author: Darryl L. Pierce Authored: Wed Mar 4 16:38:47 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/connector.rb | 98 2 files changed, 99 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/58519ad8/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 4f017e1..6047613 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -103,6 +103,7 @@ require "reactor/reactor" require "reactor/ssl_config" require "reactor/global_overrides" require "reactor/urls" +require "reactor/connector" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/58519ad8/proton-c/bindings/ruby/lib/reactor/connector.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/connector.rb b/proton-c/bindings/ruby/lib/reactor/connector.rb new file mode 100644 index 000..a6523db --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/connector.rb @@ -0,0 +1,98 @@ +#-- +# 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 Connector < Qpid::Proton::BaseHandler + +attr_accessor :address +attr_accessor :reconnect +attr_accessor :ssl_domain + +def initialize(connection) + @connection = connection + @address = nil + @heartbeat = nil + @reconnect = nil + @ssl_domain = nil +end + +def on_connection_local_open(event) + self.connect(event.connection) +end + +def on_connection_remote_open(event) + if !@reconnect.nil? +@reconnect.reset +@transport = nil + end +end + +def on_transport_tail_closed(event) + self.on_transport_closed(event) +end + +def on_transport_closed(event) + if !@connection.nil? && !(@connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero? +if !@reconnect.nil? + event.transport.unbind + delay = @reconnect.next + if delay == 0 +self.connect(@connection) + else +event.reactor.schedule(delay, self) + end +else + @connection = nil +end + end +end + +def on_timer_task(event) + self.connect(@connection) +end + +def on_connection_remote_close(event) + @connection = nil +end + +def connect(connection) + url = @address.next + connection.hostname = "#{url.host}:#{url.port}" + + transport = Qpid::Proton::Transport.new + transport.bind(connection) + if !@heartbeat.nil? +transport.idle_timeout = @heartbeat + elsif (url.scheme == "amqps") && !@ssl_domain.nil? +@ssl = Qpid::Proton::SSL.new(transport, @ssl_domain) +@ss.peer_hostname = url.host + elsif !url.username.nil? +sasl = transport.sasl +if url.username == "anonymous" + sasl.mechanisms("ANONYMOUS") +else + sasl.plain(url.username, url.password) +end + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[06/31] qpid-proton git commit: PROTON-781: Repackaged the Ruby Selectable class to Qpid::Proton.
PROTON-781: Repackaged the Ruby Selectable class to Qpid::Proton. It's now a part of the core APIs and not part of the Messenger 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/9e8583c3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9e8583c3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9e8583c3 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 9e8583c32c0e993643b012b2c42745ff30fc64cf Parents: 4dffce6 Author: Darryl L. Pierce Authored: Tue Feb 24 13:31:51 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/core/selectable.rb | 118 +++ .../bindings/ruby/lib/messenger/selectable.rb | 118 --- proton-c/bindings/ruby/lib/qpid_proton.rb | 2 +- 3 files changed, 119 insertions(+), 119 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e8583c3/proton-c/bindings/ruby/lib/core/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/core/selectable.rb b/proton-c/bindings/ruby/lib/core/selectable.rb new file mode 100644 index 000..8a5b223 --- /dev/null +++ b/proton-c/bindings/ruby/lib/core/selectable.rb @@ -0,0 +1,118 @@ +#-- +# 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 + + # Selectable enables accessing the underlying file descriptors + # for Messenger. + # + # @private + class Selectable + + +def initialize(messenger, impl) # :nodoc: + @messenger = messenger + @impl = impl + @io = nil + @freed = false +end + +# Returns the underlying file descriptor. +# +# This can be used in conjunction with the IO class. +# +def fileno + Cproton.pn_selectable_get_fd(@impl) +end + +def to_io + @io ||= IO.new(fileno) +end + +# The number of bytes the selectable is capable of consuming. +# +#def capacity +# Cproton.pn_selectable_capacity(@impl) +#end + +# The number of bytes waiting to be written to the file descriptor. +# +def pending + Cproton.pn_selectable_pending(@impl) +end + +# The future expiry time at which control will be returned to the +# selectable. +# +def deadline + tstamp = Cproton.pn_selectable_deadline(@impl) + tstamp.nil? ? nil : tstamp / 1000 +end + +def readable + Cproton.pn_selectable_readable(@impl) +end + +def writable + Cproton.pn_selectable_writable(@impl) +end + +def expired? + Cproton.pn_selectable_expired(@impl) +end + +def registered=(registered) + Cproton.pn_selectable_set_registered(@impl, registered) +end + +def registered? + Cproton.pn_selectable_is_registered(@impl) +end + +def terminal? + return true if @impl.nil? + Cproton.pn_selectable_is_terminal(@impl) +end + +def to_s + "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}" +end + +def free + return if @freed + @freed = true + @messenger.unregister_selectable(fileno) + @io.close unless @io.nil? + Cproton.pn_selectable_free(@impl) + @impl = nil +end + +def freed? # :nodoc: + @freed +end + +private + +def check_is_initialized + raise RuntimeError.new("selectable freed") if @impl.nil? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e8583c3/proton-c/bindings/ruby/lib/messenger/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/messenger/selectable.rb b/proton-c/bindings/ruby/lib/messenger/selectable.rb deleted file mode 100644 index da1a3d5..000 --- a/proton-c/bindings/ruby/lib/messenger/selectable.rb +++ /dev/null @@ -1,118 +0,0 @@ -#-- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed
[31/31] qpid-proton git commit: PROTON-781: Reactive Ruby examples
PROTON-781: Reactive Ruby examples Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f63454c5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f63454c5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f63454c5 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: f63454c5caac0124f600793a96d9c560c15fa22f Parents: 81c5cbd Author: Darryl L. Pierce Authored: Tue May 26 15:34:11 2015 -0400 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:59:49 2015 -0400 -- examples/ruby/lib/debugging.rb | 26 +++ examples/ruby/lib/send_and_receive.rb | 90 +++ examples/ruby/reactor/README.md| 103 examples/ruby/reactor/broker.rb| 200 examples/ruby/reactor/client.rb| 68 examples/ruby/reactor/direct_recv.rb | 60 +++ examples/ruby/reactor/direct_send.rb | 59 +++ examples/ruby/reactor/helloworld.rb| 69 examples/ruby/reactor/helloworld_direct.rb | 74 + examples/ruby/reactor/server.rb| 64 examples/ruby/reactor/simple_recv.rb | 58 +++ examples/ruby/reactor/simple_send.rb | 55 +++ 12 files changed, 926 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f63454c5/examples/ruby/lib/debugging.rb -- diff --git a/examples/ruby/lib/debugging.rb b/examples/ruby/lib/debugging.rb new file mode 100644 index 000..5065d51 --- /dev/null +++ b/examples/ruby/lib/debugging.rb @@ -0,0 +1,26 @@ +#-- +# 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 Debugging + + def debug(text) +print "[#{Time.now.strftime('%s')}] #{text}\n" + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f63454c5/examples/ruby/lib/send_and_receive.rb -- diff --git a/examples/ruby/lib/send_and_receive.rb b/examples/ruby/lib/send_and_receive.rb new file mode 100644 index 000..9fd7417 --- /dev/null +++ b/examples/ruby/lib/send_and_receive.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. +#++ + +class ExampleSend < Qpid::Proton::Handler::MessagingHandler + + attr_reader :url + + def initialize(url, expected) +super() +@url = url +@sent = 0 +@confirmed = 0 +@expected = expected + end + + def on_sendable(event) +while event.sender.credit > 0 && @sent < @expected + msg = Qpid::Proton::Message.new + msg.body = "sequence #{@sent}" + msg.id = @sent + event.sender.send(msg) + @sent = @sent + 1 +end + end + + def on_accepted(event) +@confirmed = @confirmed + 1 +if self.finished? + puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!" + event.connection.close +end + end + + def on_disconnected(event) +@sent = @confirmed + end + + def finished? +@confirmed == @expected + end + +end + +class ExampleReceive < Qpid::Proton::Handler::MessagingHandler + + attr_reader :url + + def initialize(url, expected) +super() +@url = url +@expected = expected +@received = 0 + end + + def on_messag
[13/31] qpid-proton git commit: PROTON-781: Added GlobalOverrides to the Ruby reactive APIs.
PROTON-781: Added GlobalOverrides to the Ruby reactive 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/44f13125 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/44f13125 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/44f13125 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 44f1312525c51a13ab6b82e1bff9050ec54297d2 Parents: cb84a67 Author: Darryl L. Pierce Authored: Thu Feb 26 11:28:35 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + .../ruby/lib/reactor/global_overrides.rb| 44 2 files changed, 45 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/44f13125/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 d8783bc..5b0d23f 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -97,6 +97,7 @@ require "reactor/task" require "reactor/acceptor" require "reactor/reactor" require "reactor/ssl_config" +require "reactor/global_overrides" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/44f13125/proton-c/bindings/ruby/lib/reactor/global_overrides.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/global_overrides.rb b/proton-c/bindings/ruby/lib/reactor/global_overrides.rb new file mode 100644 index 000..11d05a5 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/global_overrides.rb @@ -0,0 +1,44 @@ +#-- +# 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 GlobalOverrides + +def initialize(base) + @base = base +end + +def on_unhandled(name, event) + event.dispatch(@base) unless self.override?(event) +end + +def override?(event) + conn = event.connection + if !conn.nil? && conn.overrides? +overrides = conn.overrides +result = event.dispatch(overrides) +return result + end + false +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[10/31] qpid-proton git commit: PROTON-781: Added MessagingHandler to the Ruby reactive APIs.
PROTON-781: Added MessagingHandler to the Ruby reactive 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/271b3a00 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/271b3a00 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/271b3a00 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 271b3a006927537545d899615150671b026e4c86 Parents: 9eaa62a Author: Darryl L. Pierce Authored: Wed Feb 25 13:32:09 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- .../ruby/lib/handler/messaging_handler.rb | 218 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 219 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/271b3a00/proton-c/bindings/ruby/lib/handler/messaging_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb new file mode 100644 index 000..b4a0bcf --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb @@ -0,0 +1,218 @@ +#-- +# 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::Handler + + # A general purpose handler that simplifies processing events. + # + # @example + # + class MessagingHandler < Qpid::Proton::BaseHandler + +attr_reader :handlers + +# Creates a new instance. +# +# @param [Fixnum] prefetch +# @param [Boolean] auto_accept +# @param [Boolean] auto_settle +# @param [Boolean] peer_close_is_error +# +def initialize(prefetch = 10, auto_accept = true, auto_settle = true, peer_close_is_error = false) + @handlers = Array.new + @handlers << CFlowController.new(prefetch) unless prefetch.zero? + @handlers << EndpointStateHandler.new(peer_close_is_error, self) + @handlers << IncomingMessageHandler.new(auto_accept, self) + @handlers << OutgoingMessageHandler.new(auto_settle,self) +end + +# Called when the peer closes the connection with an error condition. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_connection_error(event) + EndpointStateHandler.print_error(event.connection, "connection") +end + + # Called when the peer closes the session with an error condition. + # + # @param event [Qpid:Proton::Event::Event] The event. + # +def on_session_error(event) + EndpointStateHandler.print_error(event.session, "session") + event.connection.close +end + +# Called when the peer closes the link with an error condition. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_link_error(event) + EndpointStateHandler.print_error(event.link, "link") + event.connection.close +end + +# Called when the event loop starts. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_reactor_init(event) + self.on_start(event) +end + +# Called when the event loop starts. +# +# This method needs to be overridden. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_start(event) +end + +# Called when the connection is closed. +# +# This method needs to be overridden. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_connection_closed(event) +end + +# Called when the session is closed. +# +# This method needs to be overridden. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_session_closed(event) +end + +# Called when the link is closed. +# +# This method needs to be overridden. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_link_closed(event) +end + +# Called when the peer initiates the closing of the connection. +# +# This method needs to be overridden. +# +# @param
[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 Authored: Mon May 4 13:26:26 2015 -0400 Committer: Darryl L. Pierce 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 000..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-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[03/31] qpid-proton git commit: PROTON-781: Refactored the Ruby Selectable class.
PROTON-781: Refactored the Ruby Selectable class. It now more closely matches the Python version. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/340a9da7 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/340a9da7 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/340a9da7 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 340a9da719f1fcea1298d0dc71f40b4e641925a8 Parents: 9e8583c Author: Darryl L. Pierce Authored: Thu Jun 4 13:56:49 2015 -0400 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- proton-c/bindings/ruby/lib/core/selectable.rb | 124 +++-- 1 file changed, 68 insertions(+), 56 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/340a9da7/proton-c/bindings/ruby/lib/core/selectable.rb -- diff --git a/proton-c/bindings/ruby/lib/core/selectable.rb b/proton-c/bindings/ruby/lib/core/selectable.rb index 8a5b223..0ae2efe 100644 --- a/proton-c/bindings/ruby/lib/core/selectable.rb +++ b/proton-c/bindings/ruby/lib/core/selectable.rb @@ -25,13 +25,11 @@ module Qpid::Proton # @private class Selectable +# @private +include Util::SwigHelper -def initialize(messenger, impl) # :nodoc: - @messenger = messenger - @impl = impl - @io = nil - @freed = false -end +# @private +PROTON_METHOD_PREFIX = "pn_selectable" # Returns the underlying file descriptor. # @@ -41,76 +39,90 @@ module Qpid::Proton Cproton.pn_selectable_get_fd(@impl) end -def to_io - @io ||= IO.new(fileno) -end +proton_reader :reading, :is_or_get => :is -# The number of bytes the selectable is capable of consuming. -# -#def capacity -# Cproton.pn_selectable_capacity(@impl) -#end +proton_reader :writing, :is_or_get => :is -# The number of bytes waiting to be written to the file descriptor. -# -def pending - Cproton.pn_selectable_pending(@impl) -end +proton_caller :readable -# The future expiry time at which control will be returned to the -# selectable. -# -def deadline - tstamp = Cproton.pn_selectable_deadline(@impl) - tstamp.nil? ? nil : tstamp / 1000 -end +proton_caller :writable -def readable - Cproton.pn_selectable_readable(@impl) -end +proton_caller :expired -def writable - Cproton.pn_selectable_writable(@impl) -end +proton_accessor :registered, :is_or_get => :is -def expired? - Cproton.pn_selectable_expired(@impl) -end +proton_accessor :terminal, :is_or_get => :is -def registered=(registered) - Cproton.pn_selectable_set_registered(@impl, registered) +proton_caller :terminate + +proton_caller :release + +# @private +def self.wrap(impl) + return nil if impl.nil? + + self.fetch_instance(impl, :pn_selectable_attachments) || Selectable.new(impl) end -def registered? - Cproton.pn_selectable_is_registered(@impl) +# @private +include Util::Wrapper + +# @private +def initialize(impl) + @impl = impl + self.class.store_instance(self, :pn_selectable_attachments) end -def terminal? - return true if @impl.nil? - Cproton.pn_selectable_is_terminal(@impl) +private + +DEFAULT = Object.new + +public + +def fileno(fd = DEFAULT) + if fd == DEFAULT +Cproton.pn_selectable_get_fd(@impl) + elsif fd.nil? +Cproton.pn_selectable_set_fd(@impl, Cproton::PN_INVALID_SOCKET) + else +Cproton.pn_selectable_set_fd(@impl, fd) + end end -def to_s - "fileno=#{self.fileno} registered=#{self.registered?} terminal=#{self.terminal?}" +def reading=(reading) + if reading.nil? +reading = false + elsif reading == "0" +reading = false + else +reading = true + end + Cproton.pn_selectable_set_reading(@impl, reading ? true : false) end -def free - return if @freed - @freed = true - @messenger.unregister_selectable(fileno) - @io.close unless @io.nil? - Cproton.pn_selectable_free(@impl) - @impl = nil +def writing=(writing) + if writing.nil? +writing = false + elsif writing == "0" +writing = false + else +writing = true + end + Cproton.pn_selectable_set_writing(@impl, writing ? true : false) end -def freed? # :nodoc: - @freed +def deadline + tstamp = Cproton.pn_selectable_get_deadline(@impl) + return nil if tstamp.nil? + mills_to_sec(tstamp) end -private +def deadline=(deadline) + Cproton.pn_selectable_set_deadlin
[18/31] qpid-proton git commit: PROTON-781: Added the Reactor class to the Ruby reactor APIs.
PROTON-781: Added the Reactor class to the Ruby reactor 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/1573e5bf Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1573e5bf Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1573e5bf Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 1573e5bf6744e6e016dc89ecc4dff264ed69f41e Parents: 0f45ba0 Author: Darryl L. Pierce Authored: Mon Feb 23 16:21:02 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/reactor.rb | 198 + 2 files changed, 199 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1573e5bf/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 bffd4d1..f8703e7 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -95,6 +95,7 @@ require "handler/messaging_handler" # Reactor classes require "reactor/task" require "reactor/acceptor" +require "reactor/reactor" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1573e5bf/proton-c/bindings/ruby/lib/reactor/reactor.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/reactor.rb b/proton-c/bindings/ruby/lib/reactor/reactor.rb new file mode 100644 index 000..1cf4f6c --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/reactor.rb @@ -0,0 +1,198 @@ +#-- +# 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 Reactor + +include Qpid::Proton::Util::Handler + +# @private +include Qpid::Proton::Util::SwigHelper + +# @private +PROTON_METHOD_PREFIX = "pn_reactor" + +proton_caller :yield + +proton_caller :mark + +proton_caller :start + +proton_caller :stop + +# @private +include Qpid::Proton::Util::Timeout + +include Qpid::Proton::Util::Wrapper + +attr_reader :errors + +def self.wrap(impl) + return nil if impl.nil? + + self.fetch_instance(impl, :pn_reactor_attachments) || Reactor.new(nil, :impl => impl) +end + +def initialize(handlers, options = {}) + @impl = options[:impl] + if @impl.nil? +@impl = Cproton.pn_reactor + end + if !handlers.nil? +[handlers].flatten.each {|handler| self.handler.add(handler)} + end + @errors = [] + @handlers = [] + self.class.store_instance(self, :pn_reactor_attachments) +end + +# Returns whether the reactor has any unbuffered data. +# +# @return [Boolean] True if there is no unbuffered data. +# +def quiesced? + Cproton.pn_reactor_quiesced(@impl) +end + +def on_error(info) + self.errors << info + self.yield +end + +def global_handler + impl = Cproton.pn_reactor_get_global_handler(@impl) + Qpid::Proton::Handler::WrappedHandler.wrap(impl, self.method(:on_error)) +end + +def global_handler=(handler) + impl = chandler(handler, self.method(:on_error)) + Cproton.pn_reactor_set_global_handler(@impl, impl) + Cproton.pn_decref(impl) +end + +# Returns the timeout period. +# +# @return [Fixnum] The timeout period, in seconds. +# +def timeout + millis_to_timeout(Cproton.pn_reactor_get_timeout(@impl)) +end + +# Sets the timeout period. +# +# @param timeout [Fixnum] The timeout, in seconds. +# +def timeout=(timeout) + Cproton.pn_reactor_set_timeout(@impl, timeout_to_millis(timeout)) +end + +def handler + impl = Cproton.pn_reactor_get_handler(@impl) + Qpid::Proton::Handler::WrappedHandler.wrap(impl, self.method(:on_error)) +end + +def handler=(handler) + impl = chandler(handler, s
[08/31] qpid-proton git commit: PROTON-781: Added EndpointStateHandler to the Ruby reactive APIs.
PROTON-781: Added EndpointStateHandler to the Ruby reactive 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/43970df0 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/43970df0 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/43970df0 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 43970df0cfc68f9acbc5458afffa9230c234885e Parents: 9ff3e04 Author: Darryl L. Pierce Authored: Wed Feb 25 13:28:38 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:51 2015 -0400 -- .../ruby/lib/handler/endpoint_state_handler.rb | 217 +++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 218 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/43970df0/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb new file mode 100644 index 000..727a20b --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/endpoint_state_handler.rb @@ -0,0 +1,217 @@ +#-- +# 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::Handler + + # A utility that exposes endpoint events; i.e., the open/close of a link, + # session or connection, in a more intuitive manner. + # + # A XXX_opened method will be called when both local and remote peers have + # opened the link, session or connection. This can be used to confirm a + # locally initiated action for example. + # + # A XXX_opening method will be called when the remote peer has requested + # an open that was not initiated locally. By default this will simply open + # locally, which then trigtgers the XXX_opened called. + # + # The same applies to close. + # + class EndpointStateHandler < Qpid::Proton::BaseHandler + +def initialize(peer_close_is_error = false, delegate = nil) + @delegate = delegate + @peer_close_is_error = peer_close_is_error +end + +def self.print_error(endpoint, endpoint_type) + if !endpoint.remote_condition.nil? + elsif self.local_endpoint?(endpoint) && endpoint.remote_closed? +logging.error("#{endpoint_type} closed by peer") + end +end + +def on_link_remote_close(event) + if !event.link.remote_condition.nil? +self.on_link_error(event) + elsif event.link.local_closed? +self.on_link_closed(event) + else +self.on_link_closing(event) + end + event.link.close +end + +def on_session_remote_close(event) + if !event.session.remote_condition.nil? +self.on_session_error(event) + elsif event.session.local_closed? +self.on_session_closed(event) + else +self.on_session_closing(event) + end + event.session.close +end + +def on_connection_remote_close(event) + if !event.connection.remote_condition.nil? +self.on_connection_error(event) + elsif event.connection.local_closed? +self.on_connection_closed(event) + else +self.on_connection_closing(event) + end + event.connection.close +end + +def on_connection_local_open(event) + self.on_connection_opened(event) if event.connection.remote_active? +end + +def on_connection_remote_open(event) + if !(event.connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero? +self.on_connection_opened(event) + elsif event.connection.local_uninit? +self.on_connection_opening(event) +event.connection.open + end +end + +def on_session_local_open(event) + self.on_session_opened(event) if event.session.remote_active? +end + +def on_session_remote_open(event) + if !(event.session.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero? +self.on_session_opened(event) + elsif event.session.local_uninit? +self.on_session_opening(event) +
[20/31] qpid-proton git commit: PROTON-781: Added the Timeout mixin to the Ruby APIs.
PROTON-781: Added the Timeout mixin to the Ruby 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/5b72338a Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5b72338a Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5b72338a Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 5b72338aee39379c56b799b6ec91aa2dbce3388f Parents: 44f1312 Author: Darryl L. Pierce Authored: Mon Mar 2 15:42:20 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/timeout.rb | 50 + 2 files changed, 51 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b72338a/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 5b0d23f..0c84f20 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -40,6 +40,7 @@ require "util/wrapper" require "util/class_wrapper" require "util/engine" require "util/uuid" +require "util/timeout" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5b72338a/proton-c/bindings/ruby/lib/util/timeout.rb -- diff --git a/proton-c/bindings/ruby/lib/util/timeout.rb b/proton-c/bindings/ruby/lib/util/timeout.rb new file mode 100644 index 000..f4647f5 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/timeout.rb @@ -0,0 +1,50 @@ +#-- +# 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::Util + + # Provides methods for converting between milliseconds, seconds + # and timeout values. + # + # @private + module Timeout + +def sec_to_millis(s) + return (s * 1000).to_int +end + +def millis_to_sec(ms) + return (ms.to_f / 1000.0).to_int +end + +def timeout_to_millis(s) + return Cproton::PN_MILLIS_MAX if s.nil? + + return sec_to_millis(s) +end + +def millis_to_timeout(ms) + return nil if ms == Cproton::PN_MILLIS_MAX + + return millis_to_sec(ms) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[25/31] qpid-proton git commit: PROTON-781: Added support for reactors to the Ruby Endpoint class.
PROTON-781: Added support for reactors to the Ruby Endpoint class. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9b30655f Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9b30655f Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9b30655f Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 9b30655f0dfefdc868989ff429b5d8b4395e6fea Parents: b8ba5ac Author: Darryl L. Pierce Authored: Thu Apr 16 10:41:08 2015 -0400 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/core/endpoint.rb | 25 1 file changed, 25 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9b30655f/proton-c/bindings/ruby/lib/core/endpoint.rb -- diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb index cbf1015..f3ddbcb 100644 --- a/proton-c/bindings/ruby/lib/core/endpoint.rb +++ b/proton-c/bindings/ruby/lib/core/endpoint.rb @@ -110,6 +110,31 @@ module Qpid::Proton !(self.state & state_mask).zero? end +def handler + reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl)) + if reactor.nil? +on_error = nil + else +on_error = reactor.method(:on_error) + end + record = self.attachments + puts "record=#{record}" + WrappedHandler.wrap(Cproton.pn_record_get_handler(record), on_error) +end + +def handler=(handler) + reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl)) + if reactor.nil? +on_error = nil + else +on_error = reactor.method(:on_error) + end + impl = chandler(handler, on_error) + record = self.attachments + Cproton.pn_record_set_handler(record, impl) + Cproton.pn_decref(impl) +end + end end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[26/31] qpid-proton git commit: PROTON-781: Added URLs to the Ruby reactive APIs.
PROTON-781: Added URLs to the Ruby reactive 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/4c09ae23 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4c09ae23 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4c09ae23 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 4c09ae236bd0238a2444cd0237d7b001621a1c34 Parents: 5504a7a Author: Darryl L. Pierce Authored: Wed Mar 4 16:38:04 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/urls.rb | 40 + 2 files changed, 41 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4c09ae23/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 11a555f..4f017e1 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -102,6 +102,7 @@ require "reactor/acceptor" require "reactor/reactor" require "reactor/ssl_config" require "reactor/global_overrides" +require "reactor/urls" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4c09ae23/proton-c/bindings/ruby/lib/reactor/urls.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/urls.rb b/proton-c/bindings/ruby/lib/reactor/urls.rb new file mode 100644 index 000..8cdb16c --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/urls.rb @@ -0,0 +1,40 @@ +#-- +# 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 URLs + +def initialize(values) + @values = [values].flatten + @iter = @values.each +end + +def next + begin +return @iter.next + rescue StopIteration +@iter = @values.each +return @iter.next + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[14/31] qpid-proton git commit: PROTON-781: Added Backoff to the Ruby reactive APIs.
PROTON-781: Added Backoff to the Ruby reactive 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/ca7f8f99 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ca7f8f99 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ca7f8f99 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: ca7f8f993aa8a071e7cd4b380858b2a494ac4335 Parents: 58519ad Author: Darryl L. Pierce Authored: Wed Mar 4 16:39:13 2015 -0500 Committer: Darryl L. Pierce Committed: Mon Jun 8 13:57:52 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/backoff.rb | 41 ++ 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ca7f8f99/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 6047613..661927e 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -104,6 +104,7 @@ require "reactor/ssl_config" require "reactor/global_overrides" require "reactor/urls" require "reactor/connector" +require "reactor/backoff" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ca7f8f99/proton-c/bindings/ruby/lib/reactor/backoff.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/backoff.rb b/proton-c/bindings/ruby/lib/reactor/backoff.rb new file mode 100644 index 000..99682e5 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/backoff.rb @@ -0,0 +1,41 @@ +#-- +# 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 Backoff + +def initialize + @delay = 0 +end + +def reset + @delay = 0 +end + +def next + current = @delay + current = 0.1 if current.zero? + @delay = [10, 2 * current].min + return current +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
qpid-proton git commit: PROTON-914: Fix for getting the SSL peer hostname in Ruby.
Repository: qpid-proton Updated Branches: refs/heads/master 0f90a7e4c -> cbb680049 PROTON-914: Fix for getting the SSL peer hostname in Ruby. Previously the call was returning the result code rather than the actual hostname value. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cbb68004 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cbb68004 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cbb68004 Branch: refs/heads/master Commit: cbb6800496e88a0a4f22523c0f0f68afd3424323 Parents: 0f90a7e Author: Darryl L. Pierce Authored: Wed Jun 17 11:12:32 2015 -0400 Committer: Darryl L. Pierce Committed: Wed Jun 17 11:51:40 2015 -0400 -- proton-c/bindings/ruby/lib/core/ssl.rb | 18 +++--- proton-c/bindings/ruby/lib/core/transport.rb | 5 ++--- proton-c/bindings/ruby/ruby.i| 13 + 3 files changed, 14 insertions(+), 22 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/ssl.rb -- diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb b/proton-c/bindings/ruby/lib/core/ssl.rb index 9c4a3e9..0b16075 100644 --- a/proton-c/bindings/ruby/lib/core/ssl.rb +++ b/proton-c/bindings/ruby/lib/core/ssl.rb @@ -66,11 +66,6 @@ module Qpid::Proton # @private PROTON_METHOD_PREFIX = "pn_ssl" -# @!attribute peer_hostname -# -# @return [String] The peer hostname. -proton_accessor :peer_hostname - # @private include Util::ErrorHandler @@ -108,10 +103,10 @@ module Qpid::Proton def initialize(impl, domain, session_details, session_id) @impl = impl - @domain = domain + @domain = domain.impl unless domain.nil? @session_details = session_details @session_id = session_id - Cproton.pn_ssl_init(@impl, @domain.impl, @session_id) + Cproton.pn_ssl_init(@impl, @domain, @session_id) end public @@ -155,6 +150,15 @@ module Qpid::Proton Cproton.pn_ssl_resume_status(@impl) end +# Gets the peer hostname. +# +# @return [String] The peer hostname. +def peer_hostname + (error, name) = Cproton.pn_ssl_get_peer_hostname(@impl, 1024) + raise SSLError.new if error < 0 + return name +end + end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/lib/core/transport.rb -- diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb index 206f97d..9ba5dc8 100644 --- a/proton-c/bindings/ruby/lib/core/transport.rb +++ b/proton-c/bindings/ruby/lib/core/transport.rb @@ -398,13 +398,12 @@ module Qpid::Proton # @return [SSL] The SSL object. # def ssl(domain = nil, session_details = nil) - self.ssl = SSL.create(self, domain, session_details) if self.ssl.nil? - self.ssl + @ssl ||= SSL.create(self, domain, session_details) if @ssl.nil? end # @private def ssl? - self.respond_to?(:ssl) && !self.ssl.nil? + !@ssl.nil? end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbb68004/proton-c/bindings/ruby/ruby.i -- diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i index 0534808..678a085 100644 --- a/proton-c/bindings/ruby/ruby.i +++ b/proton-c/bindings/ruby/ruby.i @@ -556,18 +556,7 @@ VALUE pni_address_of(void *object) { // %} //%ignore pn_collector_put; -%rename(pn_ssl_get_peer_hostname) wrap_pn_ssl_get_peer_hostname; -%inline %{ - int wrap_pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE) { -ssize_t size = pn_ssl_get_peer_hostname(ssl, OUTPUT, *OUTPUT_SIZE); -if (size >= 0) { - *OUTPUT_SIZE = size; -} else { - *OUTPUT_SIZE = 0; -} -return size; - } - %} +int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE); %ignore pn_ssl_get_peer_hostname; %include "proton/cproton.i" - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[31/50] qpid-proton git commit: PROTON-781: Added OutgoingMessageHandler to the Ruby reactive APIs.
PROTON-781: Added OutgoingMessageHandler to the Ruby reactive 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/13789804 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/13789804 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/13789804 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 137898046f9089a873b1f3a0f9b7b504b494fa59 Parents: e165313 Author: Darryl L. Pierce Authored: Thu Feb 26 09:59:18 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:20 2015 -0400 -- .../lib/handler/outgoing_message_handler.rb | 98 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 99 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb new file mode 100644 index 000..056a131 --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb @@ -0,0 +1,98 @@ +#-- +# 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::Handler + + # A utility for simpler and more intuitive handling of delivery events + # related to outgoing messages. + # + class OutgoingMessageHandler < Qpid::Proton::BaseHandler + +def initialize(auto_settle = true, delegate = nil) + @auto_settle = auto_settle + @delegate = delegate +end + +def on_link_flow(event) + self.on_sendable(event) if event.link.sender? && event.link.credit > 0 +end + +def on_delivery(event) + delivery = event.delivery + if delivery.link.sender? && delivery.updated? +if delivery.remote_accepted? + self.on_accepted(event) +elsif delivery.remote_rejected? + self.on_rejected(event) +elsif delivery.remote_released? || delivery.remote_modified? + self.on_released(event) +end +self.on_settled(event) if delivery.settled? +delivery.settle if @auto_settle + end +end + +# Called when the sender link has credit and messages and be transferred. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_sendable(event) + Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil? +end + +# Called when the remote peer accepts a sent message. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_accepted(event) + Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil? +end + +# Called when the remote peer rejects a sent message. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_rejected(event) + Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil? +end + +# Called when the remote peer releases an outgoing message. +# +# Note that this may be in resposnse to either the REELAASE or MODIFIED +# state as defined by the AMQP specification. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_released(event) + Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil? +end + +# Called when the remote peer has settled the outgoing message. +# +# This is the point at which it should never be retransmitted. +# +# @param event [Qpid::Proton::Event::Event] The event. +# +def on_settled(event) + Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil? +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/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
[35/50] qpid-proton git commit: PROTON-781: Added the Task class to the Ruby reactor APIs.
PROTON-781: Added the Task class to the Ruby reactor 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/c690e566 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c690e566 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c690e566 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: c690e566db6952fc95d6f5353276c24f8e6c0954 Parents: 7c93d88 Author: Darryl L. Pierce Authored: Mon Feb 23 16:19:33 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:20 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 3 ++ proton-c/bindings/ruby/lib/reactor/task.rb | 39 + 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c690e566/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 a60a028..f3da844 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -92,6 +92,9 @@ require "handler/outgoing_message_handler" require "handler/c_flow_controller" require "handler/messaging_handler" +# Reactor classes +require "reactor/task" + module Qpid::Proton # @private def self.registry http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c690e566/proton-c/bindings/ruby/lib/reactor/task.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/task.rb b/proton-c/bindings/ruby/lib/reactor/task.rb new file mode 100644 index 000..6818ed2 --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/task.rb @@ -0,0 +1,39 @@ +#-- +# 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 Task + +# @private +include Qpid::Proton::Util::Wrapper + +def self.wrap(impl) + return nil if impl.nil? + self.fetch_instance(impl, :pn_task_attachments) || Task.new(impl) +end + +def initialize(impl) + @impl = impl + self.class.store_instance(self, :pn_task_attachments) +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[49/50] qpid-proton git commit: PROTON-781: Added Container to the Ruby reactive APIs.
PROTON-781: Added Container to the Ruby reactive 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/6598326a Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6598326a Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6598326a Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 6598326a3774fd9153ed4ffb158dd1c537557027 Parents: e593ba8 Author: Darryl L. Pierce Authored: Thu Feb 26 10:26:11 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:21 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/reactor/container.rb | 272 +++ 2 files changed, 273 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6598326a/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 f40c608..ba1e66e 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -106,6 +106,7 @@ require "reactor/urls" require "reactor/connector" require "reactor/backoff" require "reactor/session_per_connection" +require "reactor/container" module Qpid::Proton # @private http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6598326a/proton-c/bindings/ruby/lib/reactor/container.rb -- diff --git a/proton-c/bindings/ruby/lib/reactor/container.rb b/proton-c/bindings/ruby/lib/reactor/container.rb new file mode 100644 index 000..93b49bb --- /dev/null +++ b/proton-c/bindings/ruby/lib/reactor/container.rb @@ -0,0 +1,272 @@ +#-- +# 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 + + # @private + class InternalTransactionHandler < Qpid::Proton::Handler::OutgoingMessageHandler + +def initialize + super +end + +def on_settled(event) + if event.delivery.respond_to? :transaction +event.transaction = event.delivery.transaction +event.delivery.transaction.handle_outcome(event) + end +end + + end + + + # A representation of the AMQP concept of a container which, loosely + # speaking, is something that establishes links to or from another + # container on which messages are transferred. + # + # This is an extension to the Reactor classthat adds convenience methods + # for creating instances of Qpid::Proton::Connection, Qpid::Proton::Sender + # and Qpid::Proton::Receiver. + # + # @example + # + class Container < Reactor + +include Qpid::Proton::Util::Reactor + +include Qpid::Proton::Util::UUID + +attr_accessor :container_id +attr_accessor :global_handler + +def initialize(handlers, options = {}) + super(handlers, options) + + # only do the following if we're creating a new instance + if !options.has_key?(:impl) +@ssl = SSLConfig.new +if options[:global_handler] + self.global_handler = GlobalOverrides.new(options[:global_handler]) +else + # very ugly, but using self.global_handler doesn't work in the constructor + ghandler = Reactor.instance_method(:global_handler).bind(self).call + ghandler = GlobalOverrides.new(ghandler) + Reactor.instance_method(:global_handler=).bind(self).call(ghandler) +end +@trigger = nil +@container_id = generate_uuid + end +end + +# Initiates the establishment of an AMQP connection. +# +# @param options [Hash] A hash of named arguments. +# +def connect(options = {}) + conn = self.connection(options[:handler]) + conn.container = self.container_id || generate_uuid + connector = Connector.new(conn) + conn.overrides = connector + if !options[:url].nil? +connector.address = URLs.new([options[:url]]) + elsif !options[:urls].nil? +connector.address = URLs.new(options[:urls]) +
[33/50] qpid-proton git commit: PROTON-781: Added the Handler mixin to the Ruby reactive APIs.
PROTON-781: Added the Handler mixin to the Ruby reactive 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/9dcf369b Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9dcf369b Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9dcf369b Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 9dcf369b61c46833768350227045e8ff47fb1f5d Parents: a62d922 Author: Darryl L. Pierce Authored: Wed Mar 4 08:06:19 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:20 2015 -0400 -- proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + proton-c/bindings/ruby/lib/util/handler.rb | 41 + 2 files changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9dcf369b/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 0c84f20..03f5632 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -41,6 +41,7 @@ require "util/class_wrapper" require "util/engine" require "util/uuid" require "util/timeout" +require "util/handler" # Types require "types/strings" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9dcf369b/proton-c/bindings/ruby/lib/util/handler.rb -- diff --git a/proton-c/bindings/ruby/lib/util/handler.rb b/proton-c/bindings/ruby/lib/util/handler.rb new file mode 100644 index 000..e7d07b1 --- /dev/null +++ b/proton-c/bindings/ruby/lib/util/handler.rb @@ -0,0 +1,41 @@ +#-- +# 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::Util + + # @private + module Handler + +def chandler(handler, on_error) + return nil if handler.nil? + + if handler.instance_of?(Qpid::Proton::Handler::WrappedHandler) +impl = handler.impl +Cproton.pn_incref(impl) +return impl + else +cadaptor = Qpid::Proton::Handler::CAdaptor.new(handler, on_error) +rbhandler = Cproton.pn_rbhandler(cadaptor) +return rbhandler + end +end + + end + +end - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[18/50] qpid-proton git commit: PROTON-842: enforce channel_max limit on session creation
PROTON-842: enforce channel_max limit on session creation Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e38957ae Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e38957ae Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e38957ae Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: e38957ae5115ec023993672ca5b7d5e3df414f7e Parents: 175a15a Author: Mick Goulish Authored: Thu Jun 18 08:45:47 2015 -0400 Committer: Mick Goulish Committed: Thu Jun 18 08:45:47 2015 -0400 -- proton-c/bindings/python/proton/__init__.py | 7 +- proton-c/include/proton/cproton.i | 2 - proton-c/include/proton/transport.h | 16 +++- proton-c/src/engine/engine-internal.h | 14 ++- proton-c/src/engine/engine.c| 16 +++- proton-c/src/transport/transport.c | 111 --- tests/python/proton_tests/engine.py | 44 - 7 files changed, 191 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/bindings/python/proton/__init__.py -- diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py index 9432bd8..5860764 100644 --- a/proton-c/bindings/python/proton/__init__.py +++ b/proton-c/bindings/python/proton/__init__.py @@ -2484,7 +2484,11 @@ class Connection(Wrapper, Endpoint): """ Returns a new session on this connection. """ -return Session(pn_session(self._impl)) +ssn = pn_session(self._impl) +if ssn is None: + raise(SessionException("Session allocation failed.")) +else: + return Session(ssn) def session_head(self, mask): return Session.wrap(pn_session_head(self._impl, mask)) @@ -3987,6 +3991,7 @@ __all__ = [ "SASL", "Sender", "Session", + "SessionException", "SSL", "SSLDomain", "SSLSessionDetails", http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/include/proton/cproton.i -- diff --git a/proton-c/include/proton/cproton.i b/proton-c/include/proton/cproton.i index ac2b121..b55211f 100644 --- a/proton-c/include/proton/cproton.i +++ b/proton-c/include/proton/cproton.i @@ -210,8 +210,6 @@ typedef unsigned long int uintptr_t; { require: connection != NULL; - ensure: - pn_session != NULL; } %contract pn_transport(pn_connection_t *connection) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/include/proton/transport.h -- diff --git a/proton-c/include/proton/transport.h b/proton-c/include/proton/transport.h index a3ca667..483f5a9 100644 --- a/proton-c/include/proton/transport.h +++ b/proton-c/include/proton/transport.h @@ -320,6 +320,10 @@ PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ... /** * Get the maximum allowed channel for a transport. + * This will be the minimum of + * 1. limit imposed by this proton implementation + * 2. limit imposed by remote peer + * 3. limit imposed by this application, using pn_transport_set_channel_max() * * @param[in] transport a transport object * @return the maximum allowed channel @@ -327,7 +331,17 @@ PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ... PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *transport); /** - * Set the maximum allowed channel for a transport. + * Set the maximum allowed channel number for a transport. + * Note that this is the maximum channel number allowed, giving a + * valid channel number range of [0..channel_max]. Therefore the + * maximum number of simultaineously active channels will be + * channel_max plus 1. + * You can call this function more than once to raise and lower + * the limit your application imposes on max channels for this + * transport. However, smaller limits may be imposed by this + * library, or by the remote peer. + * After the OPEN frame has been sent to the remote peer, + * further calls to this function will have no effect. * * @param[in] transport a transport object * @param[in] channel_max the maximum allowed channel http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e38957ae/proton-c/src/engine/engine-internal.h -- diff --git a/proton-c/src/engine/engine-internal.h b/proton-c/src/engine/engine-internal.h index 4c72310..c03a0a3 100644 --- a/proton-c/src/engine/engine-internal.h +++ b/proton-c/src/engine/engine-internal.h @@ -178,8 +178,20 @@ struct p
[42/50] qpid-proton git commit: PROTON-781: Reactive Ruby examples
PROTON-781: Reactive Ruby examples Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/717377a2 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/717377a2 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/717377a2 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 717377a2da1f347b20ab4f81dce2fecf97d1a463 Parents: 3211bd5 Author: Darryl L. Pierce Authored: Tue May 26 15:34:11 2015 -0400 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:21 2015 -0400 -- examples/ruby/lib/debugging.rb | 26 +++ examples/ruby/lib/send_and_receive.rb | 90 +++ examples/ruby/reactor/README.md| 103 examples/ruby/reactor/broker.rb| 200 examples/ruby/reactor/client.rb| 68 examples/ruby/reactor/direct_recv.rb | 60 +++ examples/ruby/reactor/direct_send.rb | 59 +++ examples/ruby/reactor/helloworld.rb| 69 examples/ruby/reactor/helloworld_direct.rb | 74 + examples/ruby/reactor/server.rb| 64 examples/ruby/reactor/simple_recv.rb | 58 +++ examples/ruby/reactor/simple_send.rb | 55 +++ 12 files changed, 926 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/lib/debugging.rb -- diff --git a/examples/ruby/lib/debugging.rb b/examples/ruby/lib/debugging.rb new file mode 100644 index 000..5065d51 --- /dev/null +++ b/examples/ruby/lib/debugging.rb @@ -0,0 +1,26 @@ +#-- +# 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 Debugging + + def debug(text) +print "[#{Time.now.strftime('%s')}] #{text}\n" + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/717377a2/examples/ruby/lib/send_and_receive.rb -- diff --git a/examples/ruby/lib/send_and_receive.rb b/examples/ruby/lib/send_and_receive.rb new file mode 100644 index 000..9fd7417 --- /dev/null +++ b/examples/ruby/lib/send_and_receive.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. +#++ + +class ExampleSend < Qpid::Proton::Handler::MessagingHandler + + attr_reader :url + + def initialize(url, expected) +super() +@url = url +@sent = 0 +@confirmed = 0 +@expected = expected + end + + def on_sendable(event) +while event.sender.credit > 0 && @sent < @expected + msg = Qpid::Proton::Message.new + msg.body = "sequence #{@sent}" + msg.id = @sent + event.sender.send(msg) + @sent = @sent + 1 +end + end + + def on_accepted(event) +@confirmed = @confirmed + 1 +if self.finished? + puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!" + event.connection.close +end + end + + def on_disconnected(event) +@sent = @confirmed + end + + def finished? +@confirmed == @expected + end + +end + +class ExampleReceive < Qpid::Proton::Handler::MessagingHandler + + attr_reader :url + + def initialize(url, expected) +super() +@url = url +@expected = expected +@received = 0 + end + + def on_messa
[27/50] qpid-proton git commit: PROTON-781: Added the CFlowController class to the Ruby reactive APIs.
PROTON-781: Added the CFlowController class to the Ruby reactive 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/e5299b29 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e5299b29 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e5299b29 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: e5299b29844eb3187346d158885abb12fc858fae Parents: 132e2a3 Author: Darryl L. Pierce Authored: Wed Feb 25 13:29:22 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:20 2015 -0400 -- .../ruby/lib/handler/c_flow_controller.rb | 33 proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 34 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e5299b29/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb new file mode 100644 index 000..377cc2f --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/c_flow_controller.rb @@ -0,0 +1,33 @@ +#-- +# 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::Handler + + # @private + class CFlowController < Qpid::Proton::Handler::WrappedHandler + +include Qpid::Proton::Util::Wrapper + +def initialize(window = 1024) + super(Cproton.pn_flowcontroller(window)) +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e5299b29/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 08e60b9..e14ff9d 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -86,6 +86,7 @@ require "handler/c_adaptor" require "handler/wrapped_handler" require "handler/acking" require "handler/endpoint_state_handler" +require "handler/c_flow_controller" module Qpid::Proton # @private - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
[22/50] qpid-proton git commit: PROTON-781: Added the Acking mixin to the Ruby reactive APIs.
PROTON-781: Added the Acking mixin to the Ruby reactive APIs. The Acking mixin provides methods for handling the settling of messages based on reactive callbacks. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8d8bfd23 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8d8bfd23 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8d8bfd23 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 8d8bfd23257a1b3944ec2793d40eddee0409d20e Parents: 51e85ea Author: Darryl L. Pierce Authored: Wed Feb 25 13:27:30 2015 -0500 Committer: Darryl L. Pierce Committed: Thu Jun 18 09:27:19 2015 -0400 -- proton-c/bindings/ruby/lib/handler/acking.rb | 70 +++ proton-c/bindings/ruby/lib/qpid_proton.rb| 1 + 2 files changed, 71 insertions(+) -- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/proton-c/bindings/ruby/lib/handler/acking.rb -- diff --git a/proton-c/bindings/ruby/lib/handler/acking.rb b/proton-c/bindings/ruby/lib/handler/acking.rb new file mode 100644 index 000..2c94cfe --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/acking.rb @@ -0,0 +1,70 @@ +#-- +# 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::Handler + + # Mixing that provides methods for acknowledging a delivery. + # + module Acking + +# Accept the receivered message. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# +def accept(delivery) + self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED) +end + +# Rejects a received message that is considered invalid or unprocessable. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# +def reject(delivery) + self.settle(delivery, Qpid::Proton::Delivery::REJECTED) +end + +# Releases a received message, making it available at the source for any +# other interested receiver. +# +# @param delivery [Qpid::Proton::Delivery] The delivery +# @param delivered [Boolean] True if this was considered a delivery +# attempt. +# +def release(delivery, delivered = true) + if delivered +self.settle(delivery, Qpid::Proton::Delivery::MODIFIED) + else +self.settle(delivery, Qpid::Proton::Delivery::RELEASED) + end +end + +# Settles the specified delivery. Updates the delivery state if a state +# is specified. +# +# @param delivery [Qpid::Proton::Delivery] The delivery. +# @param state [Fixnum] The delivery state. +# +def settle(delivery, state = nil) + delivery.update(state) unless state.nil? + delivery.settle +end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/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 a4b3391..8db28f3 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -84,6 +84,7 @@ require "messenger/messenger" # Handler classes require "handler/c_adaptor" require "handler/wrapped_handler" +require "handler/acking" module Qpid::Proton # @private - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org