You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/11/30 21:42:38 UTC
[07/12] qpid-proton git commit: PROTON-1064: [ruby] Removed C-based
Reactor
PROTON-1064: [ruby] Removed C-based Reactor
Kept a deprecated compatibility shim `Reactor::Container`,
delegates to the new native-ruby Qpid::Proton::Container
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0f03d826
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0f03d826
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0f03d826
Branch: refs/heads/master
Commit: 0f03d826ba0e813c24ceb17b1a644c0f3cf9eccc
Parents: 67c4bae
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Nov 22 14:01:17 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Nov 30 16:36:26 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/README.rdoc | 64 +++++-
proton-c/bindings/ruby/cproton.i | 9 -
proton-c/bindings/ruby/lib/core/connection.rb | 3 +-
proton-c/bindings/ruby/lib/core/container.rb | 3 +
proton-c/bindings/ruby/lib/core/endpoint.rb | 27 ---
proton-c/bindings/ruby/lib/core/message.rb | 22 +-
proton-c/bindings/ruby/lib/core/selectable.rb | 130 -----------
proton-c/bindings/ruby/lib/core/session.rb | 2 +-
proton-c/bindings/ruby/lib/core/uri.rb | 3 +
proton-c/bindings/ruby/lib/event/event.rb | 19 +-
proton-c/bindings/ruby/lib/qpid_proton.rb | 27 +--
proton-c/bindings/ruby/lib/reactor/acceptor.rb | 41 ----
proton-c/bindings/ruby/lib/reactor/backoff.rb | 41 ----
proton-c/bindings/ruby/lib/reactor/connector.rb | 115 ----------
proton-c/bindings/ruby/lib/reactor/container.rb | 220 +++----------------
.../ruby/lib/reactor/global_overrides.rb | 44 ----
.../bindings/ruby/lib/reactor/link_option.rb | 85 -------
proton-c/bindings/ruby/lib/reactor/reactor.rb | 197 -----------------
.../ruby/lib/reactor/session_per_connection.rb | 45 ----
.../bindings/ruby/lib/reactor/ssl_config.rb | 41 ----
proton-c/bindings/ruby/lib/reactor/task.rb | 39 ----
proton-c/bindings/ruby/lib/reactor/urls.rb | 45 ----
.../bindings/ruby/lib/util/class_wrapper.rb | 2 -
proton-c/bindings/ruby/lib/util/reactor.rb | 32 ---
.../ruby/tests/old_examples/direct_send.rb | 3 +-
25 files changed, 128 insertions(+), 1131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/proton-c/bindings/ruby/README.rdoc
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/README.rdoc b/proton-c/bindings/ruby/README.rdoc
index 566cb34..1b902da 100644
--- a/proton-c/bindings/ruby/README.rdoc
+++ b/proton-c/bindings/ruby/README.rdoc
@@ -1,20 +1,72 @@
= Qpid Proton Ruby Language Bindings
-
This is a Ruby language binding for the Qpid proton AMQP messaging library.
You can build clients and servers using this library.
+== Class Overview
+
+The {Qpid::Proton} module contains the key classes:
+
+{Qpid::Proton::Message} represents a message that can be sent or received.
+A message body can be a string or byte sequence encoded any way you choose. However, AMQP also provides standard, interoperable encodings for basic data types like {Hash} and {Array}. The equivalent AMQP encodings can be understood as maps or sequences in any programming langauge with an AMQP library.
+
+{Qpid::Proton::Link} allows messages to be transferred to or from a remote AMQP process. The {Qpid::Proton::Sender} subclass sends messages, the {Qpid::Proton::Receiver} subclass receives them. Links have a source and target address, as explained below.
+
+Links are grouped in a {Qpid::Proton::Session}. Messages in the same session are sent sequentially, while those on different sessions can be interleaved. A large message being sent on one session does not block messages being sent on another session.
+
+Sessions belong to a {Qpid::Proton::Connection}. If you don't need multiple sessions, a connection will create links directly using a default session.
+
+A {Qpid::Proton::Delivery} represents the transfer of a message and allows the receiver to accept or reject it. The sender can use a {Qpid::Proton::Tracker} to track the status of a sent message and find out if it was accepted.
+
+A delivery is settled when both ends are done with it. Different settlement methods give different levels of reliability: at-most-once, at-least-once, and exactly-once. See below.
+
+== The anatomy of a Proton application
+
+{Qpid::Proton::Container} is the top-level object in a Proton application. A client uses {Qpid::Proton::Container#connect} to establish connections. A server uses {Qpid::Proton::Container#listen} to accept connections.
+
+Proton is an event-driven API. You implement a subclass of {Qpid::Proton::MessagingHandler MessagingHandler} and override functions to handle AMQP events, such as {Qpid::Proton::MessagingHandler#on_message #on_message}. Each connection is associated with a handler for its events. {Qpid::Proton::Container#run} polls all connections and listeners and calls the event handling functions on your handlers.
+
+A multi-threaded application can call {Qpid::Proton::Container#run} in more than one thread, the container will use all the {Qpid::Proton::Container#run #run} threads as a thread pool to dispatch events.
+
+== Sources and targets
+
+Every link has two addresses, _source_ and _target_. The most common pattern for using these addresses is as follows:
+
+When a client creates a {Qpid::Proton::Receiver Receiver} link, it sets the _source_ address. This means "I want to receive messages from this source". This is often referred to as "subscribing" to the source. When a client creates a {Qpid::Proton::Sender Sender} link, it sets the _target_ address. This means "I want to send to this target".
+
+In the case of a broker, the source or target usually refers to a queue or topic. In general they can refer to any AMQP-capable node.
+
+In the request-response pattern, a request message carries a reply-to address for the response message. This can be any AMQP address, but it is often useful to create a temporary address for the response message. The client creates a receiver with no source address and the dynamic flag set. The server generates a unique source address for the receiver, which is discarded when the link closes. The client uses this source address as the reply-to when it sends the request, so the response is delivered to the client's receiver.
+
+The server_direct.cpp example shows how to implement a request-response server.
+
+== Settlement
+
+A message is _settled_ by one end of a link when that end has forgotton the message.
+
+_Pre-settled_ messages are settled by the sender before sending. If the connection is lost before the message is received by the receiver, the message will not be delivered.
+
+If the sender does not pre-settle a message, then the receiver settles it once it is processed, and the receiver is informed of the settlement via the {Qpid::Proton::Tracker Tracker}. If the connection is lost before the sender is informed of the settlement, then the delivery is considered in-doubt and the message should be re-set. This ensures it eventually gets delivered (provided the connection and link can be reestablished) but also that it may be delivered multiple times.
== Installing
-If you have the complete proton sources, you can build and install locally with:
+You can install the latest published Gem with
+
+ gem install qpid_proton
+
+*NOTE:* before installing the Gem, you must install the proton-C library.
+
+The proton-C library can be installed by the package manager on many platforms, e.g.
+ yum install qpid-proton-c # Fedora < 25, RHEL < 7
+ dnf install qpid-proton-c # Fedora >= 25, RHEL >= 7
+
+You can also download a source release or the latest development code from http://qpid.apache.org/proton. To build from source:
- cmake -DBUILD_BINDINGS=ruby && make install
+ cmake -DBUILD_BINDINGS=ruby && make
-The cmake build also produces a Ruby Gem file at:
+This produces a Gem file at:
${CMAKE_BUILD_DIR}/proton-c/bindings/ruby/qpid_proton-${PN_VERSION}.gem
-You can install the gem with `gem install` as usual, but note that the proton-C
-library must be before installing the gem.
+You can install the gem with +gem install+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/proton-c/bindings/ruby/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/cproton.i b/proton-c/bindings/ruby/cproton.i
index 107f5d8..0f162fa 100644
--- a/proton-c/bindings/ruby/cproton.i
+++ b/proton-c/bindings/ruby/cproton.i
@@ -573,15 +573,6 @@ VALUE pni_address_of(void *object) {
%}
-//%rename(pn_collector_put) wrap_pn_collector_put;
-//%inline %{
-// pn_event_t *wrap_pn_collector_put(pn_collector_t *collector, void *context,
-// pn_event_type_t type) {
-// return pn_collector_put(collector, PN_RBREF, context, type);
-// }
-// %}
-//%ignore pn_collector_put;
-
int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
%ignore pn_ssl_get_peer_hostname;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
index 4bd7e4f..fbef0cd 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -219,7 +219,6 @@ module Qpid::Proton
object_to_data(opts[:offered_capabilities], Cproton.pn_connection_offered_capabilities(@impl))
object_to_data(opts[:desired_capabilities], Cproton.pn_connection_desired_capabilities(@impl))
object_to_data(opts[:properties], Cproton.pn_connection_properties(@impl))
- Cproton.pn_connection_open(@impl)
end
# @private Generate a unique link name, internal use only.
@@ -272,9 +271,11 @@ module Qpid::Proton
end
# Open a sender on the default_session
+ # @option opts (see Session#open_sender)
def open_sender(opts=nil) default_session.open_sender(opts) end
# Open a on the default_session
+ # @option opts (see Session#open_receiver)
def open_receiver(opts=nil) default_session.open_receiver(opts) end
# Returns the first session from the connection that matches the specified
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/proton-c/bindings/ruby/lib/core/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/container.rb b/proton-c/bindings/ruby/lib/core/container.rb
index 05c45ed..7a4aeb1 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -142,6 +142,9 @@ module Qpid::Proton
@stop_err = nil # Optional error to pass to tasks, from #stop
end
+ # @return [MessagingHandler] The container-wide handler
+ attr_reader :handler
+
# @return [String] unique identifier for this container
attr_reader :id
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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 04551eb..53f5d49 100644
--- a/proton-c/bindings/ruby/lib/core/endpoint.rb
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -118,32 +118,5 @@ module Qpid::Proton
def remote_closed?
check_state(REMOTE_CLOSED)
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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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 d84e795..cbbe905 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -19,25 +19,17 @@
module Qpid::Proton
- # A Message represents an addressable quantity of data.
+ # Messsage data and headers that can sent or received on a {Link}
#
- # ==== Message Body
+ # {#body} is the main message content.
+ # {#properties} is a hash of extra properties that can be attached to the message.
#
- # The message body can be set using the #body= method. The message will
- # then attempt to determine how exactly to encode the content.
+ # @example Create a message containing a Unicode string
+ # msg = Qpid::Proton::Message.new "this is a string"
#
- # ==== 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")
+ # @example Create a message containing binary data
# msg = Qpid::Proton::Message.new
- # msg.body = Qpid::Proton::BinaryString.new(data)
+ # msg.body = Qpid::Proton::BinaryString.new(File.binread("/home/qpid/binfile.tar.gz"))
#
class Message
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 0ae2efe..0000000
--- a/proton-c/bindings/ruby/lib/core/selectable.rb
+++ /dev/null
@@ -1,130 +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
-
- # Selectable enables accessing the underlying file descriptors
- # for Messenger.
- #
- # @private
- class Selectable
-
- # @private
- include Util::SwigHelper
-
- # @private
- PROTON_METHOD_PREFIX = "pn_selectable"
-
- # Returns the underlying file descriptor.
- #
- # This can be used in conjunction with the IO class.
- #
- def fileno
- Cproton.pn_selectable_get_fd(@impl)
- end
-
- proton_reader :reading, :is_or_get => :is
-
- proton_reader :writing, :is_or_get => :is
-
- proton_caller :readable
-
- proton_caller :writable
-
- proton_caller :expired
-
- proton_accessor :registered, :is_or_get => :is
-
- proton_accessor :terminal, :is_or_get => :is
-
- 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
-
- # @private
- include Util::Wrapper
-
- # @private
- def initialize(impl)
- @impl = impl
- self.class.store_instance(self, :pn_selectable_attachments)
- end
-
- 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 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 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 deadline
- tstamp = Cproton.pn_selectable_get_deadline(@impl)
- return nil if tstamp.nil?
- mills_to_sec(tstamp)
- end
-
- def deadline=(deadline)
- Cproton.pn_selectable_set_deadline(sec_to_millis(deadline))
- end
-
- def to_io
- @io ||= IO.new(fileno)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
index a21c152..2c1faeb 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -139,7 +139,7 @@ module Qpid::Proton
return receiver
end
- # TODO aconway 2016-01-04: doc opts or target param
+ # TODO aconway 2016-01-04: doc opts or target param, connection and containers
def open_sender(opts=nil)
opts = { :target => opts } if opts.is_a? String
opts ||= {}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/proton-c/bindings/ruby/lib/core/uri.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/uri.rb b/proton-c/bindings/ruby/lib/core/uri.rb
index aea1e6a..636d20f 100644
--- a/proton-c/bindings/ruby/lib/core/uri.rb
+++ b/proton-c/bindings/ruby/lib/core/uri.rb
@@ -23,6 +23,9 @@ module URI
# AMQP URI scheme for the AMQP protocol
class AMQP < Generic
DEFAULT_PORT = 5672
+
+ # Get the AMQP address: the {#path} minus any leading "/"
+ def amqp_address() path[0] == "/" ? path[1..-1] : path; end
end
@@schemes['AMQP'] = AMQP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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 67d5e92..8492b7c 100644
--- a/proton-c/bindings/ruby/lib/event/event.rb
+++ b/proton-c/bindings/ruby/lib/event/event.rb
@@ -218,20 +218,13 @@ module Qpid::Proton
end
end
- # Returns the reactor for this event.
- #
- # @return [Reactor, nil] The reactor.
- #
+ # @deprecated use {#container}
def reactor
- impl = Cproton.pn_event_reactor(@impl)
- Qpid::Proton::Util::ClassWrapper::WRAPPERS["pn_reactor"].call(impl)
+ deprecated __method__, :container
end
- def container
- @container || Util::ClassWrapper::WRAPPERS["pn_reactor"].call(Cproton.pn_event_reactor(@impl))
- end
-
- def container=(c); @container = c; end
+ # @return container associated with this event
+ attr_reader :container
# Returns the transport for this event.
#
@@ -312,8 +305,8 @@ module Qpid::Proton
"#{self.type}(#{self.context})"
end
+ # @private
+ def container=(c); @container = c; end
end
-
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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 43b8071..cf1a01f 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -28,7 +28,10 @@ else
end
DEPRECATION = "[DEPRECATION]"
-def deprecated(old, new) warn "#{DEPRECATION} #{old} is deprecated, use #{new}"; end
+def deprecated(old, new)
+ repl = new ? ", use `#{new}`" : "with no replacement"
+ warn "#{DEPRECATION} `#{old}` is deprecated #{repl} (called from #{caller(2).first})"
+end
# Exception classes
require "core/exceptions"
@@ -44,7 +47,6 @@ require "util/class_wrapper"
require "util/engine"
require "util/timeout"
require "util/handler"
-require "util/reactor"
# Types
require "types/strings"
@@ -63,7 +65,6 @@ require "event/event"
require "event/collector"
# Main Proton classes
-require "core/selectable"
require "core/uri"
require "core/message"
require "core/endpoint"
@@ -100,24 +101,18 @@ require "handler/outgoing_message_handler"
require "handler/c_flow_controller"
require "handler/messaging_handler"
-# Reactor classes
-require "reactor/task"
-require "reactor/acceptor"
-require "reactor/reactor"
-require "reactor/ssl_config"
-require "reactor/global_overrides"
-require "reactor/urls"
-require "reactor/connector"
-require "reactor/backoff"
-require "reactor/session_per_connection"
-require "reactor/container"
-require "reactor/link_option"
-
# Core classes that depend on handlers and events
require "core/container"
require "core/connection_driver"
+# Reactor classes for backwards compatibility
+require "reactor/container"
+
module Qpid::Proton
+
+ include Qpid::Proton::Handler
+ Tracker = Delivery
+
# @private
def self.registry
@registry ||= {}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 83e0596..0000000
--- a/proton-c/bindings/ruby/lib/reactor/acceptor.rb
+++ /dev/null
@@ -1,41 +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::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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 54bb401..0000000
--- a/proton-c/bindings/ruby/lib/reactor/backoff.rb
+++ /dev/null
@@ -1,41 +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::Reactor
-
- class Backoff
-
- def initialize min_ = 0, max_ = 3
- @min = min_ > 0 ? min_ : 0.1
- @max = [max_, min_].max
- reset
- end
-
- def reset
- @delay = 0
- end
-
- def next
- current = @delay
- @delay = @delay.zero? ? @min : [@max, 2 * @delay].min
- return current
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index b2d0c66..0000000
--- a/proton-c/bindings/ruby/lib/reactor/connector.rb
+++ /dev/null
@@ -1,115 +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::Reactor
-
- class Connector < Qpid::Proton::BaseHandler
-
- def initialize(connection, url, options)
- @connection, @options = connection, options
- @urls = URLs.new(url) if url
- options.each do |k,v|
- case k
- when :url, :urls, :address
- @urls = URLs.new(v) unless @urls
- when :reconnect
- @reconnect = v
- end
- end
- raise ::ArgumentError.new("no url for connect") unless @urls
-
- # TODO aconway 2017-08-17: review reconnect configuration and defaults
- @reconnect = Backoff.new() unless @reconnect
- @ssl_domain = SessionPerConnection.new # TODO seems this should be configurable
- @connection.overrides = self
- @connection.open
- end
-
- def on_connection_local_open(event)
- self.connect(event.connection)
- end
-
- def on_connection_remote_open(event)
- @reconnect.reset if @reconnect
- 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 = @urls.next
- transport = Qpid::Proton::Transport.new
- @options.each do |k,v|
- case k
- when :user
- connection.user = v
- when :password
- connection.password = v
- when :heartbeat
- transport.idle_timeout = v.to_i
- when :idle_timeout
- transport.idle_timeout = v.(v*1000).to_i
- when :sasl_enabled
- transport.sasl if v
- when :sasl_allow_insecure_mechs
- transport.sasl.allow_insecure_mechs = v
- when :sasl_allowed_mechs, :sasl_mechanisms
- transport.sasl.allowed_mechs = v
- end
- end
-
- # TODO aconway 2017-08-11: hostname setting is incorrect, reactor only
- connection.hostname = "#{url.host}:#{url.port}"
- connection.user = url.username if url.username && !url.username.empty?
- connection.password = url.password if url.password && !url.password.empty?
-
- transport.bind(connection)
-
- if (url.scheme == "amqps") && @ssl_domain
- @ssl = Qpid::Proton::SSL.new(transport, @ssl_domain)
- @ssl.peer_hostname = url.host
- end
- end
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
index fbe199e..8862133 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -19,206 +19,56 @@
module Qpid::Proton::Reactor
- private
- class InternalTransactionHandler < Qpid::Proton::Handler::OutgoingMessageHandler
+ # @deprecated use {Qpid::Proton::Container}
+ class Container < Qpid::Proton::Container
- 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
-
- public
- # 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.
- class Container < Reactor
-
- include Qpid::Proton::Util::Reactor
-
- attr_accessor :container_id
- attr_accessor :global_handler
-
- def initialize(handlers, opts = {})
- super(handlers, opts)
+ private
+ alias :super_connect :connect # Access to superclass method
- # only do the following if we're creating a new instance
- if !opts.has_key?(:impl)
- @container_id = String.new(opts[:container_id] || SecureRandom.uuid).freeze
- @ssl = SSLConfig.new
- if opts[:global_handler]
- self.global_handler = GlobalOverrides.new(opts[: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
- end
- end
+ public
- # Initiate an AMQP connection.
- #
- # @param url [String] Connect to URL host:port, using user:password@ if present
- # @param opts [Hash] Named options
- # For backwards compatibility, can be called with a single parameter opts.
- #
- # @option opts [String] :url Connect to URL host:port using user:password@ if present.
- # @option opts [String] :user user name for authentication if not given by URL
- # @option opts [String] :password password for authentication if not given by URL
- # @option opts [Numeric] :idle_timeout seconds before closing an idle connection,
- # can be a fractional value.
- # @option opts [Boolean] :sasl_enabled Enable or disable SASL.
- # @option opts [Boolean] :sasl_allow_insecure_mechs Allow mechanisms that disclose clear text
- # passwords, even over an insecure connection. By default, such mechanisms are only allowed
- # when SSL is enabled.
- # @option opts [String] :sasl_allowed_mechs the allowed SASL mechanisms for use on the connection.
- #
- # @option opts [String] :address *deprecated* use the :url option
- # @option opts [Numeric] :heartbeat milliseconds before closing an idle connection.
- # *deprecated* use :idle_timeout => heartbeat/1000
- #
- # @return [Connection] the new connection
- #
- def connect(url, opts = {})
- # Backwards compatible with old connect(opts)
- if url.is_a? Hash and opts.empty?
- opts = url
- url = nil
- end
- conn = self.connection(opts[:handler])
- connector = Connector.new(conn, url, opts)
- return conn
+ # @deprecated use {Qpid::Proton::Container}
+ def initialize(handlers, opts=nil)
+ deprecated self.class, "Qpid::Proton::Container"
+ super handlers || (opts && opts[:global_handler]), opts && opts[:container_id]
end
- # Initiates the establishment of a link over which messages can be sent.
- #
- # @param context [String, URL] The context.
- # @param opts [Hash] Additional opts.
- # @param opts [String] :target The target address.
- # @param opts [String] :source The source address.
- # @param opts [Boolean] :dynamic
- # @param opts [Object] :handler
- #
- # @return [Sender] The sender.
- #
- def open_sender(context, opts = {})
- if context.is_a?(::String)
- context = Qpid::Proton::URL.new(context)
- end
- if context.is_a?(Qpid::Proton::URL)
- opts[:target] ||= context.path
- end
+ alias :container_id :id
+ alias :global_handler :handler
- return _session(context).open_sender(opts)
+ def connect(opts=nil)
+ url = opts && (opts[:url] || opts[:address])
+ raise ::ArgumentError.new, "no :url or :address option provided" unless url
+ super(url, opts)
end
- # @deprecated use @{#open_sender}
- alias_method :create_sender, :open_sender
-
- # Initiates the establishment of a link over which messages can be received.
- #
- # There are two accepted arguments for the context
- # 1. If a Connection is supplied then the link is established using that
- # object. The source, and optionally the target, address can be supplied
- # 2. If it is a String or a URL then a new Connection is created on which
- # the link will be attached. If a path is specified, but not the source
- # address, then the path of the URL is used as the target address.
- #
- # The name will be generated for the link if one is not specified.
- #
- # @param context [Connection, URL, String] The connection or the connection address.
- # @param opts [Hash] Additional opts.
- # @option opts [String] :source The source address.
- # @option opts [String] :target The target address
- # @option opts [String] :name The link name.
- # @option opts [Boolean] :dynamic
- # @option opts [Object] :handler
- #
- # @return [Receiver]
- #
- def open_receiver(context, opts = {})
- if context.is_a?(::String)
- context = Qpid::Proton::URL.new(context)
+ # @deprecated use {#connect} then {Connection#open_sender}
+ def create_sender(context, opts=nil)
+ c = context if context.is_a? Qpid::Proton::Connection
+ unless c
+ url = Qpid::Proton::uri context
+ c = super_connect(url, opts)
+ opts ||= {}
+ opts[:target] ||= url.amqp_address
end
- if context.is_a?(Qpid::Proton::URL)
- opts[:source] ||= context.path
- end
- return _session(context).open_receiver(opts)
+ c.open_sender opts
end
- # @deprecated use @{#open_sender}
- alias_method :create_receiver, :open_receiver
-
- def declare_transaction(context, handler = nil, settle_before_discharge = false)
- if context.respond_to? :txn_ctl && !context.__send__(:txn_ctl).nil?
- class << context
- attr_accessor :txn_ctl
- end
- context.txn_ctl = self.create_sender(context, nil, "txn-ctl",
- InternalTransactionHandler.new())
+ # @deprecated use {#connect} then {Connection#open_receiver}
+ def create_receiver(context, opts=nil)
+ c = context if context.is_a? Qpid::Proton::Connection
+ unless c
+ url = Qpid::Proton::uri context
+ c = super_connect(url, opts)
+ opts ||= {}
+ opts[:source] ||= url.amqp_address
end
- return Transaction.new(context.txn_ctl, handler, settle_before_discharge)
+ c.open_receiver opts
end
- # Initiates a server socket, accepting incoming AMQP connections on the
- # interface and port specified.
- #
- # @param url []
- # @param ssl_domain []
- #
def listen(url, ssl_domain = nil)
- url = Qpid::Proton::URL.new(url)
- acceptor = self.acceptor(url.host, url.port)
- ssl_config = ssl_domain
- if ssl_config.nil? && (url.scheme == 'amqps') && @ssl
- ssl_config = @ssl.server
- end
- if !ssl_config.nil?
- acceptor.ssl_domain(ssl_config)
- end
- return acceptor
- end
-
- private
-
- def _session(context)
- if context.is_a?(Qpid::Proton::URL)
- return _session(self.connect(:url => context))
- elsif context.is_a?(Qpid::Proton::Session)
- return context
- elsif context.is_a?(Qpid::Proton::Connection)
- return context.default_session
- else
- return context.session
- end
+ # TODO aconway 2017-11-29: ssl_domain
+ super(url)
end
-
- def do_work(timeout = nil)
- self.timeout = timeout unless timeout.nil?
- self.process
- end
-
- def _apply_link_opts(opts, link)
- opts.each {|o| o.apply(link) if o.test(link)}
- end
-
- def to_s
- "#{self.class}<@impl=#{Cproton.pni_address_of(@impl)}>"
- end
-
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 11d05a5..0000000
--- a/proton-c/bindings/ruby/lib/reactor/global_overrides.rb
+++ /dev/null
@@ -1,44 +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::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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 2066bab..0000000
--- a/proton-c/bindings/ruby/lib/reactor/link_option.rb
+++ /dev/null
@@ -1,85 +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::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.object = @properties
- else
- link.target.properties.object = @properties
- end
- end
- end
-
- class Filter < ReceiverOption
- def initialize(filter_set = {})
- @filter_set = filter_set
- end
-
- def apply(receiver)
- receiver.source.filter.object = @filter_set
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 88d062e..0000000
--- a/proton-c/bindings/ruby/lib/reactor/reactor.rb
+++ /dev/null
@@ -1,197 +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::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 = {})
- deprecated(self.class, "Qpid::Proton::Container")
- @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 [Integer] The timeout period, in seconds.
- #
- def timeout
- millis_to_timeout(Cproton.pn_reactor_get_timeout(@impl))
- end
-
- # Sets the timeout period.
- #
- # @param timeout [Integer] 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, set.method(:on_error))
- Cproton.pn_reactor_set_handler(@impl, impl)
- Cproton.pn_decref(impl)
- end
-
- def run(&block)
- self.timeout = 3.14159265359
- self.start
- while self.process do
- if block_given?
- yield
- end
- end
- self.stop
- end
-
- def wakeup
- n = Cproton.pn_reactor_wakeup(@impl)
- unless n.zero?
- raise IOError.new(Cproton.pn_reactor_error(@impl))
- end
- end
-
- def process
- result = Cproton.pn_reactor_process(@impl)
- if !self.errors.nil? && !self.errors.empty?
- (0...self.errors.size).each do |index|
- error_set = self.errors[index]
- print error.backtrace.join("\n")
- end
- raise self.errors.last
- end
- return result
- end
-
- def schedule(delay, task)
- impl = chandler(task, self.method(:on_error))
- task = Task.wrap(Cproton.pn_reactor_schedule(@impl, sec_to_millis(delay), impl))
- Cproton.pn_decref(impl)
- return task
- end
-
- def acceptor(host, port, handler = nil)
- impl = chandler(handler, self.method(:on_error))
- aimpl = Cproton.pn_reactor_acceptor(@impl, host, "#{port}", impl)
- Cproton.pn_decref(impl)
- if !aimpl.nil?
- return Acceptor.new(aimpl)
- else
- io_error = Cproton.pn_reactor_error(@impl)
- error_text = Cproton.pn_error_text(io_error)
- text = "(#{Cproton.pn_error_text(io_error)} (#{host}:#{port}))"
- raise IOError.new(text)
- end
- end
-
- def connection(handler = nil)
- impl = chandler(handler, self.method(:on_error))
- conn = Qpid::Proton::Connection.wrap(Cproton.pn_reactor_connection(@impl, impl))
- Cproton.pn_decref(impl)
- return conn
- end
-
- def selectable(handler = nil)
- impl = chandler(handler, self.method(:on_error))
- result = Selectable.wrap(Cproton.pn_reactor_selectable(@impl))
- if !impl.nil?
- record = Cproton.pn_selectable_attachments(result.impl)
- Cproton.pn_record_set_handler(record, impl)
- Cproton.pn_decref(impl)
- end
- return result
- end
-
- def update(sel)
- Cproton.pn_reactor_update(@impl, sel.impl)
- end
-
- def push_event(obj, etype)
- Cproton.pn_collector_put(Cproton.pn_reactor_collector(@impl), Qpid::Proton::Util::RBCTX, Cproton.pn_py2void(obj), etype.number)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index f8180c0..0000000
--- a/proton-c/bindings/ruby/lib/reactor/session_per_connection.rb
+++ /dev/null
@@ -1,45 +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::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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 56fec71..0000000
--- a/proton-c/bindings/ruby/lib/reactor/ssl_config.rb
+++ /dev/null
@@ -1,41 +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::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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 6818ed2..0000000
--- a/proton-c/bindings/ruby/lib/reactor/task.rb
+++ /dev/null
@@ -1,39 +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::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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 92cab81..0000000
--- a/proton-c/bindings/ruby/lib/reactor/urls.rb
+++ /dev/null
@@ -1,45 +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::Reactor
-
- class URLs
-
- def initialize(values)
- @values = values
- if @values.is_a? Enumerable
- @values = @values.map { |u| Qpid::Proton::URL.new(u) }
- else
- @values = [Qpid::Proton::URL.new(values)]
- end
- @iter = @values.each
- end
-
- def next
- begin
- return @iter.next
- rescue StopIteration
- @iter = @values.each
- return @iter.next
- end
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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 dec16e9..134f655 100644
--- a/proton-c/bindings/ruby/lib/util/class_wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/class_wrapper.rb
@@ -36,8 +36,6 @@ 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)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/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
deleted file mode 100644
index 0bcb557..0000000
--- a/proton-c/bindings/ruby/lib/util/reactor.rb
+++ /dev/null
@@ -1,32 +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::Util
-
- module Reactor
-
- def create_session(connection, handler = nil)
- session = connection.session
- session.open
- return session
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f03d826/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/direct_send.rb b/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
index 50543b2..c507b46 100644
--- a/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
@@ -57,7 +57,8 @@ OptionParser.new do |opts|
end.parse!
begin
- Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
+ Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages]), {:container_id=> "direct_send"}).run
+
rescue Interrupt => error
puts "ERROR: #{error}"
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org