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 2018/01/05 16:35:25 UTC
[01/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fix
copyright comments and top-level yard doc
Repository: qpid-proton
Updated Branches:
refs/heads/go1 6c48527c1 -> b25d21e67
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/test_tools.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_tools.rb b/proton-c/bindings/ruby/tests/test_tools.rb
index b0e98d6..2dc13b3 100644
--- a/proton-c/bindings/ruby/tests/test_tools.rb
+++ b/proton-c/bindings/ruby/tests/test_tools.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
# Tools for tests. Only minitest is used.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/test_uri.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_uri.rb b/proton-c/bindings/ruby/tests/test_uri.rb
index 2cfa3b7..95887b1 100644
--- a/proton-c/bindings/ruby/tests/test_uri.rb
+++ b/proton-c/bindings/ruby/tests/test_uri.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'minitest/autorun'
require 'qpid_proton'
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[26/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] add
deprecation warnings and aliases
Posted by ac...@apache.org.
PROTON-1537: [ruby] add deprecation warnings and aliases
Fixed a few uses of deprecated APIs internall.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5d7dd4af
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5d7dd4af
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5d7dd4af
Branch: refs/heads/go1
Commit: 5d7dd4af1cd861e3d0b107f073ef8436dbc9ab7f
Parents: a13bc2b
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 13 15:01:29 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 15:30:35 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 7 +-
proton-c/bindings/ruby/lib/core/delivery.rb | 2 +-
proton-c/bindings/ruby/lib/core/disposition.rb | 4 +-
proton-c/bindings/ruby/lib/core/endpoint.rb | 3 +-
proton-c/bindings/ruby/lib/core/event.rb | 11 ++-
proton-c/bindings/ruby/lib/core/link.rb | 2 +-
proton-c/bindings/ruby/lib/core/message.rb | 3 +
proton-c/bindings/ruby/lib/core/sasl.rb | 80 ++++++++++----------
proton-c/bindings/ruby/lib/core/sender.rb | 19 ++---
proton-c/bindings/ruby/lib/core/session.rb | 11 ++-
proton-c/bindings/ruby/lib/core/ssl.rb | 2 +-
proton-c/bindings/ruby/lib/core/transfer.rb | 5 +-
proton-c/bindings/ruby/lib/core/transport.rb | 2 +
proton-c/bindings/ruby/lib/core/url.rb | 3 +-
.../ruby/lib/handler/messaging_adapter.rb | 2 +-
.../ruby/lib/handler/messaging_handler.rb | 5 +-
.../lib/handler/reactor_messaging_adapter.rb | 2 +-
.../bindings/ruby/lib/messenger/messenger.rb | 3 +-
proton-c/bindings/ruby/lib/qpid_proton.rb | 8 +-
proton-c/bindings/ruby/lib/reactor/container.rb | 5 +-
proton-c/bindings/ruby/lib/types/array.rb | 15 ++--
proton-c/bindings/ruby/lib/types/hash.rb | 6 +-
proton-c/bindings/ruby/lib/util/deprecation.rb | 42 ++++++++++
23 files changed, 151 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 dcbae1f..3ec7c26 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -20,6 +20,7 @@ module Qpid::Proton
# An AMQP connection.
class Connection < Endpoint
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_connection"
@@ -58,10 +59,10 @@ module Qpid::Proton
public
# @deprecated no replacement
- def overrides?() Qpid.deprecated __method__; false; end
+ def overrides?() deprecated __method__; false; end
# @deprecated no replacement
- def session_policy?() Qpid.deprecated __method__; false; end
+ def session_policy?() deprecated __method__; false; end
# @return [Connection] self
def connection() self; end
@@ -179,7 +180,7 @@ module Qpid::Proton
end
# @deprecated use #default_session()
- alias session default_session
+ deprecated_alias :session, :default_session
# Open a new session on this connection.
def open_session
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index e86a06e..fd5c43a 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -64,7 +64,7 @@ module Qpid::Proton
# @deprecated use {#release} with modification options
def modify()
- Qpid.deprecated __method__, "#release"
+ deprecated __method__, "release(modification_options)"
release failed=>true
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index 9cecf69..bca787e 100644
--- a/proton-c/bindings/ruby/lib/core/disposition.rb
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -20,6 +20,8 @@ module Qpid::Proton
# @deprecated use {Delivery}
class Disposition
+ include Util::Deprecation
+
# @private
PROTON_METHOD_PREFIX = "pn_disposition"
# @private
@@ -36,7 +38,7 @@ module Qpid::Proton
# @private
def initialize(impl, local)
- Qpid.deprecated self.class, Delivery
+ deprecated self.class, Delivery
@impl = impl
@local = local
@data = nil
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 bd66f7a..86d8efe 100644
--- a/proton-c/bindings/ruby/lib/core/endpoint.rb
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -30,9 +30,10 @@ module Qpid::Proton
# puts "Remote connection flags: #{conn.state || Qpid::Proton::Endpoint::REMOTE_MASK}"
#
class Endpoint
+ include Util::Deprecation
# The local connection is uninitialized.
- LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT
+ LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT
# The local connection is active.
LOCAL_ACTIVE = Cproton::PN_LOCAL_ACTIVE
# The local connection is closed.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index 079d1bd..ee0fc02 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -17,12 +17,11 @@
module Qpid::Proton
- # AMQP protocol event.
- #
- # Includes a method name to call when the event is dispatched, and the context
- # objects relevant to the event.
+
+ # @deprecated Only used with the deprecated {Handler::MessagingHandler} API.
class Event
private
+ include Util::Deprecation
PROTON_METHOD_PREFIX = "pn_disposition"
include Util::Wrapper
@@ -150,9 +149,9 @@ module Qpid::Proton
end
# @deprecated use {#container}
- def reactor() Qpid.deprecated __method__, :container; container; end
+ deprecated_alias :reactor, :container
- # @deprecated use {Qpid::Proton::Event}
+ # @private
Event = self
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index 209d018..88c0e52 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -286,7 +286,7 @@ module Qpid::Proton
# @deprecated use {Sender#send}
def delivery(tag)
- Qpid.deprecated __method__, "Sender#send"
+ deprecated __method__, "Sender#send"
Delivery.new(Cproton.pn_delivery(@impl, tag))
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 7041d04..8b13de2 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -31,6 +31,7 @@ module Qpid::Proton
# msg.body = Qpid::Proton::BinaryString.new(File.binread("/home/qpid/binfile.tar.gz"))
#
class Message
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_message"
@@ -364,11 +365,13 @@ module Qpid::Proton
# @deprecated use {#body=}
def content=(content)
+ deprecated __method__, "body="
Cproton.pn_message_load(@impl, content)
end
# @deprecated use {#body}
def content
+ deprecated __method__, "body"
size = 16
loop do
result = Cproton.pn_message_save(@impl, size)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index 08b5e4e..14ab238 100644
--- a/proton-c/bindings/ruby/lib/core/sasl.rb
+++ b/proton-c/bindings/ruby/lib/core/sasl.rb
@@ -29,6 +29,7 @@ module Qpid::Proton
#
# @note Do not instantiate directly, use {Transport#sasl} to create a SASL object.
class SASL
+ include Util::Deprecation
# Negotation has not completed.
NONE = Cproton::PN_SASL_NONE
@@ -65,9 +66,7 @@ module Qpid::Proton
end
# @deprecated use {#allowed_mechs=}
- def mechanisms(m)
- self.allowed_mechs = m
- end
+ deprecated_alias :mechanisms, :allowed_mechs=
# True if extended SASL negotiation is supported
#
@@ -82,44 +81,43 @@ module Qpid::Proton
Cproton.pn_sasl_extended()
end
- # Set the sasl configuration path
- #
- # This is used to tell SASL where to look for the configuration file.
- # In the current implementation it can be a colon separated list of directories.
- #
- # The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
- # but if both methods are used then this pn_sasl_config_path() will take precedence.
- #
- # If not set the underlying implementation default will be used.
- #
- # @param path the configuration path
- #
- def self.config_path=(path)
- Cproton.pn_sasl_config_path(nil, path)
- path
- end
-
- # @deprecated use {config_path=}
- def self.config_path(path)
- self.config_path = path
- end
-
- # Set the configuration file name, without extension
- #
- # The name with an a ".conf" extension will be searched for in the
- # configuration path. If not set, it defaults to "proton-server" or
- # "proton-client" for a server (incoming) or client (outgoing) connection
- # respectively.
- #
- # @param name the configuration file name without extension
- #
- def self.config_name=(name)
- Cproton.pn_sasl_config_name(nil, name)
- end
-
- # @deprecated use {config_name=}
- def self.config_name(name)
- self.config_name = name
+ class << self
+ include Util::Deprecation
+
+ # Set the sasl configuration path
+ #
+ # This is used to tell SASL where to look for the configuration file.
+ # In the current implementation it can be a colon separated list of directories.
+ #
+ # The environment variable PN_SASL_CONFIG_PATH can also be used to set this path,
+ # but if both methods are used then this pn_sasl_config_path() will take precedence.
+ #
+ # If not set the underlying implementation default will be used.
+ #
+ # @param path the configuration path
+ #
+ def config_path=(path)
+ Cproton.pn_sasl_config_path(nil, path)
+ path
+ end
+
+ # Set the configuration file name, without extension
+ #
+ # The name with an a ".conf" extension will be searched for in the
+ # configuration path. If not set, it defaults to "proton-server" or
+ # "proton-client" for a server (incoming) or client (outgoing) connection
+ # respectively.
+ #
+ # @param name the configuration file name without extension
+ #
+ def config_name=(name)
+ Cproton.pn_sasl_config_name(nil, name)
+ end
+
+ # @deprecated use {config_path=}
+ deprecated_alias :config_path, :config_path=
+ # @deprecated use {config_name=}
+ deprecated_alias :config_name, :config_name=
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index bef3460..4c7324c 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -50,7 +50,7 @@ module Qpid::Proton
raise ArgumentError("too many arguments") if args.size > 1
tag = args[0]
end
- tag ||= delivery_tag
+ tag ||= next_tag
t = Tracker.new(Cproton.pn_delivery(@impl, tag))
Cproton.pn_link_send(@impl, message.encode)
Cproton.pn_link_advance(@impl)
@@ -58,19 +58,20 @@ module Qpid::Proton
return t
end
- # @deprecated internal use only
+ # @deprecated use {#send}
def stream(bytes)
+ deprecated __method__, "send"
Cproton.pn_link_send(@impl, bytes)
end
# @deprecated internal use only
- def delivery_tag
- @tag_count ||= 0
- result = @tag_count.succ
- @tag_count = result
- return result.to_s(32) # Base 32 compactness
- end
+ def delivery_tag() deprecated(__method__); next_tag; end
- end
+ private
+ def initialize(*arg) super; @tag_count = 0; end
+ def next_tag() (@tag_count += 1).to_s(32); end
+ end
end
+
+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 26a7a2f..14f1a67 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -23,6 +23,7 @@ module Qpid::Proton
# A Session has a single parent Qpid::Proton::Connection instance.
#
class Session < Endpoint
+ include Util::Deprecation
# @private
PROTON_METHOD_PREFIX = "pn_session"
@@ -112,10 +113,16 @@ module Qpid::Proton
end
# @deprecated use {#open_sender}
- def sender(name) Sender.new(Cproton.pn_sender(@impl, name)); end
+ def sender(name)
+ deprecated __method__, "open_sender"
+ Sender.new(Cproton.pn_sender(@impl, name));
+ end
# @deprecated use {#open_receiver}
- def receiver(name) Receiver.new(Cproton.pn_receiver(@impl, name)); end
+ def receiver(name)
+ deprecated __method__, "open_receiver"
+ Receiver.new(Cproton.pn_receiver(@impl, name))
+ end
# TODO aconway 2016-01-04: doc options or target param, move option handling to Link.
def open_receiver(opts=nil)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 11db54d..ec4f14d 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -51,7 +51,7 @@ module Qpid::Proton
# @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.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index f9c67f5..17f3b82 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# Status of a message transfer on a {Link}
# Common base class for {Tracker} and {Delivery}.
class Transfer
+ include Util::Deprecation
# @!private
PROTON_METHOD_PREFIX = "pn_delivery"
@@ -66,7 +67,7 @@ module Qpid::Proton
def id() Cproton.pn_delivery_tag(@impl); end
# @deprecated use {#id}
- alias tag id
+ deprecated_alias :tag, :id
# @return [Boolean] True if the transfer has is remotely settled.
proton_caller :settled?
@@ -105,7 +106,7 @@ module Qpid::Proton
# @deprecated internal use only
def local_state() Cproton.pn_delivery_local_state(@impl); end
# @deprecated use {#state}
- def remote_state() Cproton.pn_delivery_remote_state(@impl); end
+ deprecated_alias :remote_state, :state
# @deprecated internal use only
def settle(state = nil)
update(state) unless state.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 f840f3f..64a8011 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -62,6 +62,8 @@ module Qpid::Proton
# PN_TRACE_FRM=1 ruby my_proton_app.rb
#
class Transport
+ include Util::Deprecation
+
# @private
PROTON_METHOD_PREFIX = "pn_transport"
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index 48f295c..1103e06 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -20,6 +20,7 @@ module Qpid::Proton
# @deprecated use {URI} or {String}
class URL
+ include Util::Deprecation
attr_reader :scheme
attr_reader :username
@@ -32,7 +33,7 @@ module Qpid::Proton
# Parse a string, return a new URL
# @param url [#to_s] the URL string
def initialize(url = nil)
- Qpid.deprecated self.class, 'URI or String'
+ deprecated self.class, 'URI or String'
if url
@url = Cproton.pn_url_parse(url.to_s)
if @url.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
index 4f24d09..92dbba4 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
@@ -97,7 +97,7 @@ module Qpid::Proton
add_credit(event.receiver)
else # Outgoing message
t = event.tracker
- case t.remote_state
+ case t.state
when Delivery::ACCEPTED then delegate(:on_tracker_accept, t)
when Delivery::REJECTED then delegate(:on_tracker_reject, t)
when Delivery::RELEASED then delegate(:on_tracker_release, t)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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
index e4e5e12..d01ea1e 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::MessagingHandler}
class MessagingHandler
+ include Util::Deprecation
# @private
def proton_adapter_class() Handler::ReactorMessagingAdapter; end
@@ -48,9 +49,9 @@ module Qpid::Proton
# the set the local error condition {Condition}("error", "unexpected peer close")
#
# @overload initialize(prefetch=10, auto_accept=true, auto_settle=true, peer_close_is_error=false)
- # @deprecated use +initialize(opts)+ overload
+ # @deprecated use +initialize(opts)+ overload
def initialize(*args)
- Qpid.deprecated MessagingHandler, Qpid::Proton::MessagingHandler
+ deprecated MessagingHandler, Qpid::Proton::MessagingHandler
@options = {}
if args.size == 1 && args[0].is_a?(Hash)
@options.replace(args[0])
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
index 7acbbae..3466ef1 100644
--- a/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
@@ -128,7 +128,7 @@ module Qpid::Proton
else # Outgoing message
t = event.tracker
if t.updated?
- case t.remote_state
+ case t.state
when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index 0c39429..7b992e2 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -56,6 +56,7 @@ module Qpid::Proton::Messenger
class Messenger
include Qpid::Proton::Util::ErrorHandler
+ include Qpid::Proton::Util::Deprecation
can_raise_error [:send, :receive, :password=, :start, :stop,
:perform_put, :perform_get, :interrupt,
@@ -72,7 +73,7 @@ module Qpid::Proton::Messenger
# * name - the name (def. nil)
#
def initialize(name = nil)
- Qpid.deprecated 'Qpid::Proton::Messenger', 'Qpid::Proton::Container'
+ deprecated Qpid::Proton::Messenger, Qpid::Proton::Container
@impl = Cproton.pn_messenger(name)
@selectables = {}
ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 922504f..79c8cb7 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -29,15 +29,10 @@ end
# Qpid is the top level module for the Qpid project http://qpid.apache.org
# Definitions for this library are in module {Qpid::Proton}
module Qpid
- # @private
- def self.deprecated(old, new=nil)
- repl = new ? "use `#{new}`" : "internal use only"
- warn "[DEPRECATION] `#{old}` is deprecated, #{repl} (called from #{caller(2).first})"
- end
-
# Proton is a ruby API for sending and receiving AMQP messages in clients or servers.
# See the {overview}[../file.README.html] for more.
module Proton
+ # Only opened here for module doc comment
end
end
@@ -45,6 +40,7 @@ end
require "core/exceptions"
# Utility classes
+require "util/deprecation"
require "util/version"
require "util/error_handler"
require "util/wrapper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 a900d9e..22cb0e8 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -21,6 +21,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::Container}
class Container < Qpid::Proton::Container
+ include Util::Deprecation
private
alias super_connect connect # Access to superclass method
@@ -29,7 +30,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::Container}
def initialize(handlers, opts=nil)
- Qpid.deprecated self.class, "Qpid::Proton::Container"
+ deprecated Qpid::Proton::Reactor::Container, Qpid::Proton::Container
h = handlers || (opts && opts[:global_handler])
id = opts && opts[:container_id]
super(h, id)
@@ -44,7 +45,6 @@ module Qpid::Proton
super(url, opts)
end
- # @deprecated use {#connect} then {Connection#open_sender}
def create_sender(context, opts=nil)
c = context if context.is_a? Qpid::Proton::Connection
unless c
@@ -56,7 +56,6 @@ module Qpid::Proton
c.open_sender opts
end
- # @deprecated use {#connect} then {Connection#open_receiver}
def create_receiver(context, opts=nil)
c = context if context.is_a? Qpid::Proton::Connection
unless c
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/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 4ea1d70..7a20adb 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -26,7 +26,10 @@ module Qpid::Proton
# @deprecated use {UniformArray}
class ArrayHeader
- def initialize(type, descriptor = nil) @type, @descriptor = Codec::Mapping[type], descriptor; end
+ def initialize(type, descriptor = nil)
+ Util::Deprecation.deprecated ArrayHeader, "UniformArray"
+ @type, @descriptor = Codec::Mapping[type], descriptor
+ end
attr_reader :type, :descriptor
def described?() !@descriptor.nil?; end
def <=>(x) [@type, @descriptor] <=> [x.type, x.descriptor]; end
@@ -72,25 +75,25 @@ end
class ::Array
# @deprecated use {UniformArray}
def proton_array_header
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header
end
# @deprecated use {UniformArray}
def proton_array_header=(h)
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header= h
end
# @deprecated use {UniformArray}
def proton_described?()
- Qpid.deprecated __method__, "UniformArray"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, UniformArray
@proton_array_header && @proton_array_header.described?
end
# @deprecated
def proton_put(data)
- Qpid.deprecated __method__, "Codec::Data#array=, Codec::Data#list="
+ Qpid::Proton::Util::Deprecation.deprecated __method__, "Codec::Data#array=, Codec::Data#list="
raise TypeError, "nil data" unless data
if @proton_array_header && @proton_array_header.type
data.array = self
@@ -101,7 +104,7 @@ class ::Array
# @deprecated
def self.proton_get(data)
- Qpid.deprecated __method__, "Codec::Data#list"
+ Qpid::Proton::Util::Deprecation.deprecated __method__, "Codec::Data#list"
data.list
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index f70cbdb..2d78f74 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -23,15 +23,17 @@
# @private
class Hash # :nodoc:
+
+
# @deprecated
def proton_data_put(data)
- Qpid.deprecated(__method__, "Codec::Data#map=")
+ Qpid::Proton::Util::Deprecation.deprecated(__method__, "Codec::Data#map=")
data.map = self
end
# @deprecated
def self.proton_data_get(data)
- Qpid.deprecated(__method__, "Codec::Data#map")
+ Qpid::Proton::Util::Deprecation.deprecated(__method__, "Codec::Data#map")
data.map
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5d7dd4af/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
new file mode 100644
index 0000000..2e83783
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -0,0 +1,42 @@
+# 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 Deprecation
+ def self.deprecated(old, new=nil, skip=2)
+ replace = new ? "use `#{new}`" : "internal use only"
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from\n #{caller(skip).first}"
+ end
+
+ def deprecated(*arg) Deprecation.deprecated(*arg); end
+
+ module ClassMethods
+ def deprecated_alias(bad, good)
+ bad, good = bad.to_sym, good.to_sym
+ define_method(bad) do |*args, &block|
+ self.deprecated bad, good, 3
+ self.__send__(good, *args, &block)
+ end
+ end
+ end
+
+ def self.included(other)
+ other.__send__ :extend, ClassMethods
+ end
+ end
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[49/50] [abbrv] qpid-proton git commit: Merge tag '0.19.0' into go1
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/unmarshal.go
----------------------------------------------------------------------
diff --cc amqp/unmarshal.go
index 253d66d,0000000..97e8437
mode 100644,000000..100644
--- a/amqp/unmarshal.go
+++ b/amqp/unmarshal.go
@@@ -1,638 -1,0 +1,733 @@@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+oor 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.
+*/
+
+package amqp
+
+// #include <proton/codec.h>
+import "C"
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "reflect"
- "strings"
++ "time"
+ "unsafe"
+)
+
+const minDecode = 1024
+
+// Error returned if AMQP data cannot be unmarshaled as the desired Go type.
+type UnmarshalError struct {
+ // The name of the AMQP type.
+ AMQPType string
+ // The Go type.
+ GoType reflect.Type
+
+ s string
+}
+
+func (e UnmarshalError) Error() string { return e.s }
+
- func newUnmarshalErrorMsg(pnType C.pn_type_t, v interface{}, msg string) *UnmarshalError {
- if len(msg) > 0 && !strings.HasPrefix(msg, ":") {
- msg = ": " + msg
++// Error returned if there are not enough bytes to decode a complete AMQP value.
++var EndOfData = &UnmarshalError{s: "Not enough data for AMQP value"}
++
++var badData = &UnmarshalError{s: "Unexpected error in data"}
++
++func newUnmarshalError(pnType C.pn_type_t, v interface{}) *UnmarshalError {
++ e := &UnmarshalError{
++ AMQPType: C.pn_type_t(pnType).String(),
++ GoType: reflect.TypeOf(v),
+ }
- e := &UnmarshalError{AMQPType: C.pn_type_t(pnType).String(), GoType: reflect.TypeOf(v)}
- if e.GoType.Kind() != reflect.Ptr {
- e.s = fmt.Sprintf("cannot unmarshal to type %s, not a pointer%s", e.GoType, msg)
++ if e.GoType == nil || e.GoType.Kind() != reflect.Ptr {
++ e.s = fmt.Sprintf("cannot unmarshal to Go type %v, not a pointer", e.GoType)
+ } else {
- e.s = fmt.Sprintf("cannot unmarshal AMQP %s to %s%s", e.AMQPType, e.GoType, msg)
++ e.s = fmt.Sprintf("cannot unmarshal AMQP %v to Go %v", e.AMQPType, e.GoType.Elem())
+ }
+ return e
+}
+
- func newUnmarshalError(pnType C.pn_type_t, v interface{}) *UnmarshalError {
- return newUnmarshalErrorMsg(pnType, v, "")
++func doPanic(data *C.pn_data_t, v interface{}) {
++ e := newUnmarshalError(C.pn_data_type(data), v)
++ panic(e)
+}
+
- func newUnmarshalErrorData(data *C.pn_data_t, v interface{}) *UnmarshalError {
- err := PnError(C.pn_data_error(data))
- if err == nil {
- return nil
- }
++func doPanicMsg(data *C.pn_data_t, v interface{}, msg string) {
+ e := newUnmarshalError(C.pn_data_type(data), v)
- e.s = e.s + ": " + err.Error()
- return e
++ e.s = e.s + ": " + msg
++ panic(e)
+}
+
- func recoverUnmarshal(err *error) {
- if r := recover(); r != nil {
- if uerr, ok := r.(*UnmarshalError); ok {
- *err = uerr
- } else {
- panic(r)
- }
++func panicIfBadData(data *C.pn_data_t, v interface{}) {
++ if C.pn_data_errno(data) != 0 {
++ doPanicMsg(data, v, PnError(C.pn_data_error(data)).Error())
++ }
++}
++
++func panicUnless(ok bool, data *C.pn_data_t, v interface{}) {
++ if !ok {
++ doPanic(data, v)
++ }
++}
++
++func checkOp(ok bool, v interface{}) {
++ if !ok {
++ panic(&badData)
+ }
+}
+
+//
+// Decoding from a pn_data_t
+//
+// NOTE: we use panic() to signal a decoding error, simplifies decoding logic.
+// We recover() at the highest possible level - i.e. in the exported Unmarshal or Decode.
+//
+
+// Decoder decodes AMQP values from an io.Reader.
+//
+type Decoder struct {
+ reader io.Reader
+ buffer bytes.Buffer
+}
+
+// NewDecoder returns a new decoder that reads from r.
+//
+// The decoder has it's own buffer and may read more data than required for the
+// AMQP values requested. Use Buffered to see if there is data left in the
+// buffer.
+//
+func NewDecoder(r io.Reader) *Decoder {
+ return &Decoder{r, bytes.Buffer{}}
+}
+
+// Buffered returns a reader of the data remaining in the Decoder's buffer. The
+// reader is valid until the next call to Decode.
+//
+func (d *Decoder) Buffered() io.Reader {
+ return bytes.NewReader(d.buffer.Bytes())
+}
+
+// Decode reads the next AMQP value from the Reader and stores it in the value pointed to by v.
+//
+// See the documentation for Unmarshal for details about the conversion of AMQP into a Go value.
+//
+func (d *Decoder) Decode(v interface{}) (err error) {
- defer recoverUnmarshal(&err)
+ data := C.pn_data(0)
+ defer C.pn_data_free(data)
+ var n int
- for n == 0 {
- n, err = decode(data, d.buffer.Bytes())
- if err != nil {
- return err
++ for n, err = decode(data, d.buffer.Bytes()); err == EndOfData; {
++ err = d.more()
++ if err == nil {
++ n, err = decode(data, d.buffer.Bytes())
+ }
- if n == 0 { // n == 0 means not enough data, read more
- err = d.more()
- } else {
- unmarshal(v, data)
++ }
++ if err == nil {
++ if err = recoverUnmarshal(v, data); err == nil {
++ d.buffer.Next(n)
+ }
+ }
- d.buffer.Next(n)
+ return
+}
+
+/*
- Unmarshal decodes AMQP-encoded bytes and stores the result in the Go value pointed to by v.
- Types are converted as follows:
-
- +------------------------+-------------------------------------------------+
- |To Go types |From AMQP types |
- +========================+=================================================+
- |bool |bool |
- +------------------------+-------------------------------------------------+
- |int, int8, int16, int32,|Equivalent or smaller signed integer type: byte, |
- |int64 |short, int, long. |
- +------------------------+-------------------------------------------------+
- |uint, uint8, uint16, |Equivalent or smaller unsigned integer type: |
- |uint32, uint64 |ubyte, ushort, uint, ulong |
- +------------------------+-------------------------------------------------+
- |float32, float64 |Equivalent or smaller float or double. |
- +------------------------+-------------------------------------------------+
- |string, []byte |string, symbol or binary. |
- +------------------------+-------------------------------------------------+
- |Symbol |symbol |
- +------------------------+-------------------------------------------------+
- |map[K]T |map, provided all keys and values can unmarshal |
- | |to types K,T |
- +------------------------+-------------------------------------------------+
- |Map |map, any AMQP map |
- +------------------------+-------------------------------------------------+
- |Described |described type |
- +------------------------+-------------------------------------------------+
-
- An AMQP described type can unmarshal into the corresponding plain type, discarding the descriptor.
- For example an AMQP described string can unmarshal into a plain go string.
- Unmarshal into the Described type preserves the descriptor.
-
- Any AMQP type can unmarshal to an interface{}, the Go type used to unmarshal is chosen from the AMQP type as follows
-
- +------------------------+-------------------------------------------------+
- |AMQP Type |Go Type in interface{} |
- +========================+=================================================+
- |bool |bool |
- +------------------------+-------------------------------------------------+
- |byte,short,int,long |int8,int16,int32,int64 |
- +------------------------+-------------------------------------------------+
- |ubyte,ushort,uint,ulong |uint8,uint16,uint32,uint64 |
- +------------------------+-------------------------------------------------+
- |float, double |float32, float64 |
- +------------------------+-------------------------------------------------+
- |string |string |
- +------------------------+-------------------------------------------------+
- |symbol |Symbol |
- +------------------------+-------------------------------------------------+
- |binary |Binary |
- +------------------------+-------------------------------------------------+
- |null |nil |
- +------------------------+-------------------------------------------------+
- |map |Map |
- +------------------------+-------------------------------------------------+
- |list |List |
- +------------------------+-------------------------------------------------+
- |described type |Described |
- +--------------------------------------------------------------------------+
-
- The following Go types cannot be unmarshaled: uintptr, function, interface, channel, array (use slice), struct
-
- TODO: Not yet implemented:
-
- AMQP types: decimal32/64/128, char (round trip), timestamp, uuid.
-
- AMQP maps with mixed key types, or key types that are not legal Go map keys.
++
++Unmarshal decodes AMQP-encoded bytes and stores the result in the Go value
++pointed to by v. Legal conversions from the source AMQP type to the target Go
++type as follows:
++
++ +----------------------------+-------------------------------------------------+
++ |Target Go type | Allowed AMQP types
++ +============================+==================================================+
++ |bool |bool |
++ +----------------------------+--------------------------------------------------+
++ |int, int8, int16, int32, |Equivalent or smaller signed integer type: |
++ |int64 |byte, short, int, long or char |
++ +----------------------------+--------------------------------------------------+
++ |uint, uint8, uint16, uint32,|Equivalent or smaller unsigned integer type: |
++ |uint64 |ubyte, ushort, uint, ulong |
++ +----------------------------+--------------------------------------------------+
++ |float32, float64 |Equivalent or smaller float or double |
++ +----------------------------+--------------------------------------------------+
++ |string, []byte |string, symbol or binary |
++ +----------------------------+--------------------------------------------------+
++ |Symbol |symbol |
++ +----------------------------+--------------------------------------------------+
++ |Char |char |
++ +----------------------------+--------------------------------------------------+
++ |Described |AMQP described type [1] |
++ +----------------------------+--------------------------------------------------+
++ |Time |timestamp |
++ +----------------------------+--------------------------------------------------+
++ |UUID |uuid |
++ +----------------------------+--------------------------------------------------+
++ |map[interface{}]interface{} |Any AMQP map |
++ +----------------------------+--------------------------------------------------+
++ |map[K]T |map, provided all keys and values can unmarshal |
++ | |to types K,T |
++ +----------------------------+--------------------------------------------------+
++ |[]interface{} |AMQP list or array |
++ +----------------------------+--------------------------------------------------+
++ |[]T |list or array if elements can unmarshal as T |
++ +----------------------------+------------------n-------------------------------+
++ |interface{} |any AMQP type[2] |
++ +----------------------------+--------------------------------------------------+
++
++[1] An AMQP described value can also unmarshal to a plain value, discarding the
++descriptor. Unmarshalling into the special amqp.Described type preserves the
++descriptor.
++
++[2] Any AMQP value can be unmarshalled to an interface{}. The Go type is
++determined by the AMQP type as follows:
++
++ +----------------------------+--------------------------------------------------+
++ |Source AMQP Type |Go Type in target interface{} |
++ +============================+==================================================+
++ |bool |bool |
++ +----------------------------+--------------------------------------------------+
++ |byte,short,int,long |int8,int16,int32,int64 |
++ +----------------------------+--------------------------------------------------+
++ |ubyte,ushort,uint,ulong |uint8,uint16,uint32,uint64 |
++ +----------------------------+--------------------------------------------------+
++ |float, double |float32, float64 |
++ +----------------------------+--------------------------------------------------+
++ |string |string |
++ +----------------------------+--------------------------------------------------+
++ |symbol |Symbol |
++ +----------------------------+--------------------------------------------------+
++ |char |Char |
++ +----------------------------+--------------------------------------------------+
++ |binary |Binary |
++ +----------------------------+--------------------------------------------------+
++ |null |nil |
++ +----------------------------+--------------------------------------------------+
++ |described type |Described |
++ +----------------------------+--------------------------------------------------+
++ |timestamp |time.Time |
++ +----------------------------+--------------------------------------------------+
++ |uuid |UUID |
++ +----------------------------+--------------------------------------------------+
++ |map |Map or AnyMap[4] |
++ +----------------------------+--------------------------------------------------+
++ |list |List |
++ +----------------------------+--------------------------------------------------+
++ |array |[]T for simple types, T is chosen as above [3] |
++ +----------------------------+--------------------------------------------------+
++
++[3] An AMQP array of simple types unmarshalls as a slice of the corresponding Go type.
++An AMQP array containing complex types (lists, maps or nested arrays) unmarshals
++to the generic array type amqp.Array
++
++[4] An AMQP map unmarshals as the generic `type Map map[interface{}]interface{}`
++unless it contains key values that are illegal as Go map types, in which case
++it unmarshals as type AnyMap.
++
++The following Go types cannot be unmarshaled: uintptr, function, interface,
++channel, array (use slice), struct
++
++AMQP types not yet supported:
++- decimal32/64/128
++- maps with key values that are not legal Go map keys.
+*/
+func Unmarshal(bytes []byte, v interface{}) (n int, err error) {
- defer recoverUnmarshal(&err)
-
+ data := C.pn_data(0)
+ defer C.pn_data_free(data)
+ n, err = decode(data, bytes)
- if err != nil {
- return 0, err
- }
- if n == 0 {
- return 0, fmt.Errorf("not enough data")
- } else {
- unmarshal(v, data)
++ if err == nil {
++ err = recoverUnmarshal(v, data)
+ }
- return n, nil
++ return
+}
+
+// Internal
- func UnmarshalUnsafe(pn_data unsafe.Pointer, v interface{}) (err error) {
- defer recoverUnmarshal(&err)
- unmarshal(v, (*C.pn_data_t)(pn_data))
- return
++func UnmarshalUnsafe(pnData unsafe.Pointer, v interface{}) (err error) {
++ return recoverUnmarshal(v, (*C.pn_data_t)(pnData))
+}
+
+// more reads more data when we can't parse a complete AMQP type
+func (d *Decoder) more() error {
+ var readSize int64 = minDecode
+ if int64(d.buffer.Len()) > readSize { // Grow by doubling
+ readSize = int64(d.buffer.Len())
+ }
+ var n int64
+ n, err := d.buffer.ReadFrom(io.LimitReader(d.reader, readSize))
+ if n == 0 && err == nil { // ReadFrom won't report io.EOF, just returns 0
+ err = io.EOF
+ }
+ return err
+}
+
- // Unmarshal from data into value pointed at by v.
++// Call unmarshal(), convert panic to error value
++func recoverUnmarshal(v interface{}, data *C.pn_data_t) (err error) {
++ defer func() {
++ if r := recover(); r != nil {
++ if uerr, ok := r.(*UnmarshalError); ok {
++ err = uerr
++ } else {
++ panic(r)
++ }
++ }
++ }()
++ unmarshal(v, data)
++ return nil
++}
++
++// Unmarshal from data into value pointed at by v. Returns v.
++// NOTE: If you update this you also need to update getInterface()
+func unmarshal(v interface{}, data *C.pn_data_t) {
- pnType := C.pn_data_type(data)
++ rt := reflect.TypeOf(v)
++ rv := reflect.ValueOf(v)
++ panicUnless(v != nil && rt.Kind() == reflect.Ptr && !rv.IsNil(), data, v)
+
+ // Check for PN_DESCRIBED first, as described types can unmarshal into any of the Go types.
- // Interfaces are handled in the switch below, even for described types.
++ // An interface{} target is handled in the switch below, even for described types.
+ if _, isInterface := v.(*interface{}); !isInterface && bool(C.pn_data_is_described(data)) {
+ getDescribed(data, v)
+ return
+ }
+
+ // Unmarshal based on the target type
++ pnType := C.pn_data_type(data)
+ switch v := v.(type) {
++
+ case *bool:
- switch pnType {
- case C.PN_BOOL:
- *v = bool(C.pn_data_get_bool(data))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_BOOL, data, v)
++ *v = bool(C.pn_data_get_bool(data))
++
+ case *int8:
- switch pnType {
- case C.PN_CHAR:
- *v = int8(C.pn_data_get_char(data))
- case C.PN_BYTE:
- *v = int8(C.pn_data_get_byte(data))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_BYTE, data, v)
++ *v = int8(C.pn_data_get_byte(data))
++
+ case *uint8:
- switch pnType {
- case C.PN_CHAR:
- *v = uint8(C.pn_data_get_char(data))
- case C.PN_UBYTE:
- *v = uint8(C.pn_data_get_ubyte(data))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_UBYTE, data, v)
++ *v = uint8(C.pn_data_get_ubyte(data))
++
+ case *int16:
- switch pnType {
- case C.PN_CHAR:
- *v = int16(C.pn_data_get_char(data))
++ switch C.pn_data_type(data) {
+ case C.PN_BYTE:
+ *v = int16(C.pn_data_get_byte(data))
+ case C.PN_SHORT:
+ *v = int16(C.pn_data_get_short(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
++
+ case *uint16:
+ switch pnType {
- case C.PN_CHAR:
- *v = uint16(C.pn_data_get_char(data))
+ case C.PN_UBYTE:
+ *v = uint16(C.pn_data_get_ubyte(data))
+ case C.PN_USHORT:
+ *v = uint16(C.pn_data_get_ushort(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
++
+ case *int32:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = int32(C.pn_data_get_char(data))
+ case C.PN_BYTE:
+ *v = int32(C.pn_data_get_byte(data))
+ case C.PN_SHORT:
+ *v = int32(C.pn_data_get_short(data))
+ case C.PN_INT:
+ *v = int32(C.pn_data_get_int(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
++
+ case *uint32:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = uint32(C.pn_data_get_char(data))
+ case C.PN_UBYTE:
+ *v = uint32(C.pn_data_get_ubyte(data))
+ case C.PN_USHORT:
+ *v = uint32(C.pn_data_get_ushort(data))
+ case C.PN_UINT:
+ *v = uint32(C.pn_data_get_uint(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *int64:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = int64(C.pn_data_get_char(data))
+ case C.PN_BYTE:
+ *v = int64(C.pn_data_get_byte(data))
+ case C.PN_SHORT:
+ *v = int64(C.pn_data_get_short(data))
+ case C.PN_INT:
+ *v = int64(C.pn_data_get_int(data))
+ case C.PN_LONG:
+ *v = int64(C.pn_data_get_long(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *uint64:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = uint64(C.pn_data_get_char(data))
+ case C.PN_UBYTE:
+ *v = uint64(C.pn_data_get_ubyte(data))
+ case C.PN_USHORT:
+ *v = uint64(C.pn_data_get_ushort(data))
+ case C.PN_ULONG:
+ *v = uint64(C.pn_data_get_ulong(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *int:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = int(C.pn_data_get_char(data))
+ case C.PN_BYTE:
+ *v = int(C.pn_data_get_byte(data))
+ case C.PN_SHORT:
+ *v = int(C.pn_data_get_short(data))
+ case C.PN_INT:
+ *v = int(C.pn_data_get_int(data))
+ case C.PN_LONG:
- if unsafe.Sizeof(int(0)) == 8 {
++ if intIs64 {
+ *v = int(C.pn_data_get_long(data))
+ } else {
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *uint:
+ switch pnType {
+ case C.PN_CHAR:
+ *v = uint(C.pn_data_get_char(data))
+ case C.PN_UBYTE:
+ *v = uint(C.pn_data_get_ubyte(data))
+ case C.PN_USHORT:
+ *v = uint(C.pn_data_get_ushort(data))
+ case C.PN_UINT:
+ *v = uint(C.pn_data_get_uint(data))
+ case C.PN_ULONG:
- if unsafe.Sizeof(int(0)) == 8 {
++ if intIs64 {
+ *v = uint(C.pn_data_get_ulong(data))
+ } else {
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *float32:
- switch pnType {
- case C.PN_FLOAT:
- *v = float32(C.pn_data_get_float(data))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_FLOAT, data, v)
++ *v = float32(C.pn_data_get_float(data))
+
+ case *float64:
+ switch pnType {
+ case C.PN_FLOAT:
+ *v = float64(C.pn_data_get_float(data))
+ case C.PN_DOUBLE:
+ *v = float64(C.pn_data_get_double(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *string:
+ switch pnType {
+ case C.PN_STRING:
+ *v = goString(C.pn_data_get_string(data))
+ case C.PN_SYMBOL:
+ *v = goString(C.pn_data_get_symbol(data))
+ case C.PN_BINARY:
+ *v = goString(C.pn_data_get_binary(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+
+ case *[]byte:
+ switch pnType {
+ case C.PN_STRING:
+ *v = goBytes(C.pn_data_get_string(data))
+ case C.PN_SYMBOL:
+ *v = goBytes(C.pn_data_get_symbol(data))
+ case C.PN_BINARY:
+ *v = goBytes(C.pn_data_get_binary(data))
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
++ return
++
++ case *Char:
++ panicUnless(pnType == C.PN_CHAR, data, v)
++ *v = Char(C.pn_data_get_char(data))
+
+ case *Binary:
- switch pnType {
- case C.PN_BINARY:
- *v = Binary(goBytes(C.pn_data_get_binary(data)))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_BINARY, data, v)
++ *v = Binary(goBytes(C.pn_data_get_binary(data)))
+
+ case *Symbol:
- switch pnType {
- case C.PN_SYMBOL:
- *v = Symbol(goBytes(C.pn_data_get_symbol(data)))
- default:
- panic(newUnmarshalError(pnType, v))
- }
++ panicUnless(pnType == C.PN_SYMBOL, data, v)
++ *v = Symbol(goBytes(C.pn_data_get_symbol(data)))
+
- case *interface{}:
- getInterface(data, v)
++ case *time.Time:
++ panicUnless(pnType == C.PN_TIMESTAMP, data, v)
++ *v = time.Unix(0, int64(C.pn_data_get_timestamp(data))*1000)
++
++ case *UUID:
++ panicUnless(pnType == C.PN_UUID, data, v)
++ pn := C.pn_data_get_uuid(data)
++ copy((*v)[:], C.GoBytes(unsafe.Pointer(&pn.bytes), 16))
+
+ case *AnnotationKey:
- if pnType == C.PN_ULONG || pnType == C.PN_SYMBOL || pnType == C.PN_STRING {
- unmarshal(&v.value, data)
- } else {
- panic(newUnmarshalError(pnType, v))
++ panicUnless(pnType == C.PN_ULONG || pnType == C.PN_SYMBOL || pnType == C.PN_STRING, data, v)
++ unmarshal(&v.value, data)
++
++ case *AnyMap:
++ panicUnless(C.pn_data_type(data) == C.PN_MAP, data, v)
++ n := int(C.pn_data_get_map(data)) / 2
++ if cap(*v) < n {
++ *v = make(AnyMap, n)
++ }
++ *v = (*v)[:n]
++ data.enter(*v)
++ defer data.exit(*v)
++ for i := 0; i < n; i++ {
++ data.next(*v)
++ unmarshal(&(*v)[i].Key, data)
++ data.next(*v)
++ unmarshal(&(*v)[i].Value, data)
+ }
+
++ case *interface{}:
++ getInterface(data, v)
++
+ default: // This is not one of the fixed well-known types, reflect for map and slice types
- if reflect.TypeOf(v).Kind() != reflect.Ptr {
- panic(newUnmarshalError(pnType, v))
- }
- switch reflect.TypeOf(v).Elem().Kind() {
++
++ switch rt.Elem().Kind() {
+ case reflect.Map:
+ getMap(data, v)
+ case reflect.Slice:
- getList(data, v)
++ getSequence(data, v)
+ default:
- panic(newUnmarshalError(pnType, v))
++ doPanic(data, v)
+ }
+ }
- if err := newUnmarshalErrorData(data, v); err != nil {
- panic(err)
- }
- return
- }
-
- func rewindUnmarshal(v interface{}, data *C.pn_data_t) {
- C.pn_data_rewind(data)
- C.pn_data_next(data)
- unmarshal(v, data)
+}
+
- // Getting into an interface is driven completely by the AMQP type, since the interface{}
- // target is type-neutral.
- func getInterface(data *C.pn_data_t, v *interface{}) {
++// Unmarshalling into an interface{} the type is determined by the AMQP source type,
++// since the interface{} target can hold any Go type.
++func getInterface(data *C.pn_data_t, vp *interface{}) {
+ pnType := C.pn_data_type(data)
+ switch pnType {
+ case C.PN_BOOL:
- *v = bool(C.pn_data_get_bool(data))
++ *vp = bool(C.pn_data_get_bool(data))
+ case C.PN_UBYTE:
- *v = uint8(C.pn_data_get_ubyte(data))
++ *vp = uint8(C.pn_data_get_ubyte(data))
+ case C.PN_BYTE:
- *v = int8(C.pn_data_get_byte(data))
++ *vp = int8(C.pn_data_get_byte(data))
+ case C.PN_USHORT:
- *v = uint16(C.pn_data_get_ushort(data))
++ *vp = uint16(C.pn_data_get_ushort(data))
+ case C.PN_SHORT:
- *v = int16(C.pn_data_get_short(data))
++ *vp = int16(C.pn_data_get_short(data))
+ case C.PN_UINT:
- *v = uint32(C.pn_data_get_uint(data))
++ *vp = uint32(C.pn_data_get_uint(data))
+ case C.PN_INT:
- *v = int32(C.pn_data_get_int(data))
++ *vp = int32(C.pn_data_get_int(data))
+ case C.PN_CHAR:
- *v = uint8(C.pn_data_get_char(data))
++ *vp = Char(C.pn_data_get_char(data))
+ case C.PN_ULONG:
- *v = uint64(C.pn_data_get_ulong(data))
++ *vp = uint64(C.pn_data_get_ulong(data))
+ case C.PN_LONG:
- *v = int64(C.pn_data_get_long(data))
++ *vp = int64(C.pn_data_get_long(data))
+ case C.PN_FLOAT:
- *v = float32(C.pn_data_get_float(data))
++ *vp = float32(C.pn_data_get_float(data))
+ case C.PN_DOUBLE:
- *v = float64(C.pn_data_get_double(data))
++ *vp = float64(C.pn_data_get_double(data))
+ case C.PN_BINARY:
- *v = Binary(goBytes(C.pn_data_get_binary(data)))
++ *vp = Binary(goBytes(C.pn_data_get_binary(data)))
+ case C.PN_STRING:
- *v = goString(C.pn_data_get_string(data))
++ *vp = goString(C.pn_data_get_string(data))
+ case C.PN_SYMBOL:
- *v = Symbol(goString(C.pn_data_get_symbol(data)))
++ *vp = Symbol(goString(C.pn_data_get_symbol(data)))
++ case C.PN_TIMESTAMP:
++ *vp = time.Unix(0, int64(C.pn_data_get_timestamp(data))*1000)
++ case C.PN_UUID:
++ var u UUID
++ unmarshal(&u, data)
++ *vp = u
+ case C.PN_MAP:
- m := make(Map)
- unmarshal(&m, data)
- *v = m
++ // We will try to unmarshal as a Map first, if that fails try AnyMap
++ m := make(Map, int(C.pn_data_get_map(data))/2)
++ if err := recoverUnmarshal(&m, data); err == nil {
++ *vp = m
++ } else {
++ am := make(AnyMap, int(C.pn_data_get_map(data))/2)
++ unmarshal(&am, data)
++ *vp = am
++ }
+ case C.PN_LIST:
- l := make(List, 0)
++ l := List{}
+ unmarshal(&l, data)
- *v = l
++ *vp = l
++ case C.PN_ARRAY:
++ sp := getArrayStore(data) // interface{} containing T* for suitable T
++ unmarshal(sp, data)
++ *vp = reflect.ValueOf(sp).Elem().Interface()
+ case C.PN_DESCRIBED:
+ d := Described{}
+ unmarshal(&d, data)
- *v = d
++ *vp = d
+ case C.PN_NULL:
- *v = nil
++ *vp = nil
+ case C.PN_INVALID:
+ // Allow decoding from an empty data object to an interface, treat it like NULL.
+ // This happens when optional values or properties are omitted from a message.
- *v = nil
++ *vp = nil
+ default: // Don't know how to handle this
- panic(newUnmarshalError(pnType, v))
++ panic(newUnmarshalError(pnType, vp))
+ }
+}
+
++// Return an interface{} containing a pointer to an appropriate slice or Array
++func getArrayStore(data *C.pn_data_t) interface{} {
++ // TODO aconway 2017-11-10: described arrays.
++ switch C.pn_data_get_array_type(data) {
++ case C.PN_BOOL:
++ return new([]bool)
++ case C.PN_UBYTE:
++ return new([]uint8)
++ case C.PN_BYTE:
++ return new([]int8)
++ case C.PN_USHORT:
++ return new([]uint16)
++ case C.PN_SHORT:
++ return new([]int16)
++ case C.PN_UINT:
++ return new([]uint32)
++ case C.PN_INT:
++ return new([]int32)
++ case C.PN_CHAR:
++ return new([]Char)
++ case C.PN_ULONG:
++ return new([]uint64)
++ case C.PN_LONG:
++ return new([]int64)
++ case C.PN_FLOAT:
++ return new([]float32)
++ case C.PN_DOUBLE:
++ return new([]float64)
++ case C.PN_BINARY:
++ return new([]Binary)
++ case C.PN_STRING:
++ return new([]string)
++ case C.PN_SYMBOL:
++ return new([]Symbol)
++ case C.PN_TIMESTAMP:
++ return new([]time.Time)
++ case C.PN_UUID:
++ return new([]UUID)
++ }
++ return new(Array) // Not a simple type, use generic Array
++}
++
++var typeOfInterface = reflect.TypeOf(interface{}(nil))
++
+// get into map pointed at by v
+func getMap(data *C.pn_data_t, v interface{}) {
++ panicUnless(C.pn_data_type(data) == C.PN_MAP, data, v)
++ n := int(C.pn_data_get_map(data)) / 2
+ mapValue := reflect.ValueOf(v).Elem()
+ mapValue.Set(reflect.MakeMap(mapValue.Type())) // Clear the map
- switch pnType := C.pn_data_type(data); pnType {
- case C.PN_MAP:
- count := int(C.pn_data_get_map(data))
- if bool(C.pn_data_enter(data)) {
- defer C.pn_data_exit(data)
- for i := 0; i < count/2; i++ {
- if bool(C.pn_data_next(data)) {
- key := reflect.New(mapValue.Type().Key())
- unmarshal(key.Interface(), data)
- if bool(C.pn_data_next(data)) {
- val := reflect.New(mapValue.Type().Elem())
- unmarshal(val.Interface(), data)
- mapValue.SetMapIndex(key.Elem(), val.Elem())
- }
- }
- }
++ data.enter(v)
++ defer data.exit(v)
++ // Allocate re-usable key/val values
++ keyType := mapValue.Type().Key()
++ keyPtr := reflect.New(keyType)
++ valPtr := reflect.New(mapValue.Type().Elem())
++ for i := 0; i < n; i++ {
++ data.next(v)
++ unmarshal(keyPtr.Interface(), data)
++ if keyType.Kind() == reflect.Interface && !keyPtr.Elem().Elem().Type().Comparable() {
++ doPanicMsg(data, v, fmt.Sprintf("key %#v is not comparable", keyPtr.Elem().Interface()))
+ }
- default: // Empty/error/unknown, leave map empty
++ data.next(v)
++ unmarshal(valPtr.Interface(), data)
++ mapValue.SetMapIndex(keyPtr.Elem(), valPtr.Elem())
+ }
+}
+
- func getList(data *C.pn_data_t, v interface{}) {
++func getSequence(data *C.pn_data_t, vp interface{}) {
++ var count int
+ pnType := C.pn_data_type(data)
- if pnType != C.PN_LIST {
- panic(newUnmarshalError(pnType, v))
++ switch pnType {
++ case C.PN_LIST:
++ count = int(C.pn_data_get_list(data))
++ case C.PN_ARRAY:
++ count = int(C.pn_data_get_array(data))
++ default:
++ doPanic(data, vp)
+ }
- count := int(C.pn_data_get_list(data))
- listValue := reflect.MakeSlice(reflect.TypeOf(v).Elem(), count, count)
- if bool(C.pn_data_enter(data)) {
- for i := 0; i < count; i++ {
- if bool(C.pn_data_next(data)) {
- val := reflect.New(listValue.Type().Elem())
- unmarshal(val.Interface(), data)
- listValue.Index(i).Set(val.Elem())
- }
- }
- C.pn_data_exit(data)
++ listValue := reflect.MakeSlice(reflect.TypeOf(vp).Elem(), count, count)
++ data.enter(vp)
++ defer data.exit(vp)
++ for i := 0; i < count; i++ {
++ data.next(vp)
++ val := reflect.New(listValue.Type().Elem())
++ unmarshal(val.Interface(), data)
++ listValue.Index(i).Set(val.Elem())
+ }
- reflect.ValueOf(v).Elem().Set(listValue)
++ reflect.ValueOf(vp).Elem().Set(listValue)
+}
+
- func getDescribed(data *C.pn_data_t, v interface{}) {
- d, _ := v.(*Described)
- pnType := C.pn_data_type(data)
- if bool(C.pn_data_enter(data)) {
- defer C.pn_data_exit(data)
- if bool(C.pn_data_next(data)) {
- if d != nil {
- unmarshal(&d.Descriptor, data)
- }
- if bool(C.pn_data_next(data)) {
- if d != nil {
- unmarshal(&d.Value, data)
- } else {
- unmarshal(v, data)
- }
- return
- }
- }
++func getDescribed(data *C.pn_data_t, vp interface{}) {
++ d, isDescribed := vp.(*Described)
++ data.enter(vp)
++ defer data.exit(vp)
++ data.next(vp)
++ if isDescribed {
++ unmarshal(&d.Descriptor, data)
++ data.next(vp)
++ unmarshal(&d.Value, data)
++ } else {
++ data.next(vp) // Skip descriptor
++ unmarshal(vp, data) // Unmarshal plain value
+ }
- // The pn_data cursor didn't move as expected
- panic(newUnmarshalErrorMsg(pnType, v, "bad described value encoding"))
+}
+
+// decode from bytes.
+// Return bytes decoded or 0 if we could not decode a complete object.
+//
+func decode(data *C.pn_data_t, bytes []byte) (int, error) {
- if len(bytes) == 0 {
- return 0, nil
- }
- n := int(C.pn_data_decode(data, cPtr(bytes), cLen(bytes)))
- if n == int(C.PN_UNDERFLOW) {
++ n := C.pn_data_decode(data, cPtr(bytes), cLen(bytes))
++ if n == C.PN_UNDERFLOW {
+ C.pn_error_clear(C.pn_data_error(data))
- return 0, nil
++ return 0, EndOfData
+ } else if n <= 0 {
- return 0, fmt.Errorf("unmarshal %s", PnErrorCode(n))
++ return 0, &UnmarshalError{s: fmt.Sprintf("unmarshal %v", PnErrorCode(n))}
+ }
- return n, nil
++ return int(n), nil
+}
++
++// Checked versions of pn_data functions
++
++func (data *C.pn_data_t) enter(v interface{}) { checkOp(bool(C.pn_data_enter(data)), v) }
++func (data *C.pn_data_t) exit(v interface{}) { checkOp(bool(C.pn_data_exit(data)), v) }
++func (data *C.pn_data_t) next(v interface{}) { checkOp(bool(C.pn_data_next(data)), v) }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/url_test.go
----------------------------------------------------------------------
diff --cc amqp/url_test.go
index f52d4bf,0000000..192e2fb
mode 100644,000000..100644
--- a/amqp/url_test.go
+++ b/amqp/url_test.go
@@@ -1,59 -1,0 +1,59 @@@
+/*
+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.
+*/
+
+package amqp
+
+import (
+ "fmt"
+)
+
+func ExampleParseURL() {
+ for _, s := range []string{
+ "amqp://username:password@host:1234/path",
+ "host:1234",
+ "host",
+ "host/path",
+ "amqps://host",
+ "/path",
+ "",
+ ":1234",
- // Taken out becasue the go 1.4 URL parser isn't the same as later
++ // Taken out because the go 1.4 URL parser isn't the same as later
+ //"[::1]",
+ //"[::1",
+ // Output would be:
+ // amqp://[::1]:amqp
+ // parse amqp://[::1: missing ']' in host
+ } {
+ u, err := ParseURL(s)
+ if err != nil {
+ fmt.Println(err)
+ } else {
+ fmt.Println(u)
+ }
+ }
+ // Output:
+ // amqp://username:password@host:1234/path
+ // amqp://host:1234
+ // amqp://host:amqp
+ // amqp://host:amqp/path
+ // amqps://host:amqps
+ // amqp://localhost:amqp/path
+ // amqp://localhost:amqp
+ // parse :1234: missing protocol scheme
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/electron/auth_test.go
----------------------------------------------------------------------
diff --cc electron/auth_test.go
index 9eb48c0,0000000..9fa9fa2
mode 100644,000000..100644
--- a/electron/auth_test.go
+++ b/electron/auth_test.go
@@@ -1,133 -1,0 +1,137 @@@
+/*
+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.
+*/
+
+package electron
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func testAuthClientServer(t *testing.T, copts []ConnectionOption, sopts []ConnectionOption) (got connectionSettings, err error) {
+ client, server := newClientServerOpts(t, copts, sopts)
+ defer closeClientServer(client, server)
+
+ go func() {
+ for in := range server.Incoming() {
+ switch in := in.(type) {
+ case *IncomingConnection:
+ got = connectionSettings{user: in.User(), virtualHost: in.VirtualHost()}
+ }
+ in.Accept()
+ }
+ }()
+
+ err = client.Sync()
+ return
+}
+
+func TestAuthAnonymous(t *testing.T) {
- fatalIf(t, configureSASL())
++ configureSASL()
+ got, err := testAuthClientServer(t,
+ []ConnectionOption{User("fred"), VirtualHost("vhost"), SASLAllowInsecure(true)},
+ []ConnectionOption{SASLAllowedMechs("ANONYMOUS"), SASLAllowInsecure(true)})
+ fatalIf(t, err)
+ errorIf(t, checkEqual(connectionSettings{user: "anonymous", virtualHost: "vhost"}, got))
+}
+
+func TestAuthPlain(t *testing.T) {
+ if !SASLExtended() {
+ t.Skip()
+ }
+ fatalIf(t, configureSASL())
+ got, err := testAuthClientServer(t,
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN"), User("fred@proton"), Password([]byte("xxx"))},
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN")})
+ fatalIf(t, err)
+ errorIf(t, checkEqual(connectionSettings{user: "fred@proton"}, got))
+}
+
+func TestAuthBadPass(t *testing.T) {
+ if !SASLExtended() {
+ t.Skip()
+ }
+ fatalIf(t, configureSASL())
+ _, err := testAuthClientServer(t,
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN"), User("fred@proton"), Password([]byte("yyy"))},
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN")})
+ if err == nil {
+ t.Error("Expected auth failure for bad pass")
+ }
+}
+
+func TestAuthBadUser(t *testing.T) {
+ if !SASLExtended() {
+ t.Skip()
+ }
+ fatalIf(t, configureSASL())
+ _, err := testAuthClientServer(t,
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN"), User("foo@bar"), Password([]byte("yyy"))},
+ []ConnectionOption{SASLAllowInsecure(true), SASLAllowedMechs("PLAIN")})
+ if err == nil {
+ t.Error("Expected auth failure for bad user")
+ }
+}
+
+var confDir string
+var confErr error
+
+func configureSASL() error {
+ if confDir != "" || confErr != nil {
+ return confErr
+ }
+ confDir, confErr = ioutil.TempDir("", "")
+ if confErr != nil {
+ return confErr
+ }
+
+ GlobalSASLConfigDir(confDir)
+ GlobalSASLConfigName("test")
+ conf := filepath.Join(confDir, "test.conf")
+
+ db := filepath.Join(confDir, "proton.sasldb")
- cmd := exec.Command("saslpasswd2", "-c", "-p", "-f", db, "-u", "proton", "fred")
++ saslpasswd := os.Getenv("SASLPASSWD");
++ if saslpasswd == "" {
++ saslpasswd = "saslpasswd2"
++ }
++ cmd := exec.Command(saslpasswd, "-c", "-p", "-f", db, "-u", "proton", "fred")
+ cmd.Stdin = strings.NewReader("xxx") // Password
+ if out, err := cmd.CombinedOutput(); err != nil {
+ confErr = fmt.Errorf("saslpasswd2 failed: %s\n%s", err, out)
+ return confErr
+ }
+ confStr := "sasldb_path: " + db + "\nmech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS\n"
+ if err := ioutil.WriteFile(conf, []byte(confStr), os.ModePerm); err != nil {
+ confErr = fmt.Errorf("write conf file %s failed: %s", conf, err)
+ }
+ return confErr
+}
+
+func TestMain(m *testing.M) {
+ status := m.Run()
+ if confDir != "" {
+ _ = os.RemoveAll(confDir)
+ }
+ os.Exit(status)
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/electron/connection.go
----------------------------------------------------------------------
diff --cc electron/connection.go
index 2749b2b,0000000..731e64d
mode 100644,000000..100644
--- a/electron/connection.go
+++ b/electron/connection.go
@@@ -1,421 -1,0 +1,421 @@@
+/*
+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.
+*/
+
+package electron
+
+// #include <proton/disposition.h>
+import "C"
+
+import (
+ "net"
+ "qpid.apache.org/proton"
+ "sync"
+ "time"
+)
+
+// Settings associated with a Connection.
+type ConnectionSettings interface {
+ // Authenticated user name associated with the connection.
+ User() string
+
+ // The AMQP virtual host name for the connection.
+ //
+ // Optional, useful when the server has multiple names and provides different
+ // service based on the name the client uses to connect.
+ //
+ // By default it is set to the DNS host name that the client uses to connect,
+ // but it can be set to something different at the client side with the
+ // VirtualHost() option.
+ //
+ // Returns error if the connection fails to authenticate.
+ VirtualHost() string
+
+ // Heartbeat is the maximum delay between sending frames that the remote peer
+ // has requested of us. If the interval expires an empty "heartbeat" frame
+ // will be sent automatically to keep the connection open.
+ Heartbeat() time.Duration
+}
+
+// Connection is an AMQP connection, created by a Container.
+type Connection interface {
+ Endpoint
+ ConnectionSettings
+
+ // Sender opens a new sender on the DefaultSession.
+ Sender(...LinkOption) (Sender, error)
+
+ // Receiver opens a new Receiver on the DefaultSession().
+ Receiver(...LinkOption) (Receiver, error)
+
+ // DefaultSession() returns a default session for the connection. It is opened
+ // on the first call to DefaultSession and returned on subsequent calls.
+ DefaultSession() (Session, error)
+
+ // Session opens a new session.
+ Session(...SessionOption) (Session, error)
+
+ // Container for the connection.
+ Container() Container
+
+ // Disconnect the connection abruptly with an error.
+ Disconnect(error)
+
+ // Wait waits for the connection to be disconnected.
+ Wait() error
+
+ // WaitTimeout is like Wait but returns Timeout if the timeout expires.
+ WaitTimeout(time.Duration) error
+
+ // Incoming returns a channel for incoming endpoints opened by the remote peer.
+ // See the Incoming interface for more detail.
+ //
+ // Note: this channel will first return an *IncomingConnection for the
+ // connection itself which allows you to look at security information and
+ // decide whether to Accept() or Reject() the connection. Then it will return
+ // *IncomingSession, *IncomingSender and *IncomingReceiver as they are opened
+ // by the remote end.
+ //
+ // Note 2: you must receiving from Incoming() and call Accept/Reject to avoid
+ // blocking electron event loop. Normally you would run a loop in a goroutine
+ // to handle incoming types that interest and Accept() those that don't.
+ Incoming() <-chan Incoming
+}
+
+type connectionSettings struct {
+ user, virtualHost string
+ heartbeat time.Duration
+}
+
+func (c connectionSettings) User() string { return c.user }
+func (c connectionSettings) VirtualHost() string { return c.virtualHost }
+func (c connectionSettings) Heartbeat() time.Duration { return c.heartbeat }
+
+// ConnectionOption can be passed when creating a connection to configure various options
+type ConnectionOption func(*connection)
+
+// User returns a ConnectionOption sets the user name for a connection
+func User(user string) ConnectionOption {
+ return func(c *connection) {
+ c.user = user
+ c.pConnection.SetUser(user)
+ }
+}
+
+// VirtualHost returns a ConnectionOption to set the AMQP virtual host for the connection.
+// Only applies to outbound client connection.
+func VirtualHost(virtualHost string) ConnectionOption {
+ return func(c *connection) {
+ c.virtualHost = virtualHost
+ c.pConnection.SetHostname(virtualHost)
+ }
+}
+
+// Password returns a ConnectionOption to set the password used to establish a
+// connection. Only applies to outbound client connection.
+//
+// The connection will erase its copy of the password from memory as soon as it
- // has been used to authenticate. If you are concerned about paswords staying in
++// has been used to authenticate. If you are concerned about passwords staying in
+// memory you should never store them as strings, and should overwrite your
+// copy as soon as you are done with it.
+//
+func Password(password []byte) ConnectionOption {
+ return func(c *connection) { c.pConnection.SetPassword(password) }
+}
+
+// Server returns a ConnectionOption to put the connection in server mode for incoming connections.
+//
+// A server connection will do protocol negotiation to accept a incoming AMQP
+// connection. Normally you would call this for a connection created by
+// net.Listener.Accept()
+//
+func Server() ConnectionOption {
+ return func(c *connection) { c.engine.Server(); c.server = true; AllowIncoming()(c) }
+}
+
+// AllowIncoming returns a ConnectionOption to enable incoming endpoints, see
+// Connection.Incoming() This is automatically set for Server() connections.
+func AllowIncoming() ConnectionOption {
+ return func(c *connection) { c.incoming = make(chan Incoming) }
+}
+
+// Parent returns a ConnectionOption that associates the Connection with it's Container
+// If not set a connection will create its own default container.
+func Parent(cont Container) ConnectionOption {
+ return func(c *connection) { c.container = cont.(*container) }
+}
+
+type connection struct {
+ endpoint
+ connectionSettings
+
+ defaultSessionOnce, closeOnce sync.Once
+
+ container *container
+ conn net.Conn
+ server bool
+ incoming chan Incoming
+ handler *handler
+ engine *proton.Engine
+ pConnection proton.Connection
+
+ defaultSession Session
+}
+
+// NewConnection creates a connection with the given options.
+func NewConnection(conn net.Conn, opts ...ConnectionOption) (*connection, error) {
+ c := &connection{
+ conn: conn,
+ }
+ c.handler = newHandler(c)
+ var err error
+ c.engine, err = proton.NewEngine(c.conn, c.handler.delegator)
+ if err != nil {
+ return nil, err
+ }
+ c.pConnection = c.engine.Connection()
+ for _, set := range opts {
+ set(c)
+ }
+ if c.container == nil {
+ c.container = NewContainer("").(*container)
+ }
+ c.pConnection.SetContainer(c.container.Id())
+ globalSASLInit(c.engine)
+
+ c.endpoint.init(c.engine.String())
+ go c.run()
+ return c, nil
+}
+
+func (c *connection) run() {
+ if !c.server {
+ c.pConnection.Open()
+ }
+ _ = c.engine.Run()
+ if c.incoming != nil {
+ close(c.incoming)
+ }
+ _ = c.closed(Closed)
+}
+
+func (c *connection) Close(err error) {
+ c.err.Set(err)
+ c.engine.Close(err)
+}
+
+func (c *connection) Disconnect(err error) {
+ c.err.Set(err)
+ c.engine.Disconnect(err)
+}
+
+func (c *connection) Session(opts ...SessionOption) (Session, error) {
+ var s Session
+ err := c.engine.InjectWait(func() error {
+ if c.Error() != nil {
+ return c.Error()
+ }
+ pSession, err := c.engine.Connection().Session()
+ if err == nil {
+ pSession.Open()
+ if err == nil {
+ s = newSession(c, pSession, opts...)
+ }
+ }
+ return err
+ })
+ return s, err
+}
+
+func (c *connection) Container() Container { return c.container }
+
+func (c *connection) DefaultSession() (s Session, err error) {
+ c.defaultSessionOnce.Do(func() {
+ c.defaultSession, err = c.Session()
+ })
+ if err == nil {
+ err = c.Error()
+ }
+ return c.defaultSession, err
+}
+
+func (c *connection) Sender(opts ...LinkOption) (Sender, error) {
+ if s, err := c.DefaultSession(); err == nil {
+ return s.Sender(opts...)
+ } else {
+ return nil, err
+ }
+}
+
+func (c *connection) Receiver(opts ...LinkOption) (Receiver, error) {
+ if s, err := c.DefaultSession(); err == nil {
+ return s.Receiver(opts...)
+ } else {
+ return nil, err
+ }
+}
+
+func (c *connection) Connection() Connection { return c }
+
+func (c *connection) Wait() error { return c.WaitTimeout(Forever) }
+func (c *connection) WaitTimeout(timeout time.Duration) error {
+ _, err := timedReceive(c.done, timeout)
+ if err == Timeout {
+ return Timeout
+ }
+ return c.Error()
+}
+
+func (c *connection) Incoming() <-chan Incoming {
+ assert(c.incoming != nil, "Incoming() is only allowed for a Connection created with the Server() option: %s", c)
+ return c.incoming
+}
+
+type IncomingConnection struct {
+ incoming
+ connectionSettings
+ c *connection
+}
+
+func newIncomingConnection(c *connection) *IncomingConnection {
+ c.user = c.pConnection.Transport().User()
+ c.virtualHost = c.pConnection.RemoteHostname()
+ return &IncomingConnection{
+ incoming: makeIncoming(c.pConnection),
+ connectionSettings: c.connectionSettings,
+ c: c}
+}
+
+// AcceptConnection is like Accept() but takes ConnectionOption s
+// For example you can set the Heartbeat() for the accepted connection.
+func (in *IncomingConnection) AcceptConnection(opts ...ConnectionOption) Connection {
+ return in.accept(func() Endpoint {
+ for _, opt := range opts {
+ opt(in.c)
+ }
+ in.c.pConnection.Open()
+ return in.c
+ }).(Connection)
+}
+
+func (in *IncomingConnection) Accept() Endpoint {
+ return in.AcceptConnection()
+}
+
+func sasl(c *connection) proton.SASL { return c.engine.Transport().SASL() }
+
+// SASLEnable returns a ConnectionOption that enables SASL authentication.
+// Only required if you don't set any other SASL options.
+func SASLEnable() ConnectionOption { return func(c *connection) { sasl(c) } }
+
+// SASLAllowedMechs returns a ConnectionOption to set the list of allowed SASL
+// mechanisms.
+//
+// Can be used on the client or the server to restrict the SASL for a connection.
+// mechs is a space-separated list of mechanism names.
+//
+func SASLAllowedMechs(mechs string) ConnectionOption {
+ return func(c *connection) { sasl(c).AllowedMechs(mechs) }
+}
+
+// SASLAllowInsecure returns a ConnectionOption that allows or disallows clear
+// text SASL authentication mechanisms
+//
+// By default the SASL layer is configured not to allow mechanisms that disclose
+// the clear text of the password over an unencrypted AMQP connection. This specifically
+// will disallow the use of the PLAIN mechanism without using SSL encryption.
+//
+// This default is to avoid disclosing password information accidentally over an
+// insecure network.
+//
+func SASLAllowInsecure(b bool) ConnectionOption {
+ return func(c *connection) { sasl(c).SetAllowInsecureMechs(b) }
+}
+
+// Heartbeat returns a ConnectionOption that requests the maximum delay
+// between sending frames for the remote peer. If we don't receive any frames
+// within 2*delay we will close the connection.
+//
+func Heartbeat(delay time.Duration) ConnectionOption {
+ // Proton-C divides the idle-timeout by 2 before sending, so compensate.
+ return func(c *connection) { c.engine.Transport().SetIdleTimeout(2 * delay) }
+}
+
+// GlobalSASLConfigDir sets the SASL configuration directory for every
+// Connection created in this process. If not called, the default is determined
+// by your SASL installation.
+//
+// You can set SASLAllowInsecure and SASLAllowedMechs on individual connections.
+//
+func GlobalSASLConfigDir(dir string) { globalSASLConfigDir = dir }
+
+// GlobalSASLConfigName sets the SASL configuration name for every Connection
+// created in this process. If not called the default is "proton-server".
+//
+// The complete configuration file name is
+// <sasl-config-dir>/<sasl-config-name>.conf
+//
+// You can set SASLAllowInsecure and SASLAllowedMechs on individual connections.
+//
+func GlobalSASLConfigName(dir string) { globalSASLConfigName = dir }
+
+// Do we support extended SASL negotiation?
+// All implementations of Proton support ANONYMOUS and EXTERNAL on both
+// client and server sides and PLAIN on the client side.
+//
+// Extended SASL implememtations use an external library (Cyrus SASL)
+// to support other mechanisms beyond these basic ones.
+func SASLExtended() bool { return proton.SASLExtended() }
+
+var (
+ globalSASLConfigName string
+ globalSASLConfigDir string
+)
+
+// TODO aconway 2016-09-15: Current pn_sasl C impl config is broken, so all we
+// can realistically offer is global configuration. Later if/when the pn_sasl C
+// impl is fixed we can offer per connection over-rides.
+func globalSASLInit(eng *proton.Engine) {
+ sasl := eng.Transport().SASL()
+ if globalSASLConfigName != "" {
+ sasl.ConfigName(globalSASLConfigName)
+ }
+ if globalSASLConfigDir != "" {
+ sasl.ConfigPath(globalSASLConfigDir)
+ }
+}
+
+// Dial is shorthand for using net.Dial() then NewConnection()
+// See net.Dial() for the meaning of the network, address arguments.
+func Dial(network, address string, opts ...ConnectionOption) (c Connection, err error) {
+ conn, err := net.Dial(network, address)
+ if err == nil {
+ c, err = NewConnection(conn, opts...)
+ }
+ return
+}
+
+// DialWithDialer is shorthand for using dialer.Dial() then NewConnection()
+// See net.Dial() for the meaning of the network, address arguments.
+func DialWithDialer(dialer *net.Dialer, network, address string, opts ...ConnectionOption) (c Connection, err error) {
+ conn, err := dialer.Dial(network, address)
+ if err == nil {
+ c, err = NewConnection(conn, opts...)
+ }
+ return
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/electron/electron_test.go
----------------------------------------------------------------------
diff --cc electron/electron_test.go
index 4cd8453,0000000..74759f5
mode 100644,000000..100644
--- a/electron/electron_test.go
+++ b/electron/electron_test.go
@@@ -1,546 -1,0 +1,546 @@@
+/*
+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.
+*/
+
+package electron
+
+import (
+ "fmt"
+ "net"
+ "path"
+ "qpid.apache.org/amqp"
+ "reflect"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func fatalIf(t *testing.T, err error) {
+ if err != nil {
+ _, file, line, ok := runtime.Caller(1) // annotate with location of caller.
+ if ok {
+ _, file = path.Split(file)
+ }
+ t.Fatalf("(from %s:%d) %v", file, line, err)
+ }
+}
+
+func errorIf(t *testing.T, err error) {
+ if err != nil {
+ _, file, line, ok := runtime.Caller(1) // annotate with location of caller.
+ if ok {
+ _, file = path.Split(file)
+ }
+ t.Errorf("(from %s:%d) %v", file, line, err)
+ }
+}
+
+func checkEqual(want interface{}, got interface{}) error {
+ if !reflect.DeepEqual(want, got) {
+ return fmt.Errorf("%#v != %#v", want, got)
+ }
+ return nil
+}
+
+// Start a server, return listening addr and channel for incoming Connections.
+func newServer(t *testing.T, cont Container, opts ...ConnectionOption) (net.Addr, <-chan Connection) {
+ listener, err := net.Listen("tcp4", "") // For systems with ipv6 disabled
+ fatalIf(t, err)
+ addr := listener.Addr()
+ ch := make(chan Connection)
+ go func() {
+ conn, err := listener.Accept()
+ c, err := cont.Connection(conn, append([]ConnectionOption{Server()}, opts...)...)
+ fatalIf(t, err)
+ ch <- c
+ }()
+ return addr, ch
+}
+
+// Open a client connection and session, return the session.
+func newClient(t *testing.T, cont Container, addr net.Addr, opts ...ConnectionOption) Session {
+ conn, err := net.Dial(addr.Network(), addr.String())
+ fatalIf(t, err)
- c, err := cont.Connection(conn, opts...)
- fatalIf(t, err)
- sn, err := c.Session()
- fatalIf(t, err)
++ // Don't bother checking error here, it's an async error so it's racy to do so anyway.
++ // Let caller use Sync() or catch it on first use.
++ c, _ := cont.Connection(conn, opts...)
++ sn, _ := c.Session()
+ return sn
+}
+
+// Return client and server ends of the same connection.
+func newClientServerOpts(t *testing.T, copts []ConnectionOption, sopts []ConnectionOption) (client Session, server Connection) {
+ addr, ch := newServer(t, NewContainer("test-server"), sopts...)
+ client = newClient(t, NewContainer("test-client"), addr, copts...)
+ return client, <-ch
+}
+
+// Return client and server ends of the same connection.
+func newClientServer(t *testing.T) (client Session, server Connection) {
+ return newClientServerOpts(t, nil, nil)
+}
+
+// Close client and server
+func closeClientServer(client Session, server Connection) {
+ client.Connection().Close(nil)
+ server.Close(nil)
+}
+
+// Send a message one way with a client sender and server receiver, verify ack.
+func TestClientSendServerReceive(t *testing.T) {
+ nLinks := 3
+ nMessages := 3
+
+ rchan := make(chan Receiver, nLinks)
+ client, server := newClientServer(t)
+ go func() {
+ for in := range server.Incoming() {
+ switch in := in.(type) {
+ case *IncomingReceiver:
+ in.SetCapacity(1)
+ in.SetPrefetch(false)
+ rchan <- in.Accept().(Receiver)
+ default:
+ in.Accept()
+ }
+ }
+ }()
+
+ defer func() { closeClientServer(client, server) }()
+
+ s := make([]Sender, nLinks)
+ for i := 0; i < nLinks; i++ {
+ var err error
+ s[i], err = client.Sender(Target(fmt.Sprintf("foo%d", i)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ r := make([]Receiver, nLinks)
+ for i := 0; i < nLinks; i++ {
+ r[i] = <-rchan
+ }
+
+ for i := 0; i < nLinks; i++ {
+ for j := 0; j < nMessages; j++ {
+ // Client send
+ ack := make(chan Outcome, 1)
+ sendDone := make(chan struct{})
+ go func() {
+ defer close(sendDone)
+ m := amqp.NewMessageWith(fmt.Sprintf("foobar%v-%v", i, j))
+ var err error
+ s[i].SendAsync(m, ack, "testing")
+ if err != nil {
+ t.Fatal(err)
+ }
+ }()
+
- // Server recieve
++ // Server receive
+ rm, err := r[i].Receive()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if want, got := interface{}(fmt.Sprintf("foobar%v-%v", i, j)), rm.Message.Body(); want != got {
+ t.Errorf("%#v != %#v", want, got)
+ }
+
+ // Should not be acknowledged on client yet
+ <-sendDone
+ select {
+ case <-ack:
+ t.Errorf("unexpected ack")
+ default:
+ }
+
+ // Server send ack
+ if err := rm.Reject(); err != nil {
+ t.Error(err)
+ }
+ // Client get ack.
+ if a := <-ack; a.Value != "testing" || a.Error != nil || a.Status != Rejected {
+ t.Error("unexpected ack: ", a.Status, a.Error, a.Value)
+ }
+ }
+ }
+}
+
+func TestClientReceiver(t *testing.T) {
+ nMessages := 3
+ client, server := newClientServer(t)
+ go func() {
+ for in := range server.Incoming() {
+ switch in := in.(type) {
+ case *IncomingSender:
+ s := in.Accept().(Sender)
+ go func() {
+ for i := int32(0); i < int32(nMessages); i++ {
+ out := s.SendSync(amqp.NewMessageWith(i))
+ if out.Error != nil {
+ t.Error(out.Error)
+ return
+ }
+ }
+ s.Close(nil)
+ }()
+ default:
+ in.Accept()
+ }
+ }
+ }()
+
+ r, err := client.Receiver(Source("foo"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ for i := int32(0); i < int32(nMessages); i++ {
+ rm, err := r.Receive()
+ if err != nil {
+ if err != Closed {
+ t.Error(err)
+ }
+ break
+ }
+ if err := rm.Accept(); err != nil {
+ t.Error(err)
+ }
+ if b, ok := rm.Message.Body().(int32); !ok || b != i {
+ t.Errorf("want %v, true got %v, %v", i, b, ok)
+ }
+ }
+ server.Close(nil)
+ client.Connection().Close(nil)
+}
+
+// Test timeout versions of waiting functions.
+func TestTimeouts(t *testing.T) {
+ var err error
+ rchan := make(chan Receiver, 1)
+ client, server := newClientServer(t)
+ go func() {
+ for i := range server.Incoming() {
+ switch i := i.(type) {
+ case *IncomingReceiver:
+ i.SetCapacity(1)
+ i.SetPrefetch(false)
+ rchan <- i.Accept().(Receiver) // Issue credit only on receive
+ default:
+ i.Accept()
+ }
+ }
+ }()
+ defer func() { closeClientServer(client, server) }()
+
+ // Open client sender
+ snd, err := client.Sender(Target("test"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ rcv := <-rchan
+
+ // Test send with timeout
+ short := time.Millisecond
+ long := time.Second
+ m := amqp.NewMessage()
+ if err := snd.SendSyncTimeout(m, 0).Error; err != Timeout { // No credit, expect timeout.
+ t.Error("want Timeout got", err)
+ }
+ if err := snd.SendSyncTimeout(m, short).Error; err != Timeout { // No credit, expect timeout.
+ t.Error("want Timeout got", err)
+ }
+ // Test receive with timeout
+ if _, err = rcv.ReceiveTimeout(0); err != Timeout { // No credit, expect timeout.
+ t.Error("want Timeout got", err)
+ }
+ // Test receive with timeout
+ if _, err = rcv.ReceiveTimeout(short); err != Timeout { // No credit, expect timeout.
+ t.Error("want Timeout got", err)
+ }
+ // There is now a credit on the link due to receive
+ ack := make(chan Outcome)
+ snd.SendAsyncTimeout(m, ack, nil, short)
+ // Disposition should timeout
+ select {
+ case <-ack:
+ t.Errorf("want Timeout got %#v", ack)
+ case <-time.After(short):
+ }
+
+ // Receive and accept
+ rm, err := rcv.ReceiveTimeout(long)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := rm.Accept(); err != nil {
+ t.Fatal(err)
+ }
+ // Sender get ack
+ if a := <-ack; a.Status != Accepted || a.Error != nil {
+ t.Errorf("want (accepted, nil) got %#v", a)
+ }
+}
+
+// A server that returns the opposite end of each client link via channels.
+type pairs struct {
+ t *testing.T
+ client Session
+ server Connection
+ rchan chan Receiver
+ schan chan Sender
+ capacity int
+ prefetch bool
+}
+
+func newPairs(t *testing.T, capacity int, prefetch bool) *pairs {
+ p := &pairs{t: t, rchan: make(chan Receiver, 1), schan: make(chan Sender, 1)}
+ p.client, p.server = newClientServer(t)
+ go func() {
+ for i := range p.server.Incoming() {
+ switch i := i.(type) {
+ case *IncomingReceiver:
+ i.SetCapacity(capacity)
+ i.SetPrefetch(prefetch)
+ p.rchan <- i.Accept().(Receiver)
+ case *IncomingSender:
+ p.schan <- i.Accept().(Sender)
+ default:
+ i.Accept()
+ }
+ }
+ }()
+ return p
+}
+
+func (p *pairs) close() {
+ closeClientServer(p.client, p.server)
+}
+
+// Return a client sender and server receiver
+func (p *pairs) senderReceiver() (Sender, Receiver) {
+ snd, err := p.client.Sender()
+ fatalIf(p.t, err)
+ rcv := <-p.rchan
+ return snd, rcv
+}
+
+// Return a client receiver and server sender
+func (p *pairs) receiverSender() (Receiver, Sender) {
+ rcv, err := p.client.Receiver()
+ fatalIf(p.t, err)
+ snd := <-p.schan
+ return rcv, snd
+}
+
+type result struct {
+ label string
+ err error
+ value interface{}
+}
+
+func (r result) String() string { return fmt.Sprintf("%v(%v)", r.err, r.label) }
+
+func doSend(snd Sender, results chan result) {
+ err := snd.SendSync(amqp.NewMessage()).Error
+ results <- result{"send", err, nil}
+}
+
+func doReceive(rcv Receiver, results chan result) {
+ msg, err := rcv.Receive()
+ results <- result{"receive", err, msg}
+}
+
+func doDisposition(ack <-chan Outcome, results chan result) {
+ results <- result{"disposition", (<-ack).Error, nil}
+}
+
+// Senders get credit immediately if receivers have prefetch set
+func TestSendReceivePrefetch(t *testing.T) {
+ pairs := newPairs(t, 1, true)
+ s, r := pairs.senderReceiver()
+ s.SendAsyncTimeout(amqp.NewMessage(), nil, nil, time.Second) // Should not block for credit.
+ if _, err := r.Receive(); err != nil {
+ t.Error(err)
+ }
+}
+
+// Senders do not get credit till Receive() if receivers don't have prefetch
+func TestSendReceiveNoPrefetch(t *testing.T) {
+ pairs := newPairs(t, 1, false)
+ s, r := pairs.senderReceiver()
+ done := make(chan struct{}, 1)
+ go func() {
+ s.SendAsyncTimeout(amqp.NewMessage(), nil, nil, time.Second) // Should block for credit.
+ close(done)
+ }()
+ select {
+ case <-done:
+ t.Errorf("send should be blocked on credit")
+ default:
+ if _, err := r.Receive(); err != nil {
+ t.Error(err)
+ } else {
+ <-done
+ } // Should be unblocked now
+ }
+}
+
+// Test that closing Links interrupts blocked link functions.
+func TestLinkCloseInterrupt(t *testing.T) {
+ want := amqp.Error{Name: "x", Description: "all bad"}
+ pairs := newPairs(t, 1, false)
+ results := make(chan result) // Collect expected errors
+
+ // Note closing the link does not interrupt Send() calls, the AMQP spec says
+ // that deliveries can be settled after the link is closed.
+
+ // Receiver.Close() interrupts Receive()
+ snd, rcv := pairs.senderReceiver()
+ go doReceive(rcv, results)
+ rcv.Close(want)
+ if r := <-results; want != r.err {
+ t.Errorf("want %#v got %#v", want, r)
+ }
+
+ // Remote Sender.Close() interrupts Receive()
+ snd, rcv = pairs.senderReceiver()
+ go doReceive(rcv, results)
+ snd.Close(want)
+ if r := <-results; want != r.err {
+ t.Errorf("want %#v got %#v", want, r)
+ }
+}
+
+// Test closing the server end of a connection.
+func TestConnectionCloseInterrupt1(t *testing.T) {
+ want := amqp.Error{Name: "x", Description: "bad"}
+ pairs := newPairs(t, 1, true)
+ results := make(chan result) // Collect expected errors
+
+ // Connection.Close() interrupts Send, Receive, Disposition.
+ snd, rcv := pairs.senderReceiver()
+ go doSend(snd, results)
+
+ if _, err := rcv.Receive(); err != nil {
+ t.Error("receive", err)
+ }
+ rcv, snd = pairs.receiverSender()
+ go doReceive(rcv, results)
+
+ snd, rcv = pairs.senderReceiver()
+ ack := snd.SendWaitable(amqp.NewMessage())
+ if _, err := rcv.Receive(); err != nil {
+ t.Error("receive", err)
+ }
+ go doDisposition(ack, results)
+
+ pairs.server.Close(want)
+ for i := 0; i < 3; i++ {
+ if r := <-results; want != r.err {
+ t.Errorf("want %v got %v", want, r)
+ }
+ }
+}
+
+// Test closing the client end of the connection.
+func TestConnectionCloseInterrupt2(t *testing.T) {
+ want := amqp.Error{Name: "x", Description: "bad"}
+ pairs := newPairs(t, 1, true)
+ results := make(chan result) // Collect expected errors
+
+ // Connection.Close() interrupts Send, Receive, Disposition.
+ snd, rcv := pairs.senderReceiver()
+ go doSend(snd, results)
+ if _, err := rcv.Receive(); err != nil {
+ t.Error("receive", err)
+ }
+
+ rcv, snd = pairs.receiverSender()
+ go doReceive(rcv, results)
+
+ snd, rcv = pairs.senderReceiver()
+ ack := snd.SendWaitable(amqp.NewMessage())
+ go doDisposition(ack, results)
+
+ pairs.client.Connection().Close(want)
+ for i := 0; i < 3; i++ {
+ if r := <-results; want != r.err {
+ t.Errorf("want %v got %v", want, r.err)
+ }
+ }
+}
+
+func heartbeat(c Connection) time.Duration {
+ return c.(*connection).engine.Transport().RemoteIdleTimeout()
+}
+
+func TestHeartbeat(t *testing.T) {
+ client, server := newClientServerOpts(t,
+ []ConnectionOption{Heartbeat(102 * time.Millisecond)},
+ nil)
+ defer closeClientServer(client, server)
+
+ var serverHeartbeat time.Duration
+
+ go func() {
+ for in := range server.Incoming() {
+ switch in := in.(type) {
+ case *IncomingConnection:
+ serverHeartbeat = in.Heartbeat()
+ in.AcceptConnection(Heartbeat(101 * time.Millisecond))
+ default:
+ in.Accept()
+ }
+ }
+ }()
+
+ // Freeze the server to stop it sending heartbeats.
+ unfreeze := make(chan bool)
+ defer close(unfreeze)
+ freeze := func() error { return server.(*connection).engine.Inject(func() { <-unfreeze }) }
+
+ fatalIf(t, client.Sync())
+ errorIf(t, checkEqual(101*time.Millisecond, heartbeat(client.Connection())))
+ errorIf(t, checkEqual(102*time.Millisecond, serverHeartbeat))
+ errorIf(t, client.Connection().Error())
+
+ // Freeze the server for less than a heartbeat
+ fatalIf(t, freeze())
+ time.Sleep(50 * time.Millisecond)
+ unfreeze <- true
+ // Make sure server is still responding.
+ s, err := client.Sender()
+ errorIf(t, err)
+ errorIf(t, s.Sync())
+
+ // Freeze the server till the client times out the connection
+ fatalIf(t, freeze())
+ select {
+ case <-client.Done():
+ if amqp.ResourceLimitExceeded != client.Error().(amqp.Error).Name {
+ t.Error("bad timeout error:", client.Error())
+ }
+ case <-time.After(400 * time.Millisecond):
+ t.Error("connection failed to time out")
+ }
+
+ unfreeze <- true // Unfreeze the server
+ <-server.Done()
+ if amqp.ResourceLimitExceeded != server.Error().(amqp.Error).Name {
+ t.Error("bad timeout error:", server.Error())
+ }
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/electron/receiver.go
----------------------------------------------------------------------
diff --cc electron/receiver.go
index 781fd7c,0000000..26b46a8
mode 100644,000000..100644
--- a/electron/receiver.go
+++ b/electron/receiver.go
@@@ -1,236 -1,0 +1,236 @@@
+/*
+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.
+*/
+
+package electron
+
+import (
+ "fmt"
+ "qpid.apache.org/amqp"
+ "qpid.apache.org/proton"
+ "time"
+)
+
+// Receiver is a Link that receives messages.
+//
+type Receiver interface {
+ Endpoint
+ LinkSettings
+
+ // Receive blocks until a message is available or until the Receiver is closed
+ // and has no more buffered messages.
+ Receive() (ReceivedMessage, error)
+
+ // ReceiveTimeout is like Receive but gives up after timeout, see Timeout.
+ //
+ // Note that that if Prefetch is false, after a Timeout the credit issued by
+ // Receive remains on the link. It will be used by the next call to Receive.
+ ReceiveTimeout(timeout time.Duration) (ReceivedMessage, error)
+
+ // Prefetch==true means the Receiver will automatically issue credit to the
+ // remote sender to keep its buffer as full as possible, i.e. it will
+ // "pre-fetch" messages independently of the application calling
+ // Receive(). This gives good throughput for applications that handle a
+ // continuous stream of messages. Larger capacity may improve throughput, the
+ // optimal value depends on the characteristics of your application.
+ //
+ // Prefetch==false means the Receiver will issue only issue credit when you
+ // call Receive(), and will only issue enough credit to satisfy the calls
+ // actually made. This gives lower throughput but will not fetch any messages
+ // in advance. It is good for synchronous applications that need to evaluate
+ // each message before deciding whether to receive another. The
+ // request-response pattern is a typical example. If you make concurrent
+ // calls to Receive with pre-fetch disabled, you can improve performance by
+ // setting the capacity close to the expected number of concurrent calls.
+ //
+ Prefetch() bool
+
+ // Capacity is the size (number of messages) of the local message buffer
+ // These are messages received but not yet returned to the application by a call to Receive()
+ Capacity() int
+}
+
+// Receiver implementation
+type receiver struct {
+ link
+ buffer chan ReceivedMessage
+ callers int
+}
+
+func (r *receiver) Capacity() int { return cap(r.buffer) }
+func (r *receiver) Prefetch() bool { return r.prefetch }
+
+// Call in proton goroutine
+func newReceiver(ls linkSettings) *receiver {
+ r := &receiver{link: link{linkSettings: ls}}
+ r.endpoint.init(r.link.pLink.String())
+ if r.capacity < 1 {
+ r.capacity = 1
+ }
+ r.buffer = make(chan ReceivedMessage, r.capacity)
+ r.handler().addLink(r.pLink, r)
+ r.link.pLink.Open()
+ if r.prefetch {
+ r.flow(r.maxFlow())
+ }
+ return r
+}
+
- // Call in proton gorotine. Max additional credit we can request.
++// Call in proton goroutine. Max additional credit we can request.
+func (r *receiver) maxFlow() int { return cap(r.buffer) - len(r.buffer) - r.pLink.Credit() }
+
+func (r *receiver) flow(credit int) {
+ if credit > 0 {
+ r.pLink.Flow(credit)
+ }
+}
+
+// Inject flow check per-caller call when prefetch is off.
+// Called with inc=1 at start of call, inc = -1 at end
+func (r *receiver) caller(inc int) {
+ _ = r.engine().Inject(func() {
+ r.callers += inc
+ need := r.callers - (len(r.buffer) + r.pLink.Credit())
+ max := r.maxFlow()
+ if need > max {
+ need = max
+ }
+ r.flow(need)
+ })
+}
+
+// Inject flow top-up if prefetch is enabled
+func (r *receiver) flowTopUp() {
+ if r.prefetch {
+ _ = r.engine().Inject(func() { r.flow(r.maxFlow()) })
+ }
+}
+
+func (r *receiver) Receive() (rm ReceivedMessage, err error) {
+ return r.ReceiveTimeout(Forever)
+}
+
+func (r *receiver) ReceiveTimeout(timeout time.Duration) (rm ReceivedMessage, err error) {
+ assert(r.buffer != nil, "Receiver is not open: %s", r)
+ if !r.prefetch { // Per-caller flow control
+ select { // Check for immediate availability, avoid caller() inject
+ case rm2, ok := <-r.buffer:
+ if ok {
+ rm = rm2
+ } else {
+ err = r.Error()
+ }
+ return
+ default: // Not immediately available, inject caller() counts
+ r.caller(+1)
+ defer r.caller(-1)
+ }
+ }
+ rmi, err := timedReceive(r.buffer, timeout)
+ switch err {
+ case nil:
+ r.flowTopUp()
+ rm = rmi.(ReceivedMessage)
+ case Closed:
+ err = r.Error()
+ }
+ return
+}
+
+// Called in proton goroutine on MMessage event.
+func (r *receiver) message(delivery proton.Delivery) {
+ if r.pLink.State().RemoteClosed() {
+ localClose(r.pLink, r.pLink.RemoteCondition().Error())
+ return
+ }
+ if delivery.HasMessage() {
+ m, err := delivery.Message()
+ if err != nil {
+ localClose(r.pLink, err)
+ return
+ }
+ assert(m != nil)
+ r.pLink.Advance()
+ if r.pLink.Credit() < 0 {
+ localClose(r.pLink, fmt.Errorf("received message in excess of credit limit"))
+ } else {
+ // We never issue more credit than cap(buffer) so this will not block.
+ r.buffer <- ReceivedMessage{m, delivery, r}
+ }
+ }
+}
+
+func (r *receiver) closed(err error) error {
+ e := r.link.closed(err)
+ if r.buffer != nil {
+ close(r.buffer)
+ }
+ return e
+}
+
+// ReceivedMessage contains an amqp.Message and allows the message to be acknowledged.
+type ReceivedMessage struct {
+ // Message is the received message.
+ Message amqp.Message
+
+ pDelivery proton.Delivery
+ receiver Receiver
+}
+
+// Acknowledge a ReceivedMessage with the given delivery status.
+func (rm *ReceivedMessage) acknowledge(status uint64) error {
+ return rm.receiver.(*receiver).engine().Inject(func() {
+ // Deliveries are valid as long as the connection is, unless settled.
+ rm.pDelivery.SettleAs(uint64(status))
+ })
+}
+
+// Accept tells the sender that we take responsibility for processing the message.
+func (rm *ReceivedMessage) Accept() error { return rm.acknowledge(proton.Accepted) }
+
+// Reject tells the sender we consider the message invalid and unusable.
+func (rm *ReceivedMessage) Reject() error { return rm.acknowledge(proton.Rejected) }
+
+// Release tells the sender we will not process the message but some other
+// receiver might.
+func (rm *ReceivedMessage) Release() error { return rm.acknowledge(proton.Released) }
+
+// IncomingReceiver is sent on the Connection.Incoming() channel when there is
+// an incoming request to open a receiver link.
+type IncomingReceiver struct {
+ incoming
+ linkSettings
+}
+
+func newIncomingReceiver(sn *session, pLink proton.Link) *IncomingReceiver {
+ return &IncomingReceiver{
+ incoming: makeIncoming(pLink),
+ linkSettings: makeIncomingLinkSettings(pLink, sn),
+ }
+}
+
+// SetCapacity sets the capacity of the incoming receiver, call before Accept()
+func (in *IncomingReceiver) SetCapacity(capacity int) { in.capacity = capacity }
+
+// SetPrefetch sets the pre-fetch mode of the incoming receiver, call before Accept()
+func (in *IncomingReceiver) SetPrefetch(prefetch bool) { in.prefetch = prefetch }
+
+// Accept accepts an incoming receiver endpoint
+func (in *IncomingReceiver) Accept() Endpoint {
+ return in.accept(func() Endpoint { return newReceiver(in.linkSettings) })
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/electron/time.go
----------------------------------------------------------------------
diff --cc electron/time.go
index 51bfbc5,0000000..52f0cee
mode 100644,000000..100644
--- a/electron/time.go
+++ b/electron/time.go
@@@ -1,83 -1,0 +1,83 @@@
+/*
+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.
+*/
+
+package electron
+
+import (
+ "fmt"
+ "math"
+ "reflect"
+ "time"
+)
+
+// Timeout is the error returned if an operation does not complete on time.
+//
+// Methods named *Timeout in this package take time.Duration timeout parameter.
+//
+// If timeout > 0 and there is no result available before the timeout, they
+// return a zero or nil value and Timeout as an error.
+//
- // If timeout == 0 they will return a result if one is immediatley available or
++// If timeout == 0 they will return a result if one is immediately available or
+// nil/zero and Timeout as an error if not.
+//
+// If timeout == Forever the function will return only when there is a result or
+// some non-timeout error occurs.
+//
+var Timeout = fmt.Errorf("timeout")
+
+// Forever can be used as a timeout parameter to indicate wait forever.
+const Forever time.Duration = math.MaxInt64
+
+// timedReceive receives on channel (which can be a chan of any type), waiting
+// up to timeout.
+//
+// timeout==0 means do a non-blocking receive attempt. timeout < 0 means block
+// forever. Other values mean block up to the timeout.
+//
+// Returns error Timeout on timeout, Closed on channel close.
+func timedReceive(channel interface{}, timeout time.Duration) (interface{}, error) {
+ cases := []reflect.SelectCase{
+ reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(channel)},
+ }
+ if timeout == 0 { // Non-blocking
+ cases = append(cases, reflect.SelectCase{Dir: reflect.SelectDefault})
+ } else { // Block up to timeout
+ cases = append(cases,
+ reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(After(timeout))})
+ }
+ chosen, value, ok := reflect.Select(cases)
+ switch {
+ case chosen == 0 && ok:
+ return value.Interface(), nil
+ case chosen == 0 && !ok:
+ return nil, Closed
+ default:
+ return nil, Timeout
+ }
+}
+
+// After is like time.After but returns a nil channel if timeout == Forever
+// since selecting on a nil channel will never return.
+func After(timeout time.Duration) <-chan time.Time {
+ if timeout == Forever {
+ return nil
+ } else {
+ return time.After(timeout)
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[15/50] [abbrv] qpid-proton git commit: PROTON-1517: For broader
compatibility, use a string correlation ID
Posted by ac...@apache.org.
PROTON-1517: For broader compatibility, use a string correlation ID
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2b033949
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2b033949
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2b033949
Branch: refs/heads/go1
Commit: 2b033949c54549591113e61ea33e625f9b898cbb
Parents: e22ca53
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 13:03:07 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 13:03:07 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/python/proton/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2b033949/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index cf36bbe..1d052d0 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -372,7 +372,7 @@ class SyncRequestResponse(IncomingMessageHandler):
if not self.address and not request.address:
raise ValueError("Request message has no address: %s" % request)
request.reply_to = self.reply_to
- request.correlation_id = correlation_id = self.correlation_id.next()
+ request.correlation_id = correlation_id = str(self.correlation_id.next())
self.sender.send(request)
def wakeup():
return self.response and (self.response.correlation_id == correlation_id)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[27/50] [abbrv] qpid-proton git commit: NO-JIRA: Fix unintended typo
in license comment.
Posted by ac...@apache.org.
NO-JIRA: Fix unintended typo in license comment.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cd056f34
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cd056f34
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cd056f34
Branch: refs/heads/go1
Commit: cd056f34fa559121d4f46deb26857240bec0a9e8
Parents: 5d7dd4a
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 13 16:16:31 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 16:16:31 2017 -0500
----------------------------------------------------------------------
tools/py/proctest.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cd056f34/tools/py/proctest.py
----------------------------------------------------------------------
diff --git a/tools/py/proctest.py b/tools/py/proctest.py
index d779573..33cf26e 100644
--- a/tools/py/proctest.py
+++ b/tools/py/proctest.py
@@ -7,7 +7,7 @@
# "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.0OFF
+# 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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[35/50] [abbrv] qpid-proton git commit: PROTON-1720: [ruby] Missing
link options, remove handler options
Posted by ac...@apache.org.
PROTON-1720: [ruby] Missing link options, remove handler options
- Filled in missing link options
- Removed all options from MessagingHandler:
- credit_window, auto_settle and auto_accept are now link options
- on_xxx_open/close can prevent an auto-response by raising StopAutoResponse
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c5351a9d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c5351a9d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c5351a9d
Branch: refs/heads/go1
Commit: c5351a9d710e52086a09d571079e104895869cfd
Parents: 055f3dc
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 18 13:41:15 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 18 13:49:02 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 2 +-
proton-c/bindings/ruby/lib/core/exceptions.rb | 4 ++
proton-c/bindings/ruby/lib/core/link.rb | 2 +-
.../bindings/ruby/lib/core/messaging_handler.rb | 28 +++-------
proton-c/bindings/ruby/lib/core/receiver.rb | 33 +++++++++++
proton-c/bindings/ruby/lib/core/sender.rb | 26 ++++++++-
proton-c/bindings/ruby/lib/core/session.rb | 40 ++++----------
proton-c/bindings/ruby/lib/core/terminus.rb | 56 +++++++++++++++----
.../ruby/lib/handler/messaging_adapter.rb | 58 ++++++++++----------
proton-c/bindings/ruby/tests/test_container.rb | 3 +-
proton-c/bindings/ruby/tests/test_delivery.rb | 3 +-
.../ruby/tests/test_messaging_adapter.rb | 45 +++++++--------
12 files changed, 182 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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 f9a80a7..e71e69b 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -132,7 +132,7 @@ module Qpid::Proton
Cproton.pn_connection_set_user(@impl, opts[:user]) if opts[:user]
Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password]
Cproton.pn_connection_set_hostname(@impl, opts[:virtual_host]) if opts[:virtual_host]
- @link_prefix = opts[:link_prefix] || cid
+ @link_prefix = opts[:link_prefix] || cid
Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl),
Types.symbol_array(opts[:offered_capabilities]))
Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl),
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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 66af5fc..1f74085 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -122,4 +122,8 @@ module Qpid::Proton
class AbortedError < ProtonError
end
+ # Raised to stop an automatic response to an endpoint open/close,
+ # so that the application can delay completing the open/close to a later time.
+ class StopAutoResponse < ProtonError
+ end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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
index 2e656c2..8b1525f 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -48,7 +48,7 @@ module Qpid::Proton
#
proton_caller :state
- # @deprecated use {Session#open_sender} and {#Session#open_receiver}
+ # @deprecated Use {Sender#open} or {Receiver#open}
proton_caller :open
# Close the local end of the link. The remote end may or may not be closed.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/proton-c/bindings/ruby/lib/core/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/messaging_handler.rb b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
index b733d37..88392f9 100644
--- a/proton-c/bindings/ruby/lib/core/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
@@ -1,4 +1,4 @@
-# Licensed to the Apache Software Foundation (ASF) under one
+ # 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
@@ -22,31 +22,17 @@ module Qpid::Proton
#
# Subclass the handler and provide the #on_xxx methods with your event-handling code.
#
+ # An AMQP endpoint (connection, session or link) must be opened and closed at
+ # each end. Normally proton responds automatically to an incoming
+ # open/close. You can prevent the automatic response by raising
+ # {StopAutoResponse} from +#on_xxx_open+ or +#on_xxx_close+. The application becomes responsible
+ # for calling +#open/#close+ at a later point.
+ #
class MessagingHandler
# @private
def proton_adapter_class() Handler::MessagingAdapter; end
- # Create a {MessagingHandler}
- # @option opts [Integer] :prefetch (10)
- # The number of messages to fetch in advance, 0 disables prefetch.
- # @option opts [Boolean] :auto_accept (true)
- # If true, incoming messages are accepted automatically after {#on_message}.
- # If false, the application can accept, reject or release the message
- # by calling methods on {Delivery} when the message has been processed.
- # @option opts [Boolean] :auto_settle (true) If true, outgoing
- # messages are settled automatically when the remote peer settles. If false,
- # the application must call {Delivery#settle} explicitly.
- # @option opts [Boolean] :auto_open (true)
- # If true, incoming connections are opened automatically.
- # If false, the application must call {Connection#open} to open incoming connections.
- # @option opts [Boolean] :auto_close (true)
- # If true, respond to a remote close automatically with a local close.
- # If false, the application must call {Connection#close} to finish closing connections.
- def initialize(opts={})
- @options = opts.clone
- end
-
# @return [Hash] handler options, see {#initialize}
attr_reader :options
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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
index 791e891..649219f 100644
--- a/proton-c/bindings/ruby/lib/core/receiver.rb
+++ b/proton-c/bindings/ruby/lib/core/receiver.rb
@@ -29,6 +29,39 @@ module Qpid::Proton
# @private
include Util::Wrapper
+ # Open {Receiver} link
+ #
+ # @overload open_receiver(address)
+ # @param address [String] address of the source to receive from
+ # @overload open_receiver(opts)
+ # @param opts [Hash] Receiver options, see {Receiver#open}
+ # @option opts [Boolean] :credit_window automatically maintain this much credit
+ # for messages to be pre-fetched while the current message is processed.
+ # @option opts [Boolean] :auto_accept if true, deliveries that are not settled by
+ # the application in {MessagingHandler#on_message} are automatically accepted.
+ # @option opts [Integer] :credit_window (10) automatically replenish credits for flow control.
+ # @option opts [Boolean] :dynamic (false) dynamic property for source {Terminus#dynamic}
+ # @option opts [String,Hash] :source source address or source options, see {Terminus#apply}
+ # @option opts [String,Hash] :target target address or target options, see {Terminus#apply}
+ # @option opts [String] :name (generated) unique name for the link.
+ def open(opts=nil)
+ opts ||= {}
+ opts = { :source => opts } if opts.is_a? String
+ @credit_window = opts.fetch(:credit_window, 10)
+ @auto_accept = opts.fetch(:auto_accept, true)
+ source.apply(opts[:source])
+ target.apply(opts[:target])
+ source.dynamic = !!opts[:dynamic]
+ super()
+ self
+ end
+
+ # @return [Integer] credit window, see {#open}
+ attr_reader :credit_window
+
+ # @return [Boolean] auto_accept flag, see {#open}
+ attr_reader :auto_accept
+
# @!attribute drain
#
# The drain mode.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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
index c1ba1f8..ff035cb 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -27,6 +27,30 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
+ # Open the {Sender} link
+ #
+ # @overload open_sender(address)
+ # @param address [String] address of the target to send to
+ # @overload open_sender(opts)
+ # @option opts [Boolean] :auto_settle (true) if true, automatically settle transfers
+ # @option opts [Boolean] :dynamic (false) dynamic property for source {Terminus#dynamic}
+ # @option opts [String,Hash] :source source address or source options, see {Terminus#apply}
+ # @option opts [String,Hash] :target target address or target options, see {Terminus#apply}
+ # @option opts [String] :name (generated) unique name for the link.
+ def open(opts=nil)
+ opts = { :target => opts } if opts.is_a? String
+ opts ||= {}
+ target.apply opts[:target]
+ source.apply opts[:source]
+ target.dynamic = !!opts[:dynamic]
+ @auto_settle = opts.fetch(:auto_settle, true)
+ super()
+ self
+ end
+
+ # @return [Boolean] auto_settle flag, see {#open}
+ attr_reader :auto_settle
+
# Hint to the remote receiver about the number of messages available.
# The receiver may use this to optimize credit flow, or may ignore it.
# @param n [Integer] The number of deliveries potentially available.
@@ -68,8 +92,6 @@ module Qpid::Proton
def initialize(*arg) super; @tag_count = 0; end
def next_tag() (@tag_count += 1).to_s(32); end
-
- # @private
can_raise_error :stream, :error_class => Qpid::Proton::LinkError
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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 78e78a2..5508fd9 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -56,13 +56,7 @@ module Qpid::Proton
#
proton_caller :incoming_bytes
- # @!method open
- # Opens the session.
- #
- # Once this operaton has completed, the state flag is updated.
- #
- # @see LOCAL_ACTIVE
- #
+ # Open the session
proton_caller :open
# @!attribute [r] state
@@ -116,30 +110,20 @@ module Qpid::Proton
Receiver.new(Cproton.pn_receiver(@impl, name))
end
- # TODO aconway 2016-01-04: doc options or target param, move option handling to Link.
- def open_receiver(opts=nil)
- opts = { :source => opts } if opts.is_a? String
- opts ||= {}
- receiver = Receiver.new Cproton.pn_receiver(@impl, opts[:name] || connection.link_name)
- receiver.source.address ||= opts[:source]
- receiver.target.address ||= opts[:target]
- receiver.source.dynamic = true if opts[:dynamic]
- receiver.handler = opts[:handler] if !opts[:handler].nil?
- receiver.open
- return receiver
+ # Create and open a {Receiver} link, see {Receiver#open}
+ # @param opts [Hash] receiver options, see {Receiver#open}
+ # @return [Receiver]
+ def open_receiver(opts=nil)
+ name = opts[:name] rescue connection.link_name
+ Receiver.new(Cproton.pn_receiver(@impl, name)).open(opts)
end
- # TODO aconway 2016-01-04: doc opts or target param, connection and containers
+ # Create and open a {Sender} link, see {#open}
+ # @param opts [Hash] sender options, see {Sender#open}
+ # @return [Sender]
def open_sender(opts=nil)
- opts = { :target => opts } if opts.is_a? String
- opts ||= {}
- sender = Sender.new Cproton.pn_sender(@impl, opts[:name] || connection.link_name)
- sender.target.address ||= opts[:target]
- sender.source.address ||= opts[:source]
- sender.target.dynamic = true if opts[:dynamic]
- sender.handler = opts[:handler] if !opts[:handler].nil?
- sender.open
- return sender
+ name = opts[:name] rescue connection.link_name
+ Sender.new(Cproton.pn_sender(@impl, name)).open(opts)
end
# Get the links on this Session.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/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
index d3181db..df7ca8e 100644
--- a/proton-c/bindings/ruby/lib/core/terminus.rb
+++ b/proton-c/bindings/ruby/lib/core/terminus.rb
@@ -29,6 +29,7 @@ module Qpid::Proton
# the Link.
#
class Terminus
+ include Util::Deprecation
# Indicates a non-existent source or target terminus.
UNSPECIFIED = Cproton::PN_UNSPECIFIED
@@ -85,7 +86,7 @@ module Qpid::Proton
#
proton_set_get :address
- # @!attribute durability
+ # @!attribute durability_mode
#
# @return [Integer] The durability mode of the terminus.
#
@@ -93,7 +94,11 @@ module Qpid::Proton
# @see CONFIGURATION
# @see DELIVERIES
#
- proton_set_get :durability
+ proton_forward :durability_mode, :get_durability
+ proton_forward :durability_mode=, :set_durability
+
+ deprecated_alias :durability, :durability_mode
+ deprecated_alias :durability=, :durability_mode=
# @!attribute expiry_policy
#
@@ -120,7 +125,7 @@ module Qpid::Proton
# @!attribute distribution_mode
#
- # @return [Integer] The distribution mode.
+ # @return [Integer] The distribution mode. Only relevant for a message source.
#
# @see DIST_MODE_UNSPECIFIED
# @see DIST_MODE_COPY
@@ -184,7 +189,8 @@ module Qpid::Proton
Codec::Data.new(Cproton.pn_terminus_outcomes(@impl))
end
- # Access and modify the AMQP filter set for the Terminus.
+ # Access and modify the AMQP filter set for a source terminus.
+ # Only relevant for a message source.
#
# This operation will return an instance of Data that is valid until the
# Terminus is freed due to its parent being freed. Any data contained in
@@ -199,12 +205,42 @@ module Qpid::Proton
Codec::Data.new(Cproton.pn_terminus_filter(@impl))
end
- # Copy another Terminus into this instance.
- #
- # @param source [Terminus] The source instance.
- #
- def copy(source)
- Cproton.pn_terminus_copy(@impl,source.impl)
+ # Replace the data in this Terminus with the contents of +other+
+ # @param other [Terminus] The other instance.
+ def replace(other)
+ Cproton.pn_terminus_copy(@impl, other.impl)
+ self
+ end
+ deprecated_alias :copy, :replace
+
+ # Apply options to this terminus.
+ # @option opts [String] :address the node address
+ # @option opts [Boolean] :dynamic (false)
+ # if true, request a new node with a unique address to be created. +:address+ is ignored.
+ # @option opts [Integer] :distribution_mode see {#distribution_mode}, only for source nodes
+ # @option opts [Integer] :durability_mode see {#durability_mode}
+ # @option opts [Integer] :timeout see {#timeout}
+ # @option opts [Integer] :expiry_policy see {#expiry_policy}
+ # @option opts [Hash] :filter see {#filter}, only for source nodes
+ # @option opts [Hash] :capabilities see {#capabilities}
+ def apply(opts=nil)
+ return unless opts
+ if opts.is_a? String # Shorthand for address
+ self.address = opts
+ else
+ opts.each_pair do |k,v|
+ case k
+ when :address then self.address = v
+ when :dynamic then self.dynamic = !!v
+ when :distribution_mode then self.distribution_mode = v
+ when :durability_mode then self.durability_mode = v
+ when :timeout then self.timeout = v
+ when :expiry_policy then self.expiry_policy = v
+ when :filter then self.filter = v
+ when :capabilities then self.capabilities = v
+ end
+ end
+ end
end
can_raise_error([:type=, :address=, :durability=, :expiry_policy=,
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
index 92dbba4..92f92e1 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
@@ -22,15 +22,6 @@ module Qpid::Proton
# Adapt raw proton events to {MessagingHandler} events.
class MessagingAdapter < Adapter
- def initialize handler
- super
- @opts = { :prefetch => 10, :auto_accept => true, :auto_settle => true,
- :auto_open => true, :auto_close => true }
- if handler.respond_to?(:options) && handler.options
- @opts.update(handler.options)
- handler.options.replace @opts
- end
- end
def delegate(method, *args)
forward(method, *args) or forward(:on_unhandled, method, *args)
@@ -39,8 +30,8 @@ module Qpid::Proton
def delegate_error(method, context)
unless forward(method, context) || forward(:on_error, context.condition)
forward(:on_unhandled, method, context)
- # By default close the whole connection on an un-handled error
- context.connection.close(context.condition) if @opts[:auto_close]
+ # Close the whole connection on an un-handled error
+ context.connection.close(context.condition)
end
end
@@ -51,14 +42,20 @@ module Qpid::Proton
def self.open_close(endpoint)
Module.new do
define_method(:"on_#{endpoint}_remote_open") do |event|
- delegate(:"on_#{endpoint}_open", event.context)
- event.context.open if @opts[:auto_open] && event.context.local_uninit?
+ begin
+ delegate(:"on_#{endpoint}_open", event.context)
+ event.context.open if event.context.local_uninit?
+ rescue StopAutoResponse
+ end
end
define_method(:"on_#{endpoint}_remote_close") do |event|
delegate_error(:"on_#{endpoint}_error", event.context) if event.context.condition
- delegate(:"on_#{endpoint}_close", event.context)
- event.context.close if @opts[:auto_close] && event.context.local_active?
+ begin
+ delegate(:"on_#{endpoint}_close", event.context)
+ event.context.close if event.context.local_active?
+ rescue StopAutoResponse
+ end
end
end
end
@@ -66,12 +63,17 @@ module Qpid::Proton
# Using modules so we can override to extend the behavior later in the handler.
[:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
- def on_transport_error(event) delegate_error(:on_transport_error, event.context); end
- def on_transport_closed(event) delegate(:on_transport_close, event.context); end
+ def on_transport_error(event)
+ delegate_error(:on_transport_error, event.context)
+ end
+
+ def on_transport_closed(event)
+ delegate(:on_transport_close, event.context) rescue StopAutoResponse
+ end
# Add flow control for link opening events
- def on_link_local_open(event) add_credit(event.receiver); end
- def on_link_remote_open(event) super; add_credit(event.receiver); end
+ def on_link_local_open(event) add_credit(event); end
+ def on_link_remote_open(event) super; add_credit(event); end
def on_delivery(event)
@@ -80,12 +82,12 @@ module Qpid::Proton
if d.aborted?
delegate(:on_delivery_abort, d)
elsif d.complete?
- if d.link.local_closed? && @opts[:auto_accept]
+ if d.link.local_closed? && d.receiver.auto_accept
d.release # Auto release after close
else
begin
delegate(:on_message, d, d.message)
- d.accept if @opts[:auto_accept] && !d.settled?
+ d.accept if d.receiver.auto_accept && !d.settled?
rescue Reject
d.reject unless d.settled?
rescue Release
@@ -94,7 +96,7 @@ module Qpid::Proton
end
end
delegate(:on_delivery_settle, d) if d.settled?
- add_credit(event.receiver)
+ add_credit(event)
else # Outgoing message
t = event.tracker
case t.state
@@ -104,20 +106,20 @@ module Qpid::Proton
when Delivery::MODIFIED then delegate(:on_tracker_modify, t)
end
delegate(:on_tracker_settle, t) if t.settled?
- t.settle if @opts[:auto_settle]
+ t.settle if t.sender.auto_settle
end
end
def on_link_flow(event)
- add_credit(event.receiver)
+ add_credit(event)
sender = event.sender
delegate(:on_sendable, sender) if sender && sender.open? && sender.credit > 0
end
- def add_credit(r)
- prefetch = @opts[:prefetch]
- if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
- r.flow(prefetch - r.credit)
+ def add_credit(event)
+ return unless (r = event.receiver)
+ if r.open? && (r.drained == 0) && r.credit_window && (r.credit_window > r.credit)
+ r.flow(r.credit_window - r.credit)
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index 82c34e2..f2ad1f1 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -164,7 +164,8 @@ class ContainerTest < Minitest::Test
# Note: user, password and sasl_xxx options are tested by ContainerSASLTest below
server_handler = Class.new(MessagingHandler) do
def on_error(e) raise e.inspect; end
- def on_connection_open(c) @connection = c
+ def on_connection_open(c)
+ @connection = c
c.open({
:virtual_host => "server.to.client",
:properties => { :server => :client },
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/proton-c/bindings/ruby/tests/test_delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_delivery.rb b/proton-c/bindings/ruby/tests/test_delivery.rb
index db15321..266ccd6 100644
--- a/proton-c/bindings/ruby/tests/test_delivery.rb
+++ b/proton-c/bindings/ruby/tests/test_delivery.rb
@@ -25,8 +25,7 @@ include Qpid::Proton
class TestDelivery < Minitest::Test
class NoAutoHandler < MessagingHandler
- @@options = {:auto_settle=>false, :auto_accept=>false}
- def options() @@options; end
+ def on_link_open(l) l.open({:auto_settle=>false, :auto_accept=>false}); end
end
class SendHandler < NoAutoHandler
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c5351a9d/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_messaging_adapter.rb b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
index 200b68c..5a2055b 100644
--- a/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
+++ b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
@@ -45,14 +45,18 @@ class DriverPair
def clear() each { |x| x.handler.clear; } end
end
-class TestMessagingHandler < Minitest::Test
+class NoAutoOpenClose < RecordingHandler
+ def initialize() super; @endpoints = []; end
+ def on_connection_open(x) @connection = x; super; raise StopAutoResponse; end
+ def on_session_open(x) @session = x; super; raise StopAutoResponse; end
+ def on_link_open(x) @link = x; super; raise StopAutoResponse; end
+ def on_connection_close(x) super; raise StopAutoResponse; end
+ def on_session_close(x) super; raise StopAutoResponse; end
+ def on_link_close(x) super; raise StopAutoResponse; end
+ attr_reader :connection, :session, :link
+end
- def test_handler_defaults
- d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
- want = { :prefetch => 10, :auto_settle => true, :auto_accept => true, :auto_open => true, :auto_close => true }
- assert_equal want, d.client.handler.options
- assert_equal want, d.server.handler.options
- end
+class TestMessagingHandler < Minitest::Test
def test_auto_open_close
d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
@@ -66,9 +70,7 @@ class TestMessagingHandler < Minitest::Test
end
def test_no_auto_open_close
- opts = { :auto_close => false, :auto_open => false }
- d = DriverPair.new(RecordingHandler.new(opts), RecordingHandler.new(opts))
-
+ d = DriverPair.new(NoAutoOpenClose.new, NoAutoOpenClose.new)
d.client.connection.open; d.run
assert_equal [:on_connection_open], d.server.handler.names
assert_equal [], d.client.handler.names
@@ -76,7 +78,7 @@ class TestMessagingHandler < Minitest::Test
assert_equal [:on_connection_open], d.client.handler.names
assert_equal [:on_connection_open], d.server.handler.names
d.clear
- d.client.connection.session.open; d.run
+ d.client.connection.open_session; d.run
assert_equal [:on_session_open], d.server.handler.names
assert_equal [], d.client.handler.names
d.clear
@@ -102,10 +104,10 @@ class TestMessagingHandler < Minitest::Test
# Close on half-open
def test_connection_error
- opts = { :auto_open => false }
- d = DriverPair.new(RecordingHandler.new(opts), RecordingHandler.new(opts))
+ d = DriverPair.new(NoAutoOpenClose.new, NoAutoOpenClose.new)
d.client.connection.open; d.run
d.server.connection.close "bad dog"; d.run
+ d.client.connection.close; d.run
assert_equal [:on_connection_open, :on_connection_error, :on_connection_close, :on_transport_close], d.client.handler.names
assert_equal "bad dog", d.client.handler.calls[1][1].condition.description
assert_equal [:on_connection_open, :on_connection_error, :on_connection_close, :on_transport_close], d.server.handler.names
@@ -137,24 +139,19 @@ class TestMessagingHandler < Minitest::Test
assert_equal "bad dog", d.server.handler.calls[0][1].condition.description
end
- def test_options_off
- handler_class = Class.new(RecordingHandler) do
- def on_link_open(l) super; @link = l; end
- def on_session_open(s) super; @session = s; end
- attr_reader :link, :session
- end
- off = {:prefetch => nil, :auto_settle => false, :auto_accept => false, :auto_open => false, :auto_close => false}
- d = DriverPair.new(handler_class.new(off), handler_class.new(off))
+ def test_options_off
+ linkopts = {:credit_window=>0, :auto_settle=>false, :auto_accept=>false}
+ d = DriverPair.new(NoAutoOpenClose.new, NoAutoOpenClose.new)
d.client.connection.open; d.run
assert_equal [[], [:on_connection_open]], d.names
d.server.connection.open; d.run
assert_equal [[:on_connection_open], [:on_connection_open]], d.names
d.clear
- s = d.client.connection.open_sender; d.run
+ s = d.client.connection.open_sender(linkopts); d.run
assert_equal [[], [:on_session_open, :on_link_open]], d.names
- d.server.handler.session.open
- d.server.handler.link.open # Return the opens
+ d.server.handler.session.open # Return session open
+ d.server.handler.link.open(linkopts) # Return link open
d.run
assert_equal [[:on_session_open, :on_link_open], [:on_session_open, :on_link_open]], d.names
d.clear
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[32/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] added
Tracker#abort
Posted by ac...@apache.org.
PROTON-1537: [ruby] added Tracker#abort
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a4c50ca4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a4c50ca4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a4c50ca4
Branch: refs/heads/go1
Commit: a4c50ca4a1d20a31a9ac0aa3e27fb41f3084724b
Parents: 4859de4
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 13 16:21:32 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 09:59:47 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/tracker.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a4c50ca4/proton-c/bindings/ruby/lib/core/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/tracker.rb b/proton-c/bindings/ruby/lib/core/tracker.rb
index cf04be9..da6ac0a 100644
--- a/proton-c/bindings/ruby/lib/core/tracker.rb
+++ b/proton-c/bindings/ruby/lib/core/tracker.rb
@@ -35,6 +35,11 @@ module Qpid::Proton
:annotations => Codec::Data.to_object(Cproton.pn_disposition_annotations(d))
}
end
- end
+ # Abort a partially-sent message.
+ # The tracker can no longer be used after calling {#abort}.
+ def abort()
+ Cproton.pn_delivery_abort(@impl)
+ end
+ end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[06/50] [abbrv] qpid-proton git commit: PROTON-1713: Add missing 'of'
Posted by ac...@apache.org.
PROTON-1713: Add missing 'of'
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/bcd6e0db
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bcd6e0db
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bcd6e0db
Branch: refs/heads/go1
Commit: bcd6e0dba17b205cb7a35debef30acaf73d6173e
Parents: 8166c29
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 07:53:29 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 07:53:54 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/cpp/docs/main.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bcd6e0db/proton-c/bindings/cpp/docs/main.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/docs/main.md b/proton-c/bindings/cpp/docs/main.md
index 798ac4b..25ba973 100644
--- a/proton-c/bindings/cpp/docs/main.md
+++ b/proton-c/bindings/cpp/docs/main.md
@@ -49,8 +49,8 @@ release.
Sections labeled **Thread safety** describe when and where it is safe
to call functions or access data across threads.
-Sections called **C++ versions** discuss features the API that depend
-on particular versions of C++ such as C++11.
+Sections called **C++ versions** discuss features of the API that
+depend on particular versions of C++ such as C++11.
## URLs
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[46/50] [abbrv] qpid-proton git commit: PROTON-1725: [ruby] broker
example should work if SSL certs not found
Posted by ac...@apache.org.
PROTON-1725: [ruby] broker example should work if SSL certs not found
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/45bd5733
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/45bd5733
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/45bd5733
Branch: refs/heads/go1
Commit: 45bd5733ec4c682f81b2a3efb4dbf43d10b1fae9
Parents: cd06716
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 20 11:24:39 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 20 11:24:39 2017 -0500
----------------------------------------------------------------------
examples/ruby/broker.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/45bd5733/examples/ruby/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/broker.rb b/examples/ruby/broker.rb
index b28ca76..5d0793a 100644
--- a/examples/ruby/broker.rb
+++ b/examples/ruby/broker.rb
@@ -85,7 +85,7 @@ class Broker < Qpid::Proton::MessagingHandler
end
@ssl_domain.allow_unsecured_client # SSL is optional, this is not secure.
rescue
- # Don't worry if we can't set up SSL.
+ @ssl_domain = nil # Don't worry if we can't set up SSL.
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[45/50] [abbrv] qpid-proton git commit: PROTON-1724: Revert
"PROTON-1721 [ruby] resovler errors are not handled correctly"
Posted by ac...@apache.org.
PROTON-1724: Revert "PROTON-1721 [ruby] resovler errors are not handled correctly"
This reverts commit c4d5fde71d925f3f44b0e29d672de7b039ee709f.
In the context of Ruby it is better to raise these exceptions immediately than to
bury them as events.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cd06716a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cd06716a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cd06716a
Branch: refs/heads/go1
Commit: cd06716a08c936f5e7db053355a033b4af45529f
Parents: f3054e3
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 20 11:18:47 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 20 11:22:04 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/container.rb | 26 ++-------------------
proton-c/bindings/ruby/tests/test_container.rb | 7 ++----
2 files changed, 4 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cd06716a/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 e16323b..7a69b58 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -41,18 +41,6 @@ module Qpid::Proton
end
end
- # Used as the @io when a socket cannot be created due to an erro (e.g resolver fails)
- # Saves the error and raises it in on_readable so it can be reported via normal channels.
- class BrokenSocket
- def initialize(msg) @error = IOError.new(msg); end
- [:read_nonblock, :write_nonblock, :accept].each do |m|
- define_method(m) { |*args| raise @error }
- end
- [:close_read, :close_write, :close].each do |m|
- define_method(m) {}
- end
- end
-
class ListenTask < Listener
def initialize(io, handler, container)
@@ -190,12 +178,7 @@ module Qpid::Proton
opts[:password] ||= url.password
end
opts[:ssl_domain] ||= SSLDomain.new(SSLDomain::MODE_CLIENT) if url.scheme == "amqps"
- socket = begin
- TCPSocket.new(url.host, url.port)
- rescue => e
- BrokenSocket.new("connect(#{url}): #{e}")
- end
- connect_io(socket, opts)
+ connect_io(TCPSocket.new(url.host, url.port), opts)
end
# Open an AMQP protocol connection on an existing {IO} object
@@ -220,12 +203,7 @@ module Qpid::Proton
not_stopped
url = Qpid::Proton::uri url
# TODO aconway 2017-11-01: amqps, SSL
- server = begin
- TCPServer.new(url.host, url.port)
- rescue => e
- BrokenSocket.new("listen(#{url}): #{e}")
- end
- listen_io(server, handler)
+ listen_io(TCPServer.new(url.host, url.port), handler)
end
# Listen for incoming AMQP connections on an existing server socket.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cd06716a/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index f2ad1f1..71a9f3a 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -152,11 +152,8 @@ class ContainerTest < Minitest::Test
def test_bad_host
cont = Container.new(__method__)
- l = cont.listen("badlisten.example.com:999")
- c = cont.connect("badconnect.example.com:999")
- cont.run
- assert_match(/badlisten.example.com:999/, l.condition.description)
- assert_match(/badconnect.example.com:999/, c.transport.condition.description)
+ assert_raises (SocketError) { cont.listen("badlisten.example.com:999") }
+ assert_raises (SocketError) { c = cont.connect("badconnect.example.com:999") }
end
# Verify that connection options are sent to the peer and available as Connection methods
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[31/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Replace
head/next with each
Posted by ac...@apache.org.
PROTON-1537: [ruby] Replace head/next with each
Connection provides each_session, Connection and Session provide each_link,
each_sender, each_receiver
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1e256cf7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1e256cf7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1e256cf7
Branch: refs/heads/go1
Commit: 1e256cf72c283a6998c36baa98e069fa90275706
Parents: a4c50ca
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Dec 14 11:35:32 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 09:59:47 2017 -0500
----------------------------------------------------------------------
examples/ruby/broker.rb | 6 +-
proton-c/bindings/ruby/lib/core/connection.rb | 107 ++++++++-----------
proton-c/bindings/ruby/lib/core/link.rb | 15 +--
proton-c/bindings/ruby/lib/core/session.rb | 34 ++++--
proton-c/bindings/ruby/lib/util/deprecation.rb | 9 +-
.../ruby/tests/test_connection_driver.rb | 41 +++++++
6 files changed, 121 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/examples/ruby/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/broker.rb b/examples/ruby/broker.rb
index aad32a9..9595e2f 100644
--- a/examples/ruby/broker.rb
+++ b/examples/ruby/broker.rb
@@ -127,11 +127,7 @@ class Broker < Qpid::Proton::MessagingHandler
end
def remove_stale_consumers(connection)
- l = connection.link_head(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
- while !l.nil?
- self.unsubscribe(l) if l.sender?
- l = l.next(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
- end
+ connection.each_sender { |s| unsubscribe(s) }
end
def on_sendable(sender)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/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 3ec7c26..2b97f41 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -197,78 +197,63 @@ module Qpid::Proton
# @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
- # state mask.
- #
- # Examines the state of each session owned by the connection, and returns
- # the first session that matches the given state mask. If the state mask
- # contains *both* local and remote flags, then an exact match against
- # those flags is performed. If the state mask contains only local *or*
- # remote flags, then a match occurs if a*any* of the local or remote flags
- # are set, respectively.
- #
- # @param mask [Integer] The state mask to be matched.
- #
- # @return [Session] The first matching session, or nil if none matched.
- #
- # @see Endpoint#LOCAL_UNINIT
- # @see Endpoint#LOCAL_ACTIVE
- # @see Endpoint#LOCAL_CLOSED
- # @see Endpoint#REMOTE_UNINIT
- # @see Endpoint#REMOTE_ACTIVE
- # @see Endpoint#REMOTE_CLOSED
- #
- def session_head(mask)
- Session.wrap(Cproton.pn_session_header(@impl, mask))
+ # @deprecated use {#each_session}
+ def session_head(mask)
+ deprecated __method__, "#each_session"
+ Session.wrap(Cproton.pn_session_head(@impl, mask))
end
- # Returns the first link that matches the given state mask.
- #
- # Examines the state of each link owned by the connection and returns the
- # first that matches the given state mask. If the state mask contains
- # *both* local and remote flags, then an exact match against those flags
- # is performed. If the state mask contains *only* local or remote flags,
- # then a match occurs if *any* of the local ore remote flags are set,
- # respectively.
- #
- # @param mask [Integer] The state mask to be matched.
- #
- # @return [Link] The first matching link, or nil if none matched.
- #
- # @see Endpoint#LOCAL_UNINIT
- # @see Endpoint#LOCAL_ACTIVE
- # @see Endpoint#LOCAL_CLOSED
- # @see Endpoint#REMOTE_UNINIT
- # @see Endpoint#REMOTE_ACTIVE
- # @see Endpoint#REMOTE_CLOSED
- #
+ # Get the sessions on this connection.
+ # @overload each_session
+ # @yieldparam s [Session] pass each session to block
+ # @overload each_session
+ # @return [Enumerator] enumerator over sessions
+ def each_session(&block)
+ return enum_for(:each_session) unless block_given?
+ s = Cproton.pn_session_head(@impl, 0);
+ while s
+ yield Session.wrap(s)
+ s = Cproton.pn_session_next(s, 0)
+ end
+ self
+ end
+
+ # @deprecated use {#each_link}
def link_head(mask)
+ deprecated __method__, "#each_link"
Link.wrap(Cproton.pn_link_head(@impl, mask))
end
- # Extracts the first delivery on the connection that has pending
- # operations.
- #
- # A readable delivery indicates message data is waiting to be read. A
- # A writable delivery indcates that message data may be sent. An updated
- # delivery indicates that the delivery's disposition has changed.
- #
- # A delivery will never be *both* readable and writable, but it may be
- # both readable or writable and updated.
- #
- # @return [Delivery] The delivery, or nil if none are available.
- #
- # @see Delivery#next
- #
+ # Get the links on this connection.
+ # @overload each_link
+ # @yieldparam l [Link] pass each link to block
+ # @overload each_link
+ # @return [Enumerator] enumerator over links
+ def each_link
+ return enum_for(:each_link) unless block_given?
+ l = Cproton.pn_link_head(@impl, 0);
+ while l
+ yield Link.wrap(l)
+ l = Cproton.pn_link_next(l, 0)
+ end
+ self
+ end
+
+ # Get the {Sender} links - see {#each_link}
+ def each_sender() each_link.select { |l| l.sender? }; end
+
+ # Get the {Receiver} links - see {#each_link}
+ def each_receiver() each_link.select { |l| l.receiver? }; end
+
+ # @deprecated use {#MessagingHandler} to handle work
def work_head
+ deprecated __method__
Delivery.wrap(Cproton.pn_work_head(@impl))
end
- # Returns the code for a connection error.
- #
- # @return [Integer] The error code.
- #
+ # @deprecated use {#condition}
def error
+ deprecated __method__, "#condition"
Cproton.pn_error_code(Cproton.pn_connection_error(@impl))
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/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
index 88c0e52..2e656c2 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -48,12 +48,7 @@ module Qpid::Proton
#
proton_caller :state
- # @!method open
- #
- # Opens the link. Once this operation has completed, the state flag will be
- # set.
- #
- # @see Endpoint::LOCAL_ACTIVE
+ # @deprecated use {Session#open_sender} and {#Session#open_receiver}
proton_caller :open
# Close the local end of the link. The remote end may or may not be closed.
@@ -226,13 +221,9 @@ module Qpid::Proton
Cproton.pn_link_error(@impl)
end
- # Returns the next link that matches the given state mask.
- #
- # @param state_mask [Integer] The state mask.
- #
- # @return [Sender, Receiver] The next link.
- #
+ # @deprecated use {Session#each_link, Connection#each_link}
def next(state_mask)
+ deprecated __method__, "Session#each_link, Connection#each_link"
return Link.wrap(Cproton.pn_link_next(@impl, state_mask))
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/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 14f1a67..78e78a2 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -90,17 +90,9 @@ module Qpid::Proton
Cproton.pn_session_close(@impl)
end
- # Retrieves the next session from a given connection that matches the
- # specified state mask.
- #
- # When uses with Connection#session_head an application can access all of
- # the session son the connection that match the given state.
- #
- # @param state_mask [Integer] The state mask to match.
- #
- # @return [Session, nil] The next session if one matches, or nil.
- #
+ # @deprecated use {Connection#each_session}
def next(state_mask)
+ deprecated __method__, "Connection#each_session"
Session.wrap(Cproton.pn_session_next(@impl, state_mask))
end
@@ -150,6 +142,28 @@ module Qpid::Proton
return sender
end
+ # Get the links on this Session.
+ # @overload each_link
+ # @yieldparam l [Link] pass each link to block
+ # @overload each_link
+ # @return [Enumerator] enumerator over links
+ def each_link
+ return enum_for(:each_link) unless block_given?
+ l = Cproton.pn_link_head(Cproton.pn_session_connection(@impl), 0);
+ while l
+ link = Link.wrap(l)
+ yield link if link.session == self
+ l = Cproton.pn_link_next(l, 0)
+ end
+ self
+ end
+
+ # Get the {Sender} links - see {#each_link}
+ def each_sender() each_link.select { |l| l.sender? }; end
+
+ # Get the {Receiver} links - see {#each_link}
+ def each_receiver() each_link.select { |l| l.receiver? }; end
+
private
def _local_condition
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
index 2e83783..8e96cd6 100644
--- a/proton-c/bindings/ruby/lib/util/deprecation.rb
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -18,9 +18,12 @@
module Qpid::Proton::Util
# @private
module Deprecation
- def self.deprecated(old, new=nil, skip=2)
+ MATCH_DIR = /#{File.dirname(File.dirname(__FILE__))}/
+
+ def self.deprecated(old, new=nil)
replace = new ? "use `#{new}`" : "internal use only"
- warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from\n #{caller(skip).first}"
+ line = caller.find { |l| not MATCH_DIR.match(l) }
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{line}"
end
def deprecated(*arg) Deprecation.deprecated(*arg); end
@@ -29,7 +32,7 @@ module Qpid::Proton::Util
def deprecated_alias(bad, good)
bad, good = bad.to_sym, good.to_sym
define_method(bad) do |*args, &block|
- self.deprecated bad, good, 3
+ self.deprecated bad, good
self.__send__(good, *args, &block)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e256cf7/proton-c/bindings/ruby/tests/test_connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_connection_driver.rb b/proton-c/bindings/ruby/tests/test_connection_driver.rb
index 3386e49..d8cce2a 100644
--- a/proton-c/bindings/ruby/tests/test_connection_driver.rb
+++ b/proton-c/bindings/ruby/tests/test_connection_driver.rb
@@ -86,4 +86,45 @@ class RawDriverTest < Minitest::Test
d.run(start + secs*2) # After 2x timeout, connections should close
assert_equal [[:on_transport_error, :on_transport_tail_closed, :on_transport_head_closed, :on_transport_closed], [:on_connection_remote_close, :on_transport_tail_closed, :on_transport_head_closed, :on_transport_closed]], d.collect { |x| x.handler.calls }
end
+
+ # Test each_session/each_link methods both with a block and returning Enumerator
+ def test_enumerators
+ connection = Connection.new()
+ (3.times.collect { connection.open_session }).each { |s|
+ s.open_sender; s.open_receiver
+ }
+
+ assert_equal 3, connection.each_session.to_a.size
+ assert_equal 6, connection.each_link.to_a.size
+
+ # Build Session => Set<Links> map using connection link enumerator
+ map1 = {}
+ connection.each_link { |l| map1[l.session] ||= Set.new; map1[l.session] << l }
+ assert_equal 3, map1.size
+ map1.each do |session,links|
+ assert_equal 2, links.size
+ links.each { |l| assert_equal session, l.session }
+ end
+
+ # Build Session => Set<Links> map using connection and session blocks
+ map2 = {}
+ connection.each_session do |session|
+ map2[session] = Set.new
+ session.each_link { |l| map2[session] << l }
+ end
+ assert_equal map1, map2
+
+ # Build Session => Set<Links> map using connection session and session enumerators
+ map3 = Hash[connection.each_session.collect { |s| [s, Set.new(s.each_link)] }]
+ assert_equal map1, map3
+
+ assert_equal [true, true, true], connection.each_sender.collect { |l| l.is_a? Sender }
+ assert_equal [true, true, true], connection.each_receiver.collect { |l| l.is_a? Receiver }
+ connection.each_session { |session|
+ assert_equal [true], session.each_sender.collect { |l| l.is_a? Sender }
+ assert_equal [true], session.each_receiver.collect { |l| l.is_a? Receiver }
+ }
+
+
+ end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[18/50] [abbrv] qpid-proton git commit: PROTON-1537: [proton-c] add
useful information to pn_delivery_inspect
Posted by ac...@apache.org.
PROTON-1537: [proton-c] add useful information to pn_delivery_inspect
Old format: pn_delivery<ADDR>
New format: pn_delivery<ADDR>{send|receive, tag=b"TAG", local=STATE, remote=STATE}
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3649b60d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3649b60d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3649b60d
Branch: refs/heads/go1
Commit: 3649b60de9a5b8908386e7381ceb479498b90c4a
Parents: 1c1bfad
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 6 15:42:14 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:41 2017 -0500
----------------------------------------------------------------------
proton-c/src/core/engine.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3649b60d/proton-c/src/core/engine.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/engine.c b/proton-c/src/core/engine.c
index eae5ebf..0656dd9 100644
--- a/proton-c/src/core/engine.c
+++ b/proton-c/src/core/engine.c
@@ -1498,7 +1498,19 @@ static void pn_disposition_clear(pn_disposition_t *ds)
#define pn_delivery_initialize NULL
#define pn_delivery_hashcode NULL
#define pn_delivery_compare NULL
-#define pn_delivery_inspect NULL
+
+int pn_delivery_inspect(void *obj, pn_string_t *dst) {
+ pn_delivery_t *d = (pn_delivery_t*)obj;
+ const char* dir = pn_link_is_sender(d->link) ? "sending" : "receiving";
+ pn_bytes_t bytes = pn_buffer_bytes(d->tag);
+ int err =
+ pn_string_addf(dst, "pn_delivery<%p>{%s, tag=b\"", obj, dir) ||
+ pn_quote(dst, bytes.start, bytes.size) ||
+ pn_string_addf(dst, "\", local=%s, remote=%s}",
+ pn_disposition_type_name(d->local.type),
+ pn_disposition_type_name(d->remote.type));
+ return err;
+}
pn_delivery_tag_t pn_dtag(const char *bytes, size_t size) {
pn_delivery_tag_t dtag = {size, bytes};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[10/50] [abbrv] qpid-proton git commit: PROTON-1522: Document user
and password args to reactor connect;
warn users not to put users and passwords in URLs
Posted by ac...@apache.org.
PROTON-1522: Document user and password args to reactor connect; warn users not to put users and passwords in URLs
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7a936e9c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7a936e9c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7a936e9c
Branch: refs/heads/go1
Commit: 7a936e9ce15372182a630761e6713af04401d119
Parents: 1eb8a7b
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 09:51:12 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 09:51:12 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 4 ++++
proton-c/bindings/python/proton/reactor.py | 16 +++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7a936e9c/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 3671e2b..21076ee 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -4172,6 +4172,10 @@ class Url(object):
The port can be specified as a service name, e.g. 'amqp' in the
URL string but Url.port always gives the integer value.
+ Warning: The placement of user and password in URLs is not
+ recommended. It can result in credentials leaking out in program
+ logs. Use connection configuration attributes instead.
+
@ivar scheme: Url scheme e.g. 'amqp' or 'amqps'
@ivar user: Username
@ivar password: Password
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7a936e9c/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 58045e9..e9ede47 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -715,15 +715,17 @@ class Container(Reactor):
called to process any events in the scope of this connection
or its child links
- @param kwargs: sasl_enabled, which determines whether a sasl
- layer is used for the connection; allowed_mechs an optional
+ @param kwargs: 'sasl_enabled', which determines whether a sasl
+ layer is used for the connection; 'allowed_mechs', an optional
string containing a space-separated list of SASL mechanisms to
- allow if sasl is enabled; allow_insecure_mechs a flag
+ allow if sasl is enabled; 'allow_insecure_mechs', a flag
indicating whether insecure mechanisms, such as PLAIN over a
- non-encrypted socket, are allowed; 'virtual_host' the hostname
- to set in the Open performative used by peer to determine the
- correct back-end service for the client. If 'virtual_host' is
- not supplied the host field from the URL is used instead."
+ non-encrypted socket, are allowed; 'virtual_host', the
+ hostname to set in the Open performative used by peer to
+ determine the correct back-end service for the client. If
+ 'virtual_host' is not supplied the host field from the URL is
+ used instead; 'user', the user to authenticate; 'password',
+ the authentication secret.
"""
conn = self.connection(handler)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[36/50] [abbrv] qpid-proton git commit: PROTON-1720: [ruby] Default
messaging adapter for duck-type handlers
Posted by ac...@apache.org.
PROTON-1720: [ruby] Default messaging adapter for duck-type handlers
Use messaging adapter by default so that handlers don't have to subclass
any particular class - MessagingHandler remains mainly for for documentation.
Raw handlers now implement #proton_adapter_class to return nil.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/813aa432
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/813aa432
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/813aa432
Branch: refs/heads/go1
Commit: 813aa432e8a04ad7f5800e639c0618dfd5ed08ff
Parents: c5351a9
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 18 14:19:39 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 18 14:19:39 2017 -0500
----------------------------------------------------------------------
.../bindings/ruby/lib/core/messaging_handler.rb | 3 ---
proton-c/bindings/ruby/lib/handler/adapter.rb | 27 +++++++++-----------
.../ruby/tests/test_connection_driver.rb | 3 +++
3 files changed, 15 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/813aa432/proton-c/bindings/ruby/lib/core/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/messaging_handler.rb b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
index 88392f9..fd33661 100644
--- a/proton-c/bindings/ruby/lib/core/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
@@ -30,9 +30,6 @@ module Qpid::Proton
#
class MessagingHandler
- # @private
- def proton_adapter_class() Handler::MessagingAdapter; end
-
# @return [Hash] handler options, see {#initialize}
attr_reader :options
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/813aa432/proton-c/bindings/ruby/lib/handler/adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/adapter.rb b/proton-c/bindings/ruby/lib/handler/adapter.rb
index fc89b12..66fa285 100644
--- a/proton-c/bindings/ruby/lib/handler/adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/adapter.rb
@@ -27,21 +27,12 @@ module Qpid::Proton
def initialize(handlers)
raise "empty handler array" if handlers.empty?
- adapters = handlers.map do |h|
- h.__send__(proton_adapter_class) if h.respond_to? :proton_adapter_class
- end.uniq
+ adapters = (handlers.map { |h| Adapter.adapter(h) }).uniq
raise "handler array not uniform, adapters requested: #{adapters}" if adapters.size > 1
- @proton_adapter_class = htypes[0]
-
- @options = {}
+ @proton_adapter_class = adapters[0]
@methods = Set.new
handlers.each do |h|
- if h.respond_to?(:options)
- @options.merge(h.options) do |k, a, b|
- raise ArgumentError, "handler array has conflicting options for [#{k}]: #{a} != #{b}"
- end
- end
- @methods.merge(h.methods.select { |m| handler_method? m }) # Event handler methods
+ @methods.merge(h.methods.select { |m| handler_method? m }) # Collect handler methods
end
end
@@ -63,16 +54,22 @@ module Qpid::Proton
class Adapter
def initialize(h) @handler = h; end
- def adapter_class(h) nil; end # Adapters don't need adapting
-
# Create and return an adapter for handler, or return h if it does not need adapting.
def self.adapt(handler)
return unless handler
a = Array(handler)
h = (a.size == 1) ? a[0] : ArrayHandler.new(a)
- a = h.respond_to?(:proton_adapter_class) ? h.proton_adapter_class.new(handler) : h
+ ac = adapter(h)
+ ac ? ac.new(h) : h
end
+ # Adapter class if requested by handler, else default to MessagingHandler
+ def self.adapter(handler)
+ handler.respond_to?(:proton_adapter_class) ? handler.proton_adapter_class : MessagingAdapter
+ end
+
+ def proton_adapter_class() nil; end # Adapters don't need adapting
+
def forward(method, *args)
(@handler.__send__(method, *args); true) if @handler.respond_to? method
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/813aa432/proton-c/bindings/ruby/tests/test_connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_connection_driver.rb b/proton-c/bindings/ruby/tests/test_connection_driver.rb
index d8cce2a..ebe6b53 100644
--- a/proton-c/bindings/ruby/tests/test_connection_driver.rb
+++ b/proton-c/bindings/ruby/tests/test_connection_driver.rb
@@ -26,6 +26,7 @@ class RawDriverTest < Minitest::Test
# Raw handler to record all on_xxx calls
class RecordingHandler
def initialize() @calls =[]; end
+ def proton_adapter_class() nil; end # Raw adapter
attr_reader :calls
def method_missing(name, *args) respond_to_missing?(name) ? @calls << name : super; end
@@ -35,6 +36,7 @@ class RawDriverTest < Minitest::Test
def test_send_recv
send_class = Class.new do
+ def proton_adapter_class() nil; end # Raw adapter
attr_reader :outcome
def on_link_flow(event) event.sender.send Message.new("foo"); end
def on_delivery(event)
@@ -44,6 +46,7 @@ class RawDriverTest < Minitest::Test
end
recv_class = Class.new do
+ def proton_adapter_class() nil; end # Raw adapter
attr_reader :message
def on_connection_remote_open(event) event.context.open; end
def on_session_remote_open(event) event.context.open; end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[21/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Support
for multiple handlers.
Posted by ac...@apache.org.
PROTON-1537: [ruby] Support for multiple handlers.
Moved old-style handler back to Qpid::Proton::Handler::MessagingHandler
Added new-style handler in Qpid::Proton::MessagingHandler
Handler classes indicate the appropriate Adapter class in a well-known constant.
The new-style handler adapter is not yet implemented, coming sooon.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cf4a3f6c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cf4a3f6c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cf4a3f6c
Branch: refs/heads/go1
Commit: cf4a3f6c248f9e3ba733e24ec4861adb92544d57
Parents: 72074d4
Author: Alan Conway <ac...@redhat.com>
Authored: Sat Dec 9 15:36:36 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:48 2017 -0500
----------------------------------------------------------------------
.../bindings/ruby/lib/core/connection_driver.rb | 6 +-
proton-c/bindings/ruby/lib/core/container.rb | 3 +-
.../bindings/ruby/lib/core/messaging_handler.rb | 262 ++++++++++---------
proton-c/bindings/ruby/lib/handler/adapter.rb | 157 +++--------
.../ruby/lib/handler/messaging_handler.rb | 160 +++++++++++
.../ruby/lib/handler/old_messaging_adapter.rb | 151 +++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 9 +-
proton-c/bindings/ruby/tests/test_adapter.rb | 32 +--
8 files changed, 516 insertions(+), 264 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index fe52d75..29bd299 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -167,10 +167,8 @@ module Qpid::Proton
# {#dispatch} and {#process}
def initialize(io, handler)
super(io)
- # Allow multiple handlers for backwards compatibility
- a = Array(handler)
- @handler = a.size > 1 ? MessagingHandlers.new(a) : handler
- @adapter = Handler::Adapter.try_convert(handler)
+ @handler = handler
+ @adapter = Handler::Adapter.adapt(handler)
end
# @return [MessagingHandler] The handler dispatched to by {#process}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/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 dddde03..fff32e6 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -106,8 +106,7 @@ module Qpid::Proton
# Allow ID as sole argument
(handler, id = nil, handler.to_str) if (id.nil? && handler.respond_to?(:to_str))
# Allow multiple handlers ofor backwards compatibility
- a = Array(handler)
- @handler = a.size > 1 ? MessagingHandlers.new(a) : handler
+ @handler = handler
@id = ((id && id.to_s) || SecureRandom.uuid).freeze
# Implementation note:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/proton-c/bindings/ruby/lib/core/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/messaging_handler.rb b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
index 7a793df..785f730 100644
--- a/proton-c/bindings/ruby/lib/core/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
@@ -24,152 +24,180 @@ module Qpid::Proton
#
class MessagingHandler
- # @overload initialize(opts)
- # Create a {MessagingHandler} with options +opts+
- # @option opts [Integer] :prefetch (10)
- # The number of messages to fetch in advance, 0 disables prefetch.
- # @option opts [Boolean] :auto_accept (true)
- # If true, incoming messages are accepted automatically after {#on_message}.
- # If false, the application can accept, reject or release the message
- # by calling methods on {Delivery} when the message has been processed.
- # @option opts [Boolean] :auto_settle (true) If true, outgoing
- # messages are settled automatically when the remote peer settles. If false,
- # the application must call {Delivery#settle} explicitly.
- # @option opts [Boolean] :auto_open (true)
- # If true, incoming connections are opened automatically.
- # If false, the application must call {Connection#open} to open incoming connections.
- # @option opts [Boolean] :auto_close (true)
- # If true, respond to a remote close automatically with a local close.
- # If false, the application must call {Connection#close} to finish closing connections.
- # @option opts [Boolean] :peer_close_is_error (false)
- # If true, and the remote peer closes the connection without an error condition,
- # the set the local error condition {Condition}("error", "unexpected peer close")
- #
- # @overload initialize(prefetch=10, auto_accept=true, auto_settle=true, peer_close_is_error=false)
- # @deprecated use +initialize(opts)+ overload
- def initialize(*args)
- @options = {}
- if args.size == 1 && args[0].is_a?(Hash)
- @options.replace(args[0])
- else # Fill options from deprecated fixed arguments
- [:prefetch, :auto_accept, :auto_settle, :peer_close_is_error].each do |k|
- opts[k] = args.shift unless args.empty?
- end
- end
- # NOTE: the options are processed by {Handler::Adapater}
+ # Create a {MessagingHandler}
+ # @option opts [Integer] :prefetch (10)
+ # The number of messages to fetch in advance, 0 disables prefetch.
+ # @option opts [Boolean] :auto_accept (true)
+ # If true, incoming messages are accepted automatically after {#on_message}.
+ # If false, the application can accept, reject or release the message
+ # by calling methods on {Delivery} when the message has been processed.
+ # @option opts [Boolean] :auto_settle (true) If true, outgoing
+ # messages are settled automatically when the remote peer settles. If false,
+ # the application must call {Delivery#settle} explicitly.
+ # @option opts [Boolean] :auto_open (true)
+ # If true, incoming connections are opened automatically.
+ # If false, the application must call {Connection#open} to open incoming connections.
+ # @option opts [Boolean] :auto_close (true)
+ # If true, respond to a remote close automatically with a local close.
+ # If false, the application must call {Connection#close} to finish closing connections.
+ # @option opts [Boolean] :peer_close_is_error (false)
+ # If true, and the remote peer closes the connection without an error condition,
+ # the set the local error condition {Condition}("error", "unexpected peer close")
+ def initialize(opts=nil)
+ @options = opts && opts.clone
end
- public
-
- # @private
# @return [Hash] handler options, see {#initialize}
attr_reader :options
+ # @!group Most common events
- # @!method on_transport_error(event)
- # Called when the transport fails or closes unexpectedly.
- # @param event [Event] The event.
+ # @!method on_container_start(container)
+ # The container event loop is started
+ # @param container [Container] The container.
- # !@method on_connection_error(event)
- # Called when the peer closes the connection with an error condition.
- # @param event [Event] The event.
+ # @!method on_container_stop(container)
+ # The container event loop is stopped
+ # @param container [Container] The container.
- # @!method on_session_error(event)
- # Called when the peer closes the session with an error condition.
- # @param event [Qpid:Proton::Event] The event.
+ # @!method on_message(delivery, message)
+ # A message is received.
+ # @param delivery [Delivery] The delivery.
+ # @param message [Message] The message
- # @!method on_link_error(event)
- # Called when the peer closes the link with an error condition.
- # @param event [Event] The event.
+ # @!method on_sendable(sender)
+ # A message can be sent
+ # @param sender [Sender] The sender.
- # @!method on_start(event)
- # Called when the event loop starts.
- # @param event [Event] The event.
+ # @!endgroup
- # @!method on_connection_closed(event)
- # Called when the connection is closed.
- # @param event [Event] The event.
+ # @!group Endpoint lifecycle events
- # @!method on_session_closed(event)
- # Called when the session is closed.
- # @param event [Event] The event.
+ # @!method on_connection_open(connection)
+ # The remote peer opened the connection
+ # @param connection
- # @!method on_link_closed(event)
- # Called when the link is closed.
- # @param event [Event] The event.
+ # @!method on_connection_close(connection)
+ # The remote peer closed the connection
+ # @param connection
- # @!method on_connection_closing(event)
- # Called when the peer initiates the closing of the connection.
- # @param event [Event] The event.
+ # @!method on_connection_error(connection)
+ # The remote peer closed the connection with an error condition
+ # @param connection
- # @!method on_session_closing(event)
- # Called when the peer initiates the closing of the session.
- # @param event [Event] The event.
+ # @!method on_session_open(session)
+ # The remote peer opened the session
+ # @param session
- # @!method on_link_closing(event)
- # Called when the peer initiates the closing of the link.
- # @param event [Event] The event.
+ # @!method on_session_close(session)
+ # The remote peer closed the session
+ # @param session
- # @!method on_disconnected(event)
- # Called when the socket is disconnected.
- # @param event [Event] The event.
+ # @!method on_session_error(session)
+ # The remote peer closed the session with an error condition
+ # @param session
- # @!method on_sendable(event)
- # Called when the sender link has credit and messages can therefore
- # be transferred.
- # @param event [Event] The event.
+ # @!method on_sender_open(sender)
+ # The remote peer opened the sender
+ # @param sender
- # @!method on_accepted(event)
- # Called when the remote peer accepts an outgoing message.
- # @param event [Event] The event.
+ # @!method on_sender_detach(sender)
+ # The remote peer detached the sender
+ # @param sender
- # @!method on_rejected(event)
- # Called when the remote peer rejects an outgoing message.
- # @param event [Event] The event.
+ # @!method on_sender_close(sender)
+ # The remote peer closed the sender
+ # @param sender
- # @!method on_released(event)
- # Called when the remote peer releases an outgoing message for re-delivery as-is.
- # @param event [Event] The event.
+ # @!method on_sender_error(sender)
+ # The remote peer closed the sender with an error condition
+ # @param sender
- # @!method on_modified(event)
- # Called when the remote peer releases an outgoing message for re-delivery with modifications.
- # @param event [Event] The event.
+ # @!method on_receiver_open(receiver)
+ # The remote peer opened the receiver
+ # @param receiver
- # @!method on_settled(event)
- # Called when the remote peer has settled hte outgoing message.
- # This is the point at which it should never be retransmitted.
- # @param event [Event] The event.
+ # @!method on_receiver_detach(receiver)
+ # The remote peer detached the receiver
+ # @param receiver
- # @!method on_message(event)
- # Called when a message is received.
- #
- # The message is available from {Event#message}, to accept or reject the message
- # use {Event#delivery}
- # @param event [Event] The event.
+ # @!method on_receiver_close(receiver)
+ # The remote peer closed the receiver
+ # @param receiver
- # @!method on_aborted(event)
- # Called when message delivery is aborted by the sender.
- # The {Event#delivery} provides information about the delivery, but the message should be ignored.
+ # @!method on_receiver_error(receiver)
+ # The remote peer closed the receiver with an error condition
+ # @param receiver
- # @!method on_error(event)
- # If +on_xxx_error+ method is missing, {#on_error} is called instead.
- # If {#on_error} is missing, the connection is closed with the error.
- # @param event [Event] the event, {Event#method} provides the original method name.
+ # @!endgroup
- # @!method on_unhandled(event)
- # If an +on_xxx+ method is missing, {#on_unhandled} is called instead.
- # @param event [Event] the event, {Event#method} provides the original method name.
- end
+ # @!group Delivery events
+
+ # @!method on_tracker_accept(tracker)
+ # The receiving end accepted a delivery
+ # @param tracker [Tracker] The tracker.
+
+ # @!method on_tracker_reject(tracker)
+ # The receiving end rejected a delivery
+ # @param tracker [Tracker] The tracker.
+
+ # @!method on_tracker_release(tracker)
+ # The receiving end released a delivery
+ # @param tracker [Tracker] The tracker.
+
+ # @!method on_tracker_modify(tracker)
+ # The receiving end modified a delivery
+ # @param tracker [Tracker] The tracker.
+
+ # @!method on_tracker_settle(tracker)
+ # The receiving end settled a delivery
+ # @param tracker [Tracker] The tracker.
+
+ # @!method on_delivery_settle(delivery)
+ # The sending end settled a delivery
+ # @param delivery [Delivery] The delivery.
+
+ # @!endgroup
+
+ # @!group Flow control events
+
+ # @!method on_sender_drain_start(sender)
+ # The remote end of the sender requested draining
+ # @param sender [Sender] The sender.
+
+ # @!method on_receiver_drain_finish(receiver)
+ # The remote end of the receiver completed draining
+ # @param receiver [Receiver] The receiver.
+
+ # @!endgroup
+
+ # @!group Transport events
+
+ # @!method on_transport_open(transport)
+ # The underlying network channel opened
+ # @param transport [Transport] The transport.
+
+ # @!method on_transport_close(transport)
+ # The underlying network channel closed
+ # @param transport [Transport] The transport.
+
+ # @!method on_transport_error(transport)
+ # The underlying network channel is closing due to an error.
+ # @param transport [Transport] The transport.
+
+ # @!endgroup
+
+ # @!group Unhandled events
- # A {MessagingHandler} that delegates events to an array of handlers, in order.
- class MessagingHandlers < MessagingHandler
- # @param handlers [Array<MessagingHandler>] handler objects
- def initialize(handlers) @handlers = handlers; end
+ # @!method on_error(error_condition)
+ # The fallback error handler when no specific on_xxx_error is defined
+ # @param error_condition [Condition] Provides information about the error.
- # @return [Array<MessagingHandler>] array of handlers
- attr_reader :handlers
+ # @!method on_unhandled(method_name, *args)
+ # Called for events with no handler. Similar to ruby's standard #method_
+ # @param method_name [Symbol] Name of the event method that would have been called.
+ # @param args [Array] Arguments that would have been passed
- # Dispatch events to each of {#handlers} in turn
- def on_unhandled(event) @handlers.each { |h| event.dispatch h }; end
+ # @!endgroup
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/proton-c/bindings/ruby/lib/handler/adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/adapter.rb b/proton-c/bindings/ruby/lib/handler/adapter.rb
index 25dd8c0..eb712c3 100644
--- a/proton-c/bindings/ruby/lib/handler/adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/adapter.rb
@@ -17,140 +17,61 @@
# @private
-module Qpid::Proton::Handler
+module Qpid::Proton
+ module Handler
- # @private
- # Adapter to convert raw proton events to {#MessagingHandler} events
- class Adapter
-
- def self.try_convert(h) h.is_a?(Adapter) ? h : Adapter.new(h); end
-
- def initialize handler
- @handler = handler || MessagingHandler.new # Pick up default MH behavior
- @opts = (handler.options if handler.respond_to?(:options)) || {}
- @opts[:prefetch] ||= 10
- @opts[:peer_close_is_error] = false unless @opts.include? :peer_close_is_error
- [:auto_accept, :auto_settle, :auto_open, :auto_close].each do |k|
- @opts[k] = true unless @opts.include? k
- end
- end
-
- def dispatch(method, event)
- (@handler.__send__(method, event); true) if @handler.respond_to? method
- end
-
- def delegate(method, event)
- event.method = method # Update the event with the new method
- event.dispatch(@handler) || dispatch(:on_unhandled, event)
- end
- def delegate_error(method, event)
- event.method = method
- unless event.dispatch(@handler) # Default behaviour if not dispatched
- dispatch(:on_error, event) || dispatch(:on_unhandled, event)
- event.connection.close event.context.condition # Close the connection by default
+ class MultiHandler
+ def self.maybe(h)
+ a = Array(h)
+ a.size > 1 ? self.new(h) : h
end
- end
-
- # Define repetative on_xxx_open/close methods for each endpoint type
- def self.open_close(endpoint)
- on_opening = :"on_#{endpoint}_opening"
- on_opened = :"on_#{endpoint}_opened"
- on_closing = :"on_#{endpoint}_closing"
- on_closed = :"on_#{endpoint}_closed"
- on_error = :"on_#{endpoint}_error"
-
- Module.new do
- define_method(:"on_#{endpoint}_local_open") do |event|
- delegate(on_opened, event) if event.context.remote_open?
- end
- define_method(:"on_#{endpoint}_remote_open") do |event|
- if event.context.local_open?
- delegate(on_opened, event)
- elsif event.context.local_uninit?
- delegate(on_opening, event)
- event.context.open if @opts[:auto_open]
+ def initialize(a)
+ @a = a;
+ @options = {}
+ @methods = Set.new
+ @a.each do |h|
+ @methods.merge(h.methods.select { |m| m.to_s.start_with?("on_") })
+ @options.merge(h.options) do |k, a, b|
+ raise ArgumentError, "handlers have conflicting option #{k} => #{a} != #{b}"
end
end
+ end
- define_method(:"on_#{endpoint}_local_close") do |event|
- delegate(on_closed, event) if event.context.remote_closed?
- end
+ attr_reader :options
- define_method(:"on_#{endpoint}_remote_close") do |event|
- if event.context.remote_condition
- delegate_error(on_error, event)
- elsif event.context.local_closed?
- delegate(on_closed, event)
- elsif @opts[:peer_close_is_error]
- Condition.assign(event.context.__send__(:_remote_condition), "unexpected peer close")
- delegate_error(on_error, event)
- else
- delegate(on_closing, event)
- end
- event.context.close if @opts[:auto_close]
+ def method_missing(name, *args)
+ if respond_to_missing?(name)
+ @a.each { |h| h.__send__(name, *args) if h.respond_to? name}
+ else
+ super
end
end
+ def respond_to_missing?(name, private=false); @methods.include?(name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
end
- # Generate and include open_close modules for each endpoint type
- [:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
-
- def on_transport_error(event) delegate_error(:on_transport_error, event); end
- def on_transport_closed(event) delegate(:on_transport_closed, event); end
-
- # Add flow control for link opening events
- def on_link_local_open(event) super; add_credit(event); end
- def on_link_remote_open(event) super; add_credit(event); end
+ # Base adapter
+ class Adapter
+ def initialize(h)
+ @handler = MultiHandler.maybe h
+ end
- def on_delivery(event)
- if event.link.receiver? # Incoming message
- d = event.delivery
- if d.aborted?
- delegate(:on_aborted, event)
- d.settle
- elsif d.complete?
- if d.link.local_closed? && @opts[:auto_accept]
- d.release
- else
- begin
- delegate(:on_message, event)
- d.accept if @opts[:auto_accept]
- rescue Qpid::Proton::Reject
- d.reject
- rescue Qpid::Proton::Release
- d.release(true)
- end
- end
- end
- delegate(:on_settled, event) if d.settled?
- add_credit(event)
- else # Outgoing message
- t = event.tracker
- if t.updated?
- case t.remote_state
- when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
- when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
- when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
- when Qpid::Proton::Delivery::MODIFIED then delegate(:on_modified, event)
- end
- delegate(:on_settled, event) if t.settled?
- t.settle if @opts[:auto_settle]
+ def self.adapt(h)
+ if h.respond_to? :proton_event_adapter
+ a = h.proton_event_adapter
+ a = a.new(h) if a.is_a? Class
+ a
+ else
+ OldMessagingAdapter.new h
end
end
- end
- def on_link_flow(event)
- add_credit(event)
- l = event.link
- delegate(:on_sendable, event) if l.sender? && l.open? && l.credit > 0
- end
+ # Adapter is already an adapter
+ def proton_event_adapter() self; end
- def add_credit(event)
- r = event.receiver
- prefetch = @opts[:prefetch]
- if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
- r.flow(prefetch - r.credit)
+ def dispatch(method, *args)
+ (@handler.__send__(method, *args); true) if @handler.respond_to? method
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/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 0000000..0e94c17
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.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
+ module Handler
+
+ # @deprecated use {Qpid::Proton::MessagingHandler}
+ class MessagingHandler
+
+ # @overload initialize(opts)
+ # Create a {MessagingHandler} with options +opts+
+ # @option opts [Integer] :prefetch (10)
+ # The number of messages to fetch in advance, 0 disables prefetch.
+ # @option opts [Boolean] :auto_accept (true)
+ # If true, incoming messages are accepted automatically after {#on_message}.
+ # If false, the application can accept, reject or release the message
+ # by calling methods on {Delivery} when the message has been processed.
+ # @option opts [Boolean] :auto_settle (true) If true, outgoing
+ # messages are settled automatically when the remote peer settles. If false,
+ # the application must call {Delivery#settle} explicitly.
+ # @option opts [Boolean] :auto_open (true)
+ # If true, incoming connections are opened automatically.
+ # If false, the application must call {Connection#open} to open incoming connections.
+ # @option opts [Boolean] :auto_close (true)
+ # If true, respond to a remote close automatically with a local close.
+ # If false, the application must call {Connection#close} to finish closing connections.
+ # @option opts [Boolean] :peer_close_is_error (false)
+ # If true, and the remote peer closes the connection without an error condition,
+ # the set the local error condition {Condition}("error", "unexpected peer close")
+ #
+ # @overload initialize(prefetch=10, auto_accept=true, auto_settle=true, peer_close_is_error=false)
+ # @deprecated use +initialize(opts)+ overload
+ def initialize(*args)
+ @options = {}
+ if args.size == 1 && args[0].is_a?(Hash)
+ @options.replace(args[0])
+ else # Fill options from deprecated fixed arguments
+ [:prefetch, :auto_accept, :auto_settle, :peer_close_is_error].each do |k|
+ opts[k] = args.shift unless args.empty?
+ end
+ end
+ # NOTE: the options are processed by {Handler::Adapater}
+ end
+
+ public
+
+ # @return [Hash] handler options, see {#initialize}
+ attr_reader :options
+
+ # @!method on_transport_error(event)
+ # Called when the transport fails or closes unexpectedly.
+ # @param event [Event] The event.
+
+ # !@method on_connection_error(event)
+ # Called when the peer closes the connection with an error condition.
+ # @param event [Event] The event.
+
+ # @!method on_session_error(event)
+ # Called when the peer closes the session with an error condition.
+ # @param event [Qpid:Proton::Event] The event.
+
+ # @!method on_link_error(event)
+ # Called when the peer closes the link with an error condition.
+ # @param event [Event] The event.
+
+ # @!method on_start(event)
+ # Called when the event loop starts.
+ # @param event [Event] The event.
+
+ # @!method on_connection_closed(event)
+ # Called when the connection is closed.
+ # @param event [Event] The event.
+
+ # @!method on_session_closed(event)
+ # Called when the session is closed.
+ # @param event [Event] The event.
+
+ # @!method on_link_closed(event)
+ # Called when the link is closed.
+ # @param event [Event] The event.
+
+ # @!method on_connection_closing(event)
+ # Called when the peer initiates the closing of the connection.
+ # @param event [Event] The event.
+
+ # @!method on_session_closing(event)
+ # Called when the peer initiates the closing of the session.
+ # @param event [Event] The event.
+
+ # @!method on_link_closing(event)
+ # Called when the peer initiates the closing of the link.
+ # @param event [Event] The event.
+
+ # @!method on_disconnected(event)
+ # Called when the socket is disconnected.
+ # @param event [Event] The event.
+
+ # @!method on_sendable(event)
+ # Called when the sender link has credit and messages can therefore
+ # be transferred.
+ # @param event [Event] The event.
+
+ # @!method on_accepted(event)
+ # Called when the remote peer accepts an outgoing message.
+ # @param event [Event] The event.
+
+ # @!method on_rejected(event)
+ # Called when the remote peer rejects an outgoing message.
+ # @param event [Event] The event.
+
+ # @!method on_released(event)
+ # Called when the remote peer releases an outgoing message for re-delivery as-is.
+ # @param event [Event] The event.
+
+ # @!method on_modified(event)
+ # Called when the remote peer releases an outgoing message for re-delivery with modifications.
+ # @param event [Event] The event.
+
+ # @!method on_settled(event)
+ # Called when the remote peer has settled hte outgoing message.
+ # This is the point at which it should never be retransmitted.
+ # @param event [Event] The event.
+
+ # @!method on_message(event)
+ # Called when a message is received.
+ #
+ # The message is available from {Event#message}, to accept or reject the message
+ # use {Event#delivery}
+ # @param event [Event] The event.
+
+ # @!method on_aborted(event)
+ # Called when message delivery is aborted by the sender.
+ # The {Event#delivery} provides information about the delivery, but the message should be ignored.
+
+ # @!method on_error(event)
+ # If +on_xxx_error+ method is missing, {#on_error} is called instead.
+ # If {#on_error} is missing, the connection is closed with the error.
+ # @param event [Event] the event, {Event#method} provides the original method name.
+
+ # @!method on_unhandled(event)
+ # If an +on_xxx+ method is missing, {#on_unhandled} is called instead.
+ # @param event [Event] the event, {Event#method} provides the original method name.
+ end
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
new file mode 100644
index 0000000..c43dc8c
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
@@ -0,0 +1,151 @@
+# 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.
+
+
+# @private
+module Qpid::Proton
+ module Handler
+
+ # Adapter to convert raw proton events to old {Handler::MessagingHandler} events
+ class OldMessagingAdapter < Adapter
+ def initialize handler
+ super
+ @opts = (handler.options if handler.respond_to?(:options)) || {}
+ @opts[:prefetch] ||= 10
+ @opts[:peer_close_is_error] = false unless @opts.include? :peer_close_is_error
+ [:auto_accept, :auto_settle, :auto_open, :auto_close].each do |k|
+ @opts[k] = true unless @opts.include? k
+ end
+ end
+
+ def delegate(method, event)
+ event.method = method # Update the event with the new method
+ event.dispatch(@handler) || dispatch(:on_unhandled, event)
+ end
+ def delegate_error(method, event)
+ event.method = method
+ unless event.dispatch(@handler) # Default behaviour if not dispatched
+ dispatch(:on_error, event) || dispatch(:on_unhandled, event)
+ event.connection.close event.context.condition # Close the connection by default
+ end
+ end
+
+ # Define repetative on_xxx_open/close methods for each endpoint type
+ def self.open_close(endpoint)
+ on_opening = :"on_#{endpoint}_opening"
+ on_opened = :"on_#{endpoint}_opened"
+ on_closing = :"on_#{endpoint}_closing"
+ on_closed = :"on_#{endpoint}_closed"
+ on_error = :"on_#{endpoint}_error"
+
+ Module.new do
+ define_method(:"on_#{endpoint}_local_open") do |event|
+ delegate(on_opened, event) if event.context.remote_open?
+ end
+
+ define_method(:"on_#{endpoint}_remote_open") do |event|
+ if event.context.local_open?
+ delegate(on_opened, event)
+ elsif event.context.local_uninit?
+ delegate(on_opening, event)
+ event.context.open if @opts[:auto_open]
+ end
+ end
+
+ define_method(:"on_#{endpoint}_local_close") do |event|
+ delegate(on_closed, event) if event.context.remote_closed?
+ end
+
+ define_method(:"on_#{endpoint}_remote_close") do |event|
+ if event.context.remote_condition
+ delegate_error(on_error, event)
+ elsif event.context.local_closed?
+ delegate(on_closed, event)
+ elsif @opts[:peer_close_is_error]
+ Condition.assign(event.context.__send__(:_remote_condition), "unexpected peer close")
+ delegate_error(on_error, event)
+ else
+ delegate(on_closing, event)
+ end
+ event.context.close if @opts[:auto_close]
+ end
+ end
+ end
+ # Generate and include open_close modules for each endpoint type
+ [:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
+
+ def on_transport_error(event) delegate_error(:on_transport_error, event); end
+ def on_transport_closed(event) delegate(:on_transport_closed, event); end
+
+ # Add flow control for link opening events
+ def on_link_local_open(event) super; add_credit(event); end
+ def on_link_remote_open(event) super; add_credit(event); end
+
+
+ def on_delivery(event)
+ if event.link.receiver? # Incoming message
+ d = event.delivery
+ if d.aborted?
+ delegate(:on_aborted, event)
+ d.settle
+ elsif d.complete?
+ if d.link.local_closed? && @opts[:auto_accept]
+ d.release
+ else
+ begin
+ delegate(:on_message, event)
+ d.accept if @opts[:auto_accept]
+ rescue Qpid::Proton::Reject
+ d.reject
+ rescue Qpid::Proton::Release
+ d.release(true)
+ end
+ end
+ end
+ delegate(:on_settled, event) if d.settled?
+ add_credit(event)
+ else # Outgoing message
+ t = event.tracker
+ if t.updated?
+ case t.remote_state
+ when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
+ when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
+ when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
+ when Qpid::Proton::Delivery::MODIFIED then delegate(:on_modified, event)
+ end
+ delegate(:on_settled, event) if t.settled?
+ t.settle if @opts[:auto_settle]
+ end
+ end
+ end
+
+ def on_link_flow(event)
+ add_credit(event)
+ l = event.link
+ delegate(:on_sendable, event) if l.sender? && l.open? && l.credit > 0
+ end
+
+ def add_credit(event)
+ r = event.receiver
+ prefetch = @opts[:prefetch]
+ if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
+ r.flow(prefetch - r.credit)
+ end
+ end
+ end
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/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 3af6d39..2d93454 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -93,18 +93,13 @@ require "messenger/messenger"
# Handler classes
require "handler/adapter"
+require "handler/old_messaging_adapter"
# Core classes that depend on Handler
require "core/messaging_handler"
require "core/container"
require "core/connection_driver"
# Backwards compatibility shims
-
require "reactor/container"
-
-module Qpid::Proton::Handler
- # @deprecated alias for backwards compatibility
- MessagingHandler = Qpid::Proton::MessagingHandler
-end
-
+require "handler/messaging_handler"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cf4a3f6c/proton-c/bindings/ruby/tests/test_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_adapter.rb b/proton-c/bindings/ruby/tests/test_adapter.rb
index c90f788..50f46c3 100644
--- a/proton-c/bindings/ruby/tests/test_adapter.rb
+++ b/proton-c/bindings/ruby/tests/test_adapter.rb
@@ -21,25 +21,25 @@ require 'qpid_proton'
require 'test_tools'
include Qpid::Proton
-# Tests with Mock handler that handles all methods.
-class TestAllHandler < Minitest::Test
-
- class AllHandler < MessagingHandler
- def initialize(*args)
- super(*args)
- @calls = []
- end
+# Records every call
+class AllHandler < MessagingHandler
+ def initialize(*args)
+ super(*args)
+ @calls = []
+ end
- attr_accessor :calls
+ attr_accessor :calls
- def names; @calls.map { |c| c[0] }; end
- def events; @calls.map { |c| c[1] }; end
+ def names; @calls.map { |c| c[0] }; end
+ def events; @calls.map { |c| c[1] }; end
- def method_missing(name, *args) (/^on_/ =~ name) ? (@calls << [name] + args) : super; end
- def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
- def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
- end
+ def method_missing(name, *args) (/^on_/ =~ name) ? (@calls << [name] + args) : super; end
+ def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
+end
+# Tests with Mock handler that handles all methods, expect both old and new calls
+class TestOldHandler < Minitest::Test
def setup
@h = [AllHandler.new, AllHandler.new]
@ch, @sh = *@h
@@ -158,7 +158,7 @@ class TestAllHandler < Minitest::Test
end
# Test with real handlers that implement a few methods
-class TestUnhandled < Minitest::Test
+class TestOldUnhandled < Minitest::Test
def test_message
handler_class = Class.new(MessagingHandler) do
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[33/50] [abbrv] qpid-proton git commit: PROTON-1721 [ruby] resovler
errors are not handled correctly
Posted by ac...@apache.org.
PROTON-1721 [ruby] resovler errors are not handled correctly
Catch exceptions raised by TCPServer.new/TCPSocket.new and convert into error events.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c4d5fde7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c4d5fde7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c4d5fde7
Branch: refs/heads/go1
Commit: c4d5fde71d925f3f44b0e29d672de7b039ee709f
Parents: f252b2f
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 15 11:34:44 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 16:59:23 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/container.rb | 26 +++++++++++++++++++--
proton-c/bindings/ruby/tests/test_container.rb | 14 +++++++++--
2 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c4d5fde7/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 242356f..5dc9d60 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -41,6 +41,18 @@ module Qpid::Proton
end
end
+ # Used as the @io when a socket cannot be created due to an erro (e.g resolver fails)
+ # Saves the error and raises it in on_readable so it can be reported via normal channels.
+ class BrokenSocket
+ def initialize(msg) @error = IOError.new(msg); end
+ [:read_nonblock, :write_nonblock, :accept].each do |m|
+ define_method(m) { |*args| raise @error }
+ end
+ [:close_read, :close_write, :close].each do |m|
+ define_method(m) {}
+ end
+ end
+
class ListenTask < Listener
def initialize(io, handler, container)
@@ -177,7 +189,12 @@ module Qpid::Proton
opts[:password] ||= url.password
end
# TODO aconway 2017-10-26: Use SSL for amqps URLs
- connect_io(TCPSocket.new(url.host, url.port), opts)
+ socket = begin
+ TCPSocket.new(url.host, url.port)
+ rescue => e
+ BrokenSocket.new("connect(#{url}): #{e}")
+ end
+ connect_io(socket, opts)
end
# Open an AMQP protocol connection on an existing {IO} object
@@ -202,7 +219,12 @@ module Qpid::Proton
not_stopped
url = Qpid::Proton::uri url
# TODO aconway 2017-11-01: amqps, SSL
- listen_io(TCPServer.new(url.host, url.port), handler)
+ server = begin
+ TCPServer.new(url.host, url.port)
+ rescue => e
+ BrokenSocket.new("listen(#{url}): #{e}")
+ end
+ listen_io(server, handler)
end
# Listen for incoming AMQP connections on an existing server socket.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c4d5fde7/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index 044ebf4..d8bd52c 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -149,6 +149,16 @@ class ContainerTest < Minitest::Test
assert_nil l.condition
assert_nil conn.condition
end
+
+ def test_bad_host
+ cont = Container.new(__method__)
+ l = cont.listen("badlisten.example.com:999")
+ c = cont.connect("badconnect.example.com:999")
+ cont.run
+ assert_match(/badlisten.example.com:999/, l.condition.description)
+ assert_match(/badconnect.example.com:999/, c.transport.condition.description)
+ end
+
end
@@ -201,8 +211,8 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
")
end
# Tell proton library to use the new configuration
- SASL.config_path(conf_dir)
- SASL.config_name(conf_name)
+ SASL.config_path = conf_dir
+ SASL.config_name = conf_name
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[37/50] [abbrv] qpid-proton git commit: PROTON-1720: [ruby] Add
ssl_domain connection option to enable SSL
Posted by ac...@apache.org.
PROTON-1720: [ruby] Add ssl_domain connection option to enable SSL
Added ssl_send to illustrate client use and updated broker.rb
to illustrate server use.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/bf8d90e1
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bf8d90e1
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bf8d90e1
Branch: refs/heads/go1
Commit: bf8d90e131b32b9c78cb1dfbf88f63cb5116cb68
Parents: 813aa43
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 18 17:37:24 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Dec 18 17:37:24 2017 -0500
----------------------------------------------------------------------
examples/ruby/broker.rb | 18 ++++-
examples/ruby/example_test.rb | 7 ++
examples/ruby/ssl_certs/README.txt | 24 +++++++
examples/ruby/ssl_certs/tclient-certificate.p12 | Bin 0 -> 1032 bytes
examples/ruby/ssl_certs/tclient-certificate.pem | 19 +++++
examples/ruby/ssl_certs/tclient-full.p12 | Bin 0 -> 2476 bytes
examples/ruby/ssl_certs/tclient-private-key.pem | 30 ++++++++
examples/ruby/ssl_certs/tserver-certificate.p12 | Bin 0 -> 1032 bytes
examples/ruby/ssl_certs/tserver-certificate.pem | 19 +++++
examples/ruby/ssl_certs/tserver-full.p12 | Bin 0 -> 2476 bytes
examples/ruby/ssl_certs/tserver-private-key.pem | 30 ++++++++
examples/ruby/ssl_send.rb | 70 +++++++++++++++++++
proton-c/bindings/ruby/lib/core/connection.rb | 2 +
proton-c/bindings/ruby/lib/core/container.rb | 4 +-
proton-c/bindings/ruby/lib/core/ssl.rb | 3 +-
proton-c/bindings/ruby/lib/core/transport.rb | 3 +-
16 files changed, 222 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/broker.rb b/examples/ruby/broker.rb
index 9595e2f..b28ca76 100644
--- a/examples/ruby/broker.rb
+++ b/examples/ruby/broker.rb
@@ -75,11 +75,25 @@ class Broker < Qpid::Proton::MessagingHandler
super()
@url = url
@queues = {}
+ begin # Optional SSL setup, ignore if we don't find cert files etc.
+ @ssl_domain = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_SERVER)
+ cert_passsword = "tserverpw"
+ if Gem.win_platform? # Use P12 certs for windows schannel
+ @ssl_domain.credentials("ssl_certs/tserver-certificate.p12", "", cert_passsword)
+ else
+ @ssl_domain.credentials("ssl_certs/tserver-certificate.pem", "ssl_certs/tserver-private-key.pem", cert_passsword)
+ end
+ @ssl_domain.allow_unsecured_client # SSL is optional, this is not secure.
+ rescue
+ # Don't worry if we can't set up SSL.
+ end
end
def on_container_start(container)
- @listener = container.listen(@url)
- STDOUT.puts "Listening on #{@url}"; STDOUT.flush
+ # Options for incoming connections, provide SSL configuration if we have it.
+ opts = {:ssl_domain => @ssl_domain} if @ssl_domain
+ @listener = container.listen(@url, Qpid::Proton::Listener::Handler.new(opts))
+ STDOUT.puts "Listening on #{@url.inspect}"; STDOUT.flush
end
def queue(address)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/example_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/example_test.rb b/examples/ruby/example_test.rb
index dc31a18..e19855d 100755
--- a/examples/ruby/example_test.rb
+++ b/examples/ruby/example_test.rb
@@ -65,6 +65,13 @@ EOS
assert_output(want.strip, "simple_recv.rb", $url, __method__)
end
+ def test_ssl_send_recv
+ out = run_script("ssl_send.rb", $url, __method__).read.strip
+ assert_match(/Connection secured with "...*\"\nAll 10 messages confirmed!/, out)
+ want = (0..9).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+ assert_output(want.strip, "simple_recv.rb", $url, __method__)
+ end
+
def test_direct_recv
url = test_url
p = run_script("direct_recv.rb", url, __method__)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/README.txt
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/README.txt b/examples/ruby/ssl_certs/README.txt
new file mode 100644
index 0000000..9a8a4f9
--- /dev/null
+++ b/examples/ruby/ssl_certs/README.txt
@@ -0,0 +1,24 @@
+This directory contains basic self signed test certificates for use by
+proton examples.
+
+The ".pem" files are in the format expected by proton implementations
+using OpenSSL. The ".p12" file are for Windows implementations using
+SChannel.
+
+The commands used to generate the certificates follow.
+
+
+make_pn_cert()
+{
+ name=$1
+ subject=$2
+ passwd=$3
+ # create the pem files
+ openssl req -newkey rsa:2048 -keyout $name-private-key.pem -out $name-certificate.pem -subj $subject -passout pass:$passwd -x509 -days 3650
+ # create the p12 files
+ openssl pkcs12 -export -out $name-full.p12 -passin pass:$passwd -passout pass:$passwd -inkey $name-private-key.pem -in $name-certificate.pem -name $name
+ openssl pkcs12 -export -out $name-certificate.p12 -in $name-certificate.pem -name $name -nokeys -passout pass:
+}
+
+make_pn_cert tserver /CN=test_server/OU=proton_test tserverpw
+make_pn_cert tclient /CN=test_client/OU=proton_test tclientpw
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tclient-certificate.p12
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tclient-certificate.p12 b/examples/ruby/ssl_certs/tclient-certificate.p12
new file mode 100644
index 0000000..4d0e000
Binary files /dev/null and b/examples/ruby/ssl_certs/tclient-certificate.p12 differ
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tclient-certificate.pem
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tclient-certificate.pem b/examples/ruby/ssl_certs/tclient-certificate.pem
new file mode 100644
index 0000000..8088e2e
--- /dev/null
+++ b/examples/ruby/ssl_certs/tclient-certificate.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKzCCAhOgAwIBAgIJAIV7frIjftgcMA0GCSqGSIb3DQEBCwUAMCwxFDASBgNV
+BAMMC3Rlc3RfY2xpZW50MRQwEgYDVQQLDAtwcm90b25fdGVzdDAeFw0xNTExMjcx
+ODEwMzlaFw0yNTExMjQxODEwMzlaMCwxFDASBgNVBAMMC3Rlc3RfY2xpZW50MRQw
+EgYDVQQLDAtwcm90b25fdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAPCIS4qUdOtQplUxZ6WW0LXcvosqFP6qOiCARLSEWpR3B8bq213rzefwwfcM
+4TtMr88bP+huLKmlyMfwpl8yB88eXkscPgaAce2zk24urWkFXKSQ6GPitWBLGqBa
+V+W0wJ4mfW7MwefVslWfGXI381QEUlBHjkFG30AtzMMTRj2GK2JqUlRXZPljGyB7
+WcXwxcoS+HkKV7FtHWSkLAzyXwQ9vsCUEYdWTUaGXfCUNRSRV7h1LIANbu03NxV0
+XdEl7WXcr7tuTw3axeUGhRFVhLegrxKLuZTTno4aAJnEr8uaDzjxvXnv3Ne2igvy
+gRfZgOMx+XrZEob9OpAoRghQt4cCAwEAAaNQME4wHQYDVR0OBBYEFE4vbyiM0RjG
+TLMLLGGhMZE/5x1GMB8GA1UdIwQYMBaAFE4vbyiM0RjGTLMLLGGhMZE/5x1GMAwG
+A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAErr/rvLS9Ig0UCMwh1J1lA9
+/gvXf93iIK/SjrFIAqYRmfZxg4husfoes8t2hFUeuqoH05TuSOoXG8p8DpgTSGmF
+jAFe+T90vJZTm0oqZkkkI/hdzjGQoHURRp9/O2Z/lm39KSKGVAN5pUWCUDi/G5iS
+P9LZPJN6a5syXMrR6x62IPxAXowlpXkRghKClF3zPOaOBTzT1V27EkI8IEgC+p45
+246EooLnw8ibB+ucNc3KHNzpgKGVd/622+I+Q5eg9AT9PLFttP+R2ECsrVDDPYuA
+p0qaSnwgeozj/d6K3FOgKKEKbzBmpWgkv0jdcVk18aPMHypI/RDtZ/+3ET2Ksi8=
+-----END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tclient-full.p12
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tclient-full.p12 b/examples/ruby/ssl_certs/tclient-full.p12
new file mode 100644
index 0000000..ad2d7d3
Binary files /dev/null and b/examples/ruby/ssl_certs/tclient-full.p12 differ
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tclient-private-key.pem
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tclient-private-key.pem b/examples/ruby/ssl_certs/tclient-private-key.pem
new file mode 100644
index 0000000..e5c114d
--- /dev/null
+++ b/examples/ruby/ssl_certs/tclient-private-key.pem
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQICy6ghWp45z4CAggA
+MBQGCCqGSIb3DQMHBAiVdDoo4NIghQSCBMixGm1bm/omMxsaKnIPO7zm5dyLexJ+
+yTFpmh2KV7kQqmpzCyIOdoG6K8YqFnie2XdFWm3S8faRHoMq54bDmyEWIxfQPq5f
+I1iYFbIZkbnhUvK53RActsEUMf0locS4xylU7VQK3XTAwp0TVip3Lp3ehEMEdcXL
+iUWibGsoTPKcY9MIWGXZAJXsEXoeHt6k2hHo1G4E0/Bi6mLW1LY/cxZCjHTGD6qI
+Kt54SCCDvinqVa+rixw6yX9F14EA6bhALami8e+Ccd3lqHOyYlXcBaSS1ezCg6ig
+oNK97mC+gEGy1KlkZDKWXclFoOCBXRBe4DByre6Rlq3yeI9L42bvAuSBSmf5QT5g
+73Yl8vjEAKR65awBT09dPuKu7t+Fb6vkwF8/t+uyj9IuL+42UuXhMLK3ohf+6DbU
+8/zB4y3GXI80QmWM0+Wx4n6khFhPFLHt2q0Sn6V9PG1vtHyiq50oSCoyrPQLaecp
+hefnMCFBYTcT3JUwmoVGGy0boIAwL7T4aGsMt7QhwOx5tU35tKFxyY7m4fX14AKo
+2EIy+TPQwCGkGf3Puy/Pc9VA8IAxB5+WwSrjk+NeCv88eIX7gy43k4rCr+OmD9FF
+wknr3xoP3KYhNXjdZ4Ep/1UHSK+JAtzzbNLQjDcqN+gQPg/yUX6ih0j5K3Wvh9bK
+E/DvzbpJroUZPgzR+8z5O68CfsD+OIdpHBFTKqAFmzvUuqpADpr998LdCjD+lW+V
+xZZgZa8KEblwgiH3fdGbYl46Ho1zrZisf439DbqyybAuBIQB4NSZcL/MAgVGO17k
+QDpVElWZWYrFm4CFTcvS2HvIzRmbefF5m5oJedsN7Q6WQCp+3gnwYx1xIOknd7pW
+N4AHNnqjscSj9yACj/EiBVKAKNnC5H7ZGZTsaAjMETZyjLXfI2AZ3Fviz4zFR+oz
+NkAfFB6WUpRpl7H02FzrzYT7XkkLcXd6H6g+mv2iDa9uKWk/PS2QlqnJt8/dHEHD
+JKTG331yDK5GHlKAVGF3nP5BwFGgTQMuSoeiOervMXPUwDpQ8OaYkuaRej0cZLgT
+kAF9sUjqdsoYNcXDFHALp6y5g8qYkfrxrlIbKs82zIsmB5I+dtZbUaD3a0zAUrmW
+5Xm3Pc9dVP0EXKwfHz6zqPReEw2yYLisB5IoHd4M2wa3GzHBdra1ij4QTmvd3o7e
+buGFoX8KJQAcig0zpbYkoDP2gPhIh9rY4unVPQNX1Q8/wRsiJAZZsYvZY+A+SmuZ
+bwSwk+8ZJRsFzdYYYhQeRytD5cDAIQiClcI5Yj4T9dWQV/gf0N/wIBDNTMp0jJAy
+1l7PuXTfGZodNJWZH0oqsrNoWbn/k67NildvvofIKX+h09Nxszr670Pvj0qoHd5/
+CWq30lnxoJBUgbikFOz6ZuuHi/ZiCXL+haH+v8hJKN5ptRKnyYJQHchRB/IOGRoT
+5lmWxo8a7K+yXhp0VBDHJfw3685ms0xQX8Xj4X3MEuN64zd0fB1JmhtP12ydK85J
+ABawNKlRQPw5weckwtCviXQX+vX25S/xu3xA6IuqlHyqL/1t3DICzuxeOyT2mZxD
+tKQxEgNihPvu32vn9m74qA3adEaxuWPRkPZuTeITHOkMTZolvqYX/5olBsSgYwka
+7/g=
+-----END ENCRYPTED PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tserver-certificate.p12
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tserver-certificate.p12 b/examples/ruby/ssl_certs/tserver-certificate.p12
new file mode 100644
index 0000000..f38b67d
Binary files /dev/null and b/examples/ruby/ssl_certs/tserver-certificate.p12 differ
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tserver-certificate.pem
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tserver-certificate.pem b/examples/ruby/ssl_certs/tserver-certificate.pem
new file mode 100644
index 0000000..86231f3
--- /dev/null
+++ b/examples/ruby/ssl_certs/tserver-certificate.pem
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKzCCAhOgAwIBAgIJAPnYOOQCJ3kDMA0GCSqGSIb3DQEBCwUAMCwxFDASBgNV
+BAMMC3Rlc3Rfc2VydmVyMRQwEgYDVQQLDAtwcm90b25fdGVzdDAeFw0xNTExMjcx
+ODEwMzlaFw0yNTExMjQxODEwMzlaMCwxFDASBgNVBAMMC3Rlc3Rfc2VydmVyMRQw
+EgYDVQQLDAtwcm90b25fdGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
+ggEBAKJNB78lgw4KtXDAvXocTLud6mbn6zgfB6ETIF+kcrukOH9DnPxjLBBM4Lig
+sp1+kmeudFK5/X8riDrvIW52b/rlEBLgLB+oDtI74m6OTbBs9L+FUFYOuxApetQF
+qoJy2vf9pWfy4uku24vCpeo7eVLi6ypu4lXE3LR+Km3FruHI1NKonHBMhwXSOWqF
+pYM6/4IZJ4fbV0+eU0Jrx+05s6XHg5vone2BVJKxeSIBje+zWnNnh8+qG0Z70Jgp
+aMetME5KGnLNgD1okpH0vb3lwjvuqkkx4WswGVZGbLLkSqqBpXPyM9fCFVy5aKSL
+DBq7IABQtO67O2nBzK3OyigHrUUCAwEAAaNQME4wHQYDVR0OBBYEFGV1PY0FCFbJ
+gpcDVKI6JGiRTt3kMB8GA1UdIwQYMBaAFGV1PY0FCFbJgpcDVKI6JGiRTt3kMAwG
+A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAIx1TOTGWnnbpan4bse7wuvH
+GYSNDJhoTVS+X1TC63xukJD1JBAsCNTqg/ZV6lN3XEl7vvOXfGoCiyXM6a9XOKUo
+gSDtMrIr+wTh6Ss1yRO8QcCJmxH5JDXNu1ojtwsjFW/vneI4IL9kwpDsSlMQEX/E
+EkkQwtAx/Cvfe7pecZL4qSeykJOUMTts9H8fCAZqEiRZBA3ugJxqF8jwLP3DoFVQ
+6QZzKDY6CSPqfMnVb5i0MAIYVDpau+e3N9dgQpZD22F/zbua0OVbfAPdiRMnYxML
+FT4sxLnh+5YVqwpVWbEKp4onHe2Fq6YIvAxUYAJ3SBA2C8O2RAVKWxf1jko3jYI=
+-----END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tserver-full.p12
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tserver-full.p12 b/examples/ruby/ssl_certs/tserver-full.p12
new file mode 100644
index 0000000..d4a0e40
Binary files /dev/null and b/examples/ruby/ssl_certs/tserver-full.p12 differ
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_certs/tserver-private-key.pem
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_certs/tserver-private-key.pem b/examples/ruby/ssl_certs/tserver-private-key.pem
new file mode 100644
index 0000000..91dcf0e
--- /dev/null
+++ b/examples/ruby/ssl_certs/tserver-private-key.pem
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI1cT0c2J3GcQCAggA
+MBQGCCqGSIb3DQMHBAi1hxSX2LJ+EgSCBMheHJ0iXr5A36Natjk/LcAEeKUMT9s+
+sMzoQceCWe8qMlQluWksr9iDdZ4JRIE8cpK8dbmx4dLY/SShUzdlhJHCSa4zZBHq
+8cZ/jGUF/RF1rqdgjK589eUq+uOl3/gXKzG/SxBqayy6PSn12kX3qnvmlkXCmtwU
+lg+iBm5wRcJ0MyVHaJkyA8sW8gr186C/VAau6Yu0crQXN7NRo9snrd4ewuYMIEhZ
+hgaG9XsYQWB1bPhAaKj80CZGxsQbJyTwcbKKkB3IY4WXx8mmhuiNl+vKT3HBJ9Ju
+YB6tgIjs8CJ4X2P4aU3yNJwG1QldgHSqmFGQ19bcZAw3s3kzwjdzRf4H2V16XOBd
+zQ5AEs/ffVMzMIAfkb1gYwgunZ2CVwwDJ2mi1RcgkX+Og2aFQc+fxXcVOnDcGLxV
+6fuCuZ2lsXfoiIyRh9kj3L75N12GtVUvgBdnMuOc1wPw6XnGQtDwt0acJpdexLMG
+k0j57r/gcgzTcmF3qNM+y9L/HLssgrJkvVJw2Np5gmtIyfDocsDUWUbClS4dTpYf
+oTngUTU+vWtHBuaUnb+f5/WJaRS/S7mmR8usbVG3i9WnEr/vlPJpbJFSjW2S6u/H
+7cFxKUmmBZsSuEv/EKt9a+Sh62kprOChm4myqfCI1/gvNKfUZC6m0Vp8zf+2LgAq
+2RgbMuqysMjWUtV4kDRZT7oCYckUDwsCHdbLES3nmVrtBk2ShMKHBpDp8/GoRuiV
+jdV7/EjKM/M1kXtFYYe3z7Mxv++lKYIJ7bNwVrQ8nrhce/VwHw6D5emWXNCJXhKZ
+FW7EM2ZOZ9eaKOlCsIi8sbjV6Yie9IY6HJKKmi3CpO0Tv5kLBdHkru8vGCSFm3O1
+n7wz7Ys5FBSlZ19X0NwQSCQX1Q4w+tido6i1SCRX0qJEdTNGuGwVXMHCf4/1zyHV
+hj8vnxh8fzo79LFrwlTTgwLg1Mr8sEUFFDJ/raJ1AhFXi8n24trtNR8EHxRW8wtD
+CLCKaqkEqfBiFXK/Yq3RrefCayPHiD+DaNsI8BwefMGpED3vD8YYCjAzXNPh/CSF
+sc1i1jWMzbJhzOoFSPNXhlfusbUFMFQ/6olatmH47SY6HBBOL3DDP5uQ0jw8P454
+QBjlMOpEZmZxO6TcEtJwu0vzgog4rQ5g3NWy6SIpjWehNwTynLt7yM3R5WTI6cZs
+0GTv/rqo2/SUoNsFmnGIUwj/DrBe4XOAq1nS2ZlEctxKhBsKH0hMFp6D1rXOzrgl
+bwcq+oistoB0TLcThShyNgSqzW1znQ1n5SVUk9b5rRhSttJxn3yOMewH0i3v8bPo
+HOhP5kaGjblPsCYyhlL/SNVF0OXEGTwLNey7FQdWFOwVwTRRXe7k+uGZ2d5hg+Jn
+It/trDZ1RDYbVmB7/Qy73c16J4mvhOUJ2de5ZciFBjkidbiiUKLj9xnjK9k9Sauo
+MKhNnDMAEU5VDQM3xNe5BRdX8dFLwfF5H64sU3nROF83aUnDgvfFEowYPnCuPYfm
+m4aQHfoBSg4j3v1OeOwktcl+Q2TjxPHfWhbWeRBfxOTqQ/suYhnQChuFSK/qyo9K
+ccgotqghhunRsWMoZT25H7AZM6yKb1sMz/0oyMRIKeGqoYh+ULM5XLY0xNYd4/xU
+WtQ=
+-----END ENCRYPTED PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/examples/ruby/ssl_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/ssl_send.rb b/examples/ruby/ssl_send.rb
new file mode 100644
index 0000000..4ff5da6
--- /dev/null
+++ b/examples/ruby/ssl_send.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.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class SimpleSend < Qpid::Proton::MessagingHandler
+
+ def initialize(url, address, expected)
+ super()
+ @url = url
+ @address = address
+ @sent = 0
+ @confirmed = 0
+ @expected = expected
+ end
+
+ def on_container_start(container)
+ # Use a default client SSL domain
+ ssl_domain = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_CLIENT)
+ c = container.connect(@url, { :ssl_domain => ssl_domain })
+ c.open_sender(@address)
+ end
+
+ def on_connection_open(c)
+ raise "No security!" unless c.transport.ssl?
+ STDOUT.puts "Connection secured with #{c.transport.ssl.protocol_name.inspect}"
+ end
+
+ def on_sendable(sender)
+ while sender.credit > 0 && @sent < @expected
+ msg = Qpid::Proton::Message.new("sequence #{@sent}", { :id => @sent } )
+ sender.send(msg)
+ @sent = @sent + 1
+ end
+ end
+
+ def on_tracker_accept(tracker)
+ @confirmed = @confirmed + 1
+ if @confirmed == @expected
+ puts "All #{@expected} messages confirmed!"
+ tracker.connection.close
+ end
+ end
+end
+
+unless (2..3).include? ARGV.size
+ STDERR.puts "Usage: #{__FILE__} URL ADDRESS [COUNT]}
+Connect to URL and send COUNT messages to ADDRESS"
+ return 1
+end
+url, address, count = ARGV
+count = Integer(count || 10)
+Qpid::Proton::Container.new(SimpleSend.new(url, address, count)).run
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/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 e71e69b..b94eaff 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -114,6 +114,8 @@ module Qpid::Proton
# @option opts [Boolean] :sasl_allow_insecure_mechs (false) Allow mechanisms send secrets in clear text
# @option opts [String] :sasl_allowed_mechs SASL mechanisms allowed by this end of the connection
#
+ # @option opts [SSLDomain] :ssl_domain SSL configuration domain.
+ #
def open(opts=nil)
return if local_active?
apply opts if opts
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/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 9d9463e..e16323b 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -184,12 +184,12 @@ module Qpid::Proton
def connect(url, opts=nil)
not_stopped
url = Qpid::Proton::uri url
+ opts ||= {}
if url.user || url.password
- opts ||= {}
opts[:user] ||= url.user
opts[:password] ||= url.password
end
- # TODO aconway 2017-10-26: Use SSL for amqps URLs
+ opts[:ssl_domain] ||= SSLDomain.new(SSLDomain::MODE_CLIENT) if url.scheme == "amqps"
socket = begin
TCPSocket.new(url.host, url.port)
rescue => e
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/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 bc4460a..af442ba 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -128,8 +128,7 @@ module Qpid::Proton
#
def protocol_name
rc, name = Cproton.pn_ssl_get_protocol_name(@impl, 128)
- retur name if rc
- nil
+ name if rc
end
# Checks whether or not the state has resumed.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bf8d90e1/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 eb5fb01..e629b0c 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -344,7 +344,7 @@ module Qpid::Proton
# @return [SSL] The SSL object.
#
def ssl(domain = nil, session_details = nil)
- @ssl ||= SSL.create(self, domain, session_details) if @ssl.nil?
+ @ssl ||= SSL.create(self, domain, session_details)
end
# @private
@@ -367,6 +367,7 @@ module Qpid::Proton
# The transport #idle_timeout property is in *milliseconds* passed direct to C.
# Direct use of the transport is deprecated.
self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? :idle_timeout
+ self.ssl(opts[:ssl_domain]) if opts[:ssl_domain]
end
can_raise_error :process, :error_class => TransportError
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[19/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby]
Simplified SWIG wrappers, use pn_inspect
Posted by ac...@apache.org.
PROTON-1537: [ruby] Simplified SWIG wrappers, use pn_inspect
Use pn_inspect as default inspect/to_s for all wrapped proton types.
Removed existing special case code to do the same thing.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/889c0c6d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/889c0c6d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/889c0c6d
Branch: refs/heads/go1
Commit: 889c0c6d1a3dec98a2d6e908392d6b6e20582c85
Parents: 3649b60
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 6 16:30:39 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:47 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/codec/data.rb | 1637 +++++++++----------
proton-c/bindings/ruby/lib/codec/mapping.rb | 7 +-
proton-c/bindings/ruby/lib/core/connection.rb | 16 +-
proton-c/bindings/ruby/lib/core/disposition.rb | 20 +-
proton-c/bindings/ruby/lib/core/event.rb | 3 +-
proton-c/bindings/ruby/lib/core/link.rb | 20 +-
proton-c/bindings/ruby/lib/core/message.rb | 28 +-
proton-c/bindings/ruby/lib/core/receiver.rb | 7 +-
proton-c/bindings/ruby/lib/core/sasl.rb | 6 +-
proton-c/bindings/ruby/lib/core/session.rb | 12 +-
proton-c/bindings/ruby/lib/core/ssl.rb | 6 +-
proton-c/bindings/ruby/lib/core/terminus.rb | 19 +-
proton-c/bindings/ruby/lib/core/transfer.rb | 6 +-
proton-c/bindings/ruby/lib/core/transport.rb | 26 +-
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 -
proton-c/bindings/ruby/lib/util/swig_helper.rb | 113 --
proton-c/bindings/ruby/lib/util/wrapper.rb | 95 +-
17 files changed, 947 insertions(+), 1075 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 f287d64..9814836 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -16,905 +16,898 @@
# under the License.
-module Qpid::Proton::Codec
-
- # +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,
- # #enter, and #exit methods to navigate to the desired location in
- # the tree and using the supplied variety of mutator and accessor
- # methods to access or add a value of the desired type.
- #
- # The mutator methods will always add a value _after_ the current node
- # in the tree. If the current node has a next sibling the mutator method
- # will overwrite the value on this node. If there is no current node
- # or the current node has no next sibling then one will be added. The
- # accessor methods always set the added/modified node to the current
- # node. The accessor methods read the value of the current node and do
- # not change which node is current.
- #
- # The following types of scalar values are supported:
- #
- # * NULL
- # * BOOL
- # * UBYTE
- # * BYTE
- # * USHORT
- # * SHORT
- # * UINT
- # * INT
- # * CHAR
- # * ULONG
- # * LONG
- # * TIMESTAMP
- # * FLOAT
- # * DOUBLE
- # * DECIMAL32
- # * DECIMAL64
- # * DECIMAL128
- # * UUID
- # * BINARY
- # * STRING
- # * SYMBOL
- #
- # The following types of compound values are supported:
- #
- # * DESCRIBED
- # * ARRAY
- # * LIST
- # * MAP
- #
- class Data
-
- private
-
- # Rewind and convert a pn_data_t* containing a single value to a ruby object.
- def self.to_object(impl) Data.new(impl).rewind.object; end
- # Clear a pn_data_t* and convert a ruby object into it.
- def self.from_object(impl, x) Data.new(impl).clear.object = x; end
-
- public
-
- # TODO aconway 2017-12-05: confusing: use Data.new(cap) for making a
- # brand new data object only, add Data.wrap(impl) to wrap existing data object.
-
- # Creates a new instance.
- # @param capacity [Integer] capacity for the new data instance.
- def initialize(capacity = 16)
- if capacity.is_a?(Integer)
- @data = Cproton.pn_data(capacity.to_i)
- @free = true
- else
- # Assume non-integer capacity is a SWIG::pn_data_t*
- @data = capacity
- @free = false
- end
-
- # destructor
- ObjectSpace.define_finalizer(self, self.class.finalize!(@data, @free))
- end
+module Qpid::Proton module Codec
+
+ # +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,
+ # #enter, and #exit methods to navigate to the desired location in
+ # the tree and using the supplied variety of mutator and accessor
+ # methods to access or add a value of the desired type.
+ #
+ # The mutator methods will always add a value _after_ the current node
+ # in the tree. If the current node has a next sibling the mutator method
+ # will overwrite the value on this node. If there is no current node
+ # or the current node has no next sibling then one will be added. The
+ # accessor methods always set the added/modified node to the current
+ # node. The accessor methods read the value of the current node and do
+ # not change which node is current.
+ #
+ # The following types of scalar values are supported:
+ #
+ # * NULL
+ # * BOOL
+ # * UBYTE
+ # * BYTE
+ # * USHORT
+ # * SHORT
+ # * UINT
+ # * INT
+ # * CHAR
+ # * ULONG
+ # * LONG
+ # * TIMESTAMP
+ # * FLOAT
+ # * DOUBLE
+ # * DECIMAL32
+ # * DECIMAL64
+ # * DECIMAL128
+ # * UUID
+ # * BINARY
+ # * STRING
+ # * SYMBOL
+ #
+ # The following types of compound values are supported:
+ #
+ # * DESCRIBED
+ # * ARRAY
+ # * LIST
+ # * MAP
+ #
+ class Data
+
+ # @private
+ PROTON_METHOD_PREFIX = "pn_disposition"
+ # @private
+ include Util::Wrapper
+
+ # Rewind and convert a pn_data_t* containing a single value to a ruby object.
+ def self.to_object(impl) Data.new(impl).rewind.object; end
+
+ # Clear a pn_data_t* and convert a ruby object into it.
+ def self.from_object(impl, x) Data.new(impl).clear.object = x; end
+
+ # @overload initialize(capacity)
+ # @param capacity [Integer] capacity for the new data instance.
+ # @overload instance(impl)
+ # @param impl [SWIG::pn_data_t*] wrap the C impl pointer.
+ def initialize(capacity = 16)
+ if capacity.is_a?(Integer)
+ @impl = Cproton.pn_data(capacity.to_i)
+ @free = true
+ else
+ # Assume non-integer capacity is a SWIG::pn_data_t*
+ @impl = capacity
+ @free = false
+ end
- # @private
- def self.finalize!(data, free)
- proc {
- Cproton.pn_data_free(data) if free
- }
- end
+ # destructor
+ ObjectSpace.define_finalizer(self, self.class.finalize!(@impl, @free))
+ end
- # @private
- def to_s
- tmp = Cproton.pn_string("")
- Cproton.pn_inspect(@data, tmp)
- result = Cproton.pn_string_get(tmp)
- Cproton.pn_free(tmp)
- return result
- end
+ # @private
+ def self.finalize!(impl, free)
+ proc {
+ Cproton.pn_data_free(impl) if free
+ }
+ end
- # Clears the object.
- #
- def clear
- Cproton.pn_data_clear(@data)
- self
- end
+ # Clears the object.
+ #
+ def clear
+ Cproton.pn_data_clear(@impl)
+ self
+ end
- # Clears the current node and sets the parent to the root node.
- #
- # Clearing the current node sets it *before* the first node, calling
- # #next will advance to the first node.
- #
- # @return self
- def rewind
- Cproton.pn_data_rewind(@data)
- self
- end
+ # Clears the current node and sets the parent to the root node.
+ #
+ # Clearing the current node sets it *before* the first node, calling
+ # #next will advance to the first node.
+ #
+ # @return self
+ def rewind
+ Cproton.pn_data_rewind(@impl)
+ self
+ end
- # Advances the current node to its next sibling and returns its types.
- #
- # If there is no next sibling the current node remains unchanged
- # and nil is returned.
- #
- def next
- Cproton.pn_data_next(@data)
- end
+ # Advances the current node to its next sibling and returns its types.
+ #
+ # If there is no next sibling the current node remains unchanged
+ # and nil is returned.
+ #
+ def next
+ Cproton.pn_data_next(@impl)
+ end
- # Advances the current node to its previous sibling and returns its type.
- #
- # If there is no previous sibling then the current node remains unchanged
- # and nil is return.
- #
- def prev
- return Cproton.pn_data_prev(@data) ? type : nil
- end
+ # Advances the current node to its previous sibling and returns its type.
+ #
+ # If there is no previous sibling then the current node remains unchanged
+ # and nil is return.
+ #
+ def prev
+ return Cproton.pn_data_prev(@impl) ? type : nil
+ end
- # Sets the parent node to the current node and clears the current node.
- #
- # Clearing the current node sets it _before_ the first child.
- #
- def enter
- Cproton.pn_data_enter(@data)
- end
+ # Sets the parent node to the current node and clears the current node.
+ #
+ # Clearing the current node sets it _before_ the first child.
+ #
+ def enter
+ Cproton.pn_data_enter(@impl)
+ end
- # Sets the current node to the parent node and the parent node to its own
- # parent.
- #
- def exit
- Cproton.pn_data_exit(@data)
- end
+ # Sets the current node to the parent node and the parent node to its own
+ # parent.
+ #
+ def exit
+ Cproton.pn_data_exit(@impl)
+ end
- # Returns the numeric type code of the current node.
- #
- # @return [Integer] The current node type.
- # @return [nil] If there is no current node.
- #
- def type_code
- dtype = Cproton.pn_data_type(@data)
- return (dtype == -1) ? nil : dtype
- end
+ # Returns the numeric type code of the current node.
+ #
+ # @return [Integer] The current node type.
+ # @return [nil] If there is no current node.
+ #
+ def type_code
+ dtype = Cproton.pn_data_type(@impl)
+ return (dtype == -1) ? nil : dtype
+ end
- # @return [Integer] The type object for the current node.
- # @see #type_code
- #
- def type
- Mapping.for_code(type_code)
- end
+ # @return [Integer] The type object for the current node.
+ # @see #type_code
+ #
+ def type
+ Mapping.for_code(type_code)
+ end
- # Returns a representation of the data encoded in AMQP format.
- #
- # @return [String] The context of the Data as an AMQP data string.
- #
- # @example
- #
- # @data.string = "This is a test."
- # @encoded = @data.encode
- #
- # # @encoded now contains the text "This is a test." encoded for
- # # AMQP transport.
- #
- def encode
- buffer = "\0"*1024
- loop do
- cd = Cproton.pn_data_encode(@data, buffer, buffer.length)
- if cd == Cproton::PN_OVERFLOW
- buffer *= 2
- elsif cd >= 0
- return buffer[0...cd]
- else
- check(cd)
+ # Returns a representation of the data encoded in AMQP format.
+ #
+ # @return [String] The context of the Data as an AMQP data string.
+ #
+ # @example
+ #
+ # @impl.string = "This is a test."
+ # @encoded = @impl.encode
+ #
+ # # @encoded now contains the text "This is a test." encoded for
+ # # AMQP transport.
+ #
+ def encode
+ buffer = "\0"*1024
+ loop do
+ cd = Cproton.pn_data_encode(@impl, buffer, buffer.length)
+ if cd == Cproton::PN_OVERFLOW
+ buffer *= 2
+ elsif cd >= 0
+ return buffer[0...cd]
+ else
+ check(cd)
+ end
end
end
- end
- # Decodes the first value from supplied AMQP data and returns the number
- # of bytes consumed.
- #
- # @param encoded [String] The encoded data.
- #
- # @example
- #
- # # SCENARIO: A string of encoded data, @encoded, contains the text
- # # of "This is a test." and is passed to an instance of Data
- # # for decoding.
- #
- # @data.decode(@encoded)
- # @data.string #=> "This is a test."
- #
- def decode(encoded)
- check(Cproton.pn_data_decode(@data, encoded, encoded.length))
- end
+ # Decodes the first value from supplied AMQP data and returns the number
+ # of bytes consumed.
+ #
+ # @param encoded [String] The encoded data.
+ #
+ # @example
+ #
+ # # SCENARIO: A string of encoded data, @encoded, contains the text
+ # # of "This is a test." and is passed to an instance of Data
+ # # for decoding.
+ #
+ # @impl.decode(@encoded)
+ # @impl.string #=> "This is a test."
+ #
+ def decode(encoded)
+ check(Cproton.pn_data_decode(@impl, encoded, encoded.length))
+ end
- # Puts a list value.
- #
- # Elements may be filled by entering the list node and putting element
- # values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_list
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- def put_list
- check(Cproton.pn_data_put_list(@data))
- end
+ # Puts a list value.
+ #
+ # Elements may be filled by entering the list node and putting element
+ # values.
+ #
+ # @example
+ #
+ # data = Qpid::Proton::Codec::Data.new
+ # data.put_list
+ # data.enter
+ # data.int = 1
+ # data.int = 2
+ # data.int = 3
+ # data.exit
+ #
+ def put_list
+ check(Cproton.pn_data_put_list(@impl))
+ end
- # If the current node is a list, this returns the number of elements.
- # Otherwise, it returns zero.
- #
- # List elements can be accessed by entering the list.
- #
- # @example
- #
- # count = @data.list
- # @data.enter
- # (0...count).each
- # type = @data.next
- # puts "Value: #{@data.string}" if type == STRING
- # # ... process other node types
- # end
- def list
- Cproton.pn_data_get_list(@data)
- end
+ # If the current node is a list, this returns the number of elements.
+ # Otherwise, it returns zero.
+ #
+ # List elements can be accessed by entering the list.
+ #
+ # @example
+ #
+ # count = @impl.list
+ # @impl.enter
+ # (0...count).each
+ # type = @impl.next
+ # puts "Value: #{@impl.string}" if type == STRING
+ # # ... process other node types
+ # end
+ def list
+ Cproton.pn_data_get_list(@impl)
+ end
- # Puts a map value.
- #
- # Elements may be filled by entering the map node and putting alternating
- # key/value pairs.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_map
- # data.enter
- # data.string = "key"
- # data.string = "value"
- # data.exit
- #
- def put_map
- check(Cproton.pn_data_put_map(@data))
- end
+ # Puts a map value.
+ #
+ # Elements may be filled by entering the map node and putting alternating
+ # key/value pairs.
+ #
+ # @example
+ #
+ # data = Qpid::Proton::Codec::Data.new
+ # data.put_map
+ # data.enter
+ # data.string = "key"
+ # data.string = "value"
+ # data.exit
+ #
+ def put_map
+ check(Cproton.pn_data_put_map(@impl))
+ end
- # If the current node is a map, this returns the number of child
- # elements. Otherwise, it returns zero.
- #
- # Key/value pairs can be accessed by entering the map.
- #
- # @example
- #
- # count = @data.map
- # @data.enter
- # (0...count).each do
- # type = @data.next
- # puts "Key=#{@data.string}" if type == STRING
- # # ... process other key types
- # type = @data.next
- # puts "Value=#{@data.string}" if type == STRING
- # # ... process other value types
- # end
- # @data.exit
- def map
- Cproton.pn_data_get_map(@data)
- end
+ # If the current node is a map, this returns the number of child
+ # elements. Otherwise, it returns zero.
+ #
+ # Key/value pairs can be accessed by entering the map.
+ #
+ # @example
+ #
+ # count = @impl.map
+ # @impl.enter
+ # (0...count).each do
+ # type = @impl.next
+ # puts "Key=#{@impl.string}" if type == STRING
+ # # ... process other key types
+ # type = @impl.next
+ # puts "Value=#{@impl.string}" if type == STRING
+ # # ... process other value types
+ # end
+ # @impl.exit
+ def map
+ Cproton.pn_data_get_map(@impl)
+ end
- # @private
- def get_map
- ::Hash.proton_data_get(self)
- end
+ # @private
+ def get_map
+ ::Hash.proton_data_get(self)
+ end
- # Puts an array value.
- #
- # Elements may be filled by entering the array node and putting the
- # element values. The values must all be of the specified array element
- # type.
- #
- # If an array is *described* then the first child value of the array
- # is the descriptor and may be of any type.
- #
- # @param described [Boolean] True if the array is described.
- # @param element_type [Integer] The AMQP type for each element of the array.
- #
- # @example
- #
- # # create an array of integer values
- # data = Qpid::Proton::Codec::Data.new
- # data.put_array(false, INT)
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- # # create a described array of double values
- # data.put_array(true, DOUBLE)
- # data.enter
- # data.symbol = "array-descriptor"
- # data.double = 1.1
- # data.double = 1.2
- # data.double = 1.3
- # data.exit
- #
- def put_array(described, element_type)
- check(Cproton.pn_data_put_array(@data, described, element_type.code))
- end
+ # Puts an array value.
+ #
+ # Elements may be filled by entering the array node and putting the
+ # element values. The values must all be of the specified array element
+ # type.
+ #
+ # If an array is *described* then the first child value of the array
+ # is the descriptor and may be of any type.
+ #
+ # @param described [Boolean] True if the array is described.
+ # @param element_type [Integer] The AMQP type for each element of the array.
+ #
+ # @example
+ #
+ # # create an array of integer values
+ # data = Qpid::Proton::Codec::Data.new
+ # data.put_array(false, INT)
+ # data.enter
+ # data.int = 1
+ # data.int = 2
+ # data.int = 3
+ # data.exit
+ #
+ # # create a described array of double values
+ # data.put_array(true, DOUBLE)
+ # data.enter
+ # data.symbol = "array-descriptor"
+ # data.double = 1.1
+ # data.double = 1.2
+ # data.double = 1.3
+ # data.exit
+ #
+ def put_array(described, element_type)
+ check(Cproton.pn_data_put_array(@impl, described, element_type.code))
+ end
- # If the current node is an array, returns a tuple of the element count, a
- # boolean indicating whether the array is described, and the type of each
- # element. Otherwise it returns +(0, false, nil).
- #
- # Array data can be accessed by entering the array.
- #
- # @example
- #
- # # get the details of thecurrent array
- # count, described, array_type = @data.array
- #
- # # enter the node
- # data.enter
- #
- # # get the next node
- # data.next
- # puts "Descriptor: #{data.symbol}" if described
- # (0...count).each do
- # @data.next
- # puts "Element: #{@data.string}"
- # end
- def array
- count = Cproton.pn_data_get_array(@data)
- described = Cproton.pn_data_is_array_described(@data)
- array_type = Cproton.pn_data_get_array_type(@data)
- return nil if array_type == -1
- [count, described, Mapping.for_code(array_type) ]
- end
+ # If the current node is an array, returns a tuple of the element count, a
+ # boolean indicating whether the array is described, and the type of each
+ # element. Otherwise it returns +(0, false, nil).
+ #
+ # Array data can be accessed by entering the array.
+ #
+ # @example
+ #
+ # # get the details of thecurrent array
+ # count, described, array_type = @impl.array
+ #
+ # # enter the node
+ # data.enter
+ #
+ # # get the next node
+ # data.next
+ # puts "Descriptor: #{data.symbol}" if described
+ # (0...count).each do
+ # @impl.next
+ # puts "Element: #{@impl.string}"
+ # end
+ def array
+ count = Cproton.pn_data_get_array(@impl)
+ described = Cproton.pn_data_is_array_described(@impl)
+ array_type = Cproton.pn_data_get_array_type(@impl)
+ return nil if array_type == -1
+ [count, described, Mapping.for_code(array_type) ]
+ end
- # @private
- def get_array
- ::Array.proton_get(self)
- end
+ # @private
+ def get_array
+ ::Array.proton_get(self)
+ end
- # Puts a described value.
- #
- # A described node has two children, the descriptor and the value.
- # These are specified by entering the node and putting the
- # desired values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_described
- # data.enter
- # data.symbol = "value-descriptor"
- # data.string = "the value"
- # data.exit
- #
- def put_described
- check(Cproton.pn_data_put_described(@data))
- end
+ # Puts a described value.
+ #
+ # A described node has two children, the descriptor and the value.
+ # These are specified by entering the node and putting the
+ # desired values.
+ #
+ # @example
+ #
+ # data = Qpid::Proton::Codec::Data.new
+ # data.put_described
+ # data.enter
+ # data.symbol = "value-descriptor"
+ # data.string = "the value"
+ # data.exit
+ #
+ def put_described
+ check(Cproton.pn_data_put_described(@impl))
+ end
- # @private
- def get_described
- raise TypeError, "not a described type" unless self.described?
- self.enter
- self.next
- type = self.type
- descriptor = type.get(self)
- self.next
- type = self.type
- value = type.get(self)
- self.exit
- Qpid::Proton::Types::Described.new(descriptor, value)
- end
+ # @private
+ def get_described
+ raise TypeError, "not a described type" unless self.described?
+ self.enter
+ self.next
+ type = self.type
+ descriptor = type.get(self)
+ self.next
+ type = self.type
+ value = type.get(self)
+ self.exit
+ Qpid::Proton::Types::Described.new(descriptor, value)
+ end
- # Checks if the current node is a described value.
- #
- # The described and value may be accessed by entering the described value.
- #
- # @example
- #
- # if @data.described?
- # @data.enter
- # puts "The symbol is #{@data.symbol}"
- # puts "The value is #{@data.string}"
- # end
- def described?
- Cproton.pn_data_is_described(@data)
- end
+ # Checks if the current node is a described value.
+ #
+ # The described and value may be accessed by entering the described value.
+ #
+ # @example
+ #
+ # if @impl.described?
+ # @impl.enter
+ # puts "The symbol is #{@impl.symbol}"
+ # puts "The value is #{@impl.string}"
+ # end
+ def described?
+ Cproton.pn_data_is_described(@impl)
+ end
- # Puts a null value.
- #
- def null
- check(Cproton.pn_data_put_null(@data))
- end
+ # Puts a null value.
+ #
+ def null
+ check(Cproton.pn_data_put_null(@impl))
+ end
- # Utility method for Qpid::Proton::Codec::Mapping
- #
- # @private
- #
- def null=(value)
- null
- end
+ # Utility method for Qpid::Proton::Codec::Mapping
+ #
+ # @private
+ #
+ def null=(value)
+ 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
+ # 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
+ # 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.
- #
- def null?
- Cproton.pn_data_is_null(@data)
- end
+ # Checks if the current node is null.
+ #
+ # @return [Boolean] True if the node is null.
+ #
+ def null?
+ Cproton.pn_data_is_null(@impl)
+ end
- # Puts a boolean value.
- #
- # @param value [Boolean] The boolean value.
- #
- def bool=(value)
- check(Cproton.pn_data_put_bool(@data, value))
- end
+ # Puts a boolean value.
+ #
+ # @param value [Boolean] The boolean value.
+ #
+ def bool=(value)
+ check(Cproton.pn_data_put_bool(@impl, value))
+ end
- # If the current node is a boolean, then it returns the value. Otherwise,
- # it returns false.
- #
- # @return [Boolean] The boolean value.
- #
- def bool
- Cproton.pn_data_get_bool(@data)
- end
+ # If the current node is a boolean, then it returns the value. Otherwise,
+ # it returns false.
+ #
+ # @return [Boolean] The boolean value.
+ #
+ def bool
+ Cproton.pn_data_get_bool(@impl)
+ end
- # Puts an unsigned byte value.
- #
- # @param value [Integer] The unsigned byte value.
- #
- def ubyte=(value)
- check(Cproton.pn_data_put_ubyte(@data, value))
- end
+ # Puts an unsigned byte value.
+ #
+ # @param value [Integer] The unsigned byte value.
+ #
+ def ubyte=(value)
+ check(Cproton.pn_data_put_ubyte(@impl, value))
+ end
- # If the current node is an unsigned byte, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Integer] The unsigned byte value.
- #
- def ubyte
- Cproton.pn_data_get_ubyte(@data)
- end
+ # If the current node is an unsigned byte, returns its value. Otherwise,
+ # it returns 0.
+ #
+ # @return [Integer] The unsigned byte value.
+ #
+ def ubyte
+ Cproton.pn_data_get_ubyte(@impl)
+ end
- # Puts a byte value.
- #
- # @param value [Integer] The byte value.
- #
- def byte=(value)
- check(Cproton.pn_data_put_byte(@data, value))
- end
+ # Puts a byte value.
+ #
+ # @param value [Integer] The byte value.
+ #
+ def byte=(value)
+ check(Cproton.pn_data_put_byte(@impl, value))
+ end
- # If the current node is an byte, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Integer] The byte value.
- #
- def byte
- Cproton.pn_data_get_byte(@data)
- end
+ # If the current node is an byte, returns its value. Otherwise,
+ # it returns 0.
+ #
+ # @return [Integer] The byte value.
+ #
+ def byte
+ Cproton.pn_data_get_byte(@impl)
+ end
- # Puts an unsigned short value.
- #
- # @param value [Integer] The unsigned short value
- #
- def ushort=(value)
- check(Cproton.pn_data_put_ushort(@data, value))
- end
+ # Puts an unsigned short value.
+ #
+ # @param value [Integer] The unsigned short value
+ #
+ def ushort=(value)
+ check(Cproton.pn_data_put_ushort(@impl, value))
+ end
- # If the current node is an unsigned short, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Integer] The unsigned short value.
- #
- def ushort
- Cproton.pn_data_get_ushort(@data)
- end
+ # If the current node is an unsigned short, returns its value. Otherwise,
+ # it returns 0.
+ #
+ # @return [Integer] The unsigned short value.
+ #
+ def ushort
+ Cproton.pn_data_get_ushort(@impl)
+ end
- # Puts a short value.
- #
- # @param value [Integer] The short value.
- #
- def short=(value)
- check(Cproton.pn_data_put_short(@data, value))
- end
+ # Puts a short value.
+ #
+ # @param value [Integer] The short value.
+ #
+ def short=(value)
+ check(Cproton.pn_data_put_short(@impl, value))
+ end
- # If the current node is a short, returns its value. Otherwise,
- # returns a 0.
- #
- # @return [Integer] The short value.
- #
- def short
- Cproton.pn_data_get_short(@data)
- end
+ # If the current node is a short, returns its value. Otherwise,
+ # returns a 0.
+ #
+ # @return [Integer] The short value.
+ #
+ def short
+ Cproton.pn_data_get_short(@impl)
+ end
- # Puts an unsigned integer value.
- #
- # @param value [Integer] the unsigned integer value
- #
- def uint=(value)
- raise TypeError if value.nil?
- raise RangeError, "invalid uint: #{value}" if value < 0
- check(Cproton.pn_data_put_uint(@data, value))
- end
+ # Puts an unsigned integer value.
+ #
+ # @param value [Integer] the unsigned integer value
+ #
+ def uint=(value)
+ raise TypeError if value.nil?
+ raise RangeError, "invalid uint: #{value}" if value < 0
+ check(Cproton.pn_data_put_uint(@impl, value))
+ end
- # If the current node is an unsigned int, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The unsigned integer value.
- #
- def uint
- Cproton.pn_data_get_uint(@data)
- end
+ # If the current node is an unsigned int, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The unsigned integer value.
+ #
+ def uint
+ Cproton.pn_data_get_uint(@impl)
+ end
- # Puts an integer value.
- #
- # ==== Options
- #
- # * value - the integer value
- def int=(value)
- check(Cproton.pn_data_put_int(@data, value))
- end
+ # Puts an integer value.
+ #
+ # ==== Options
+ #
+ # * value - the integer value
+ def int=(value)
+ check(Cproton.pn_data_put_int(@impl, value))
+ end
- # If the current node is an integer, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The integer value.
- #
- def int
- Cproton.pn_data_get_int(@data)
- end
+ # If the current node is an integer, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The integer value.
+ #
+ def int
+ Cproton.pn_data_get_int(@impl)
+ end
- # Puts a character value.
- #
- # @param value [Integer] The character value.
- #
- def char=(value)
- check(Cproton.pn_data_put_char(@data, value))
- end
+ # Puts a character value.
+ #
+ # @param value [Integer] The character value.
+ #
+ def char=(value)
+ check(Cproton.pn_data_put_char(@impl, value))
+ end
- # If the current node is a character, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The character value.
- #
- def char
- Cproton.pn_data_get_char(@data)
- end
+ # If the current node is a character, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The character value.
+ #
+ def char
+ Cproton.pn_data_get_char(@impl)
+ end
- # Puts an unsigned long value.
- #
- # @param value [Integer] The unsigned long value.
- #
- def ulong=(value)
- raise TypeError if value.nil?
- raise RangeError, "invalid ulong: #{value}" if value < 0
- check(Cproton.pn_data_put_ulong(@data, value))
- end
+ # Puts an unsigned long value.
+ #
+ # @param value [Integer] The unsigned long value.
+ #
+ def ulong=(value)
+ raise TypeError if value.nil?
+ raise RangeError, "invalid ulong: #{value}" if value < 0
+ check(Cproton.pn_data_put_ulong(@impl, value))
+ end
- # If the current node is an unsigned long, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The unsigned long value.
- #
- def ulong
- Cproton.pn_data_get_ulong(@data)
- end
+ # If the current node is an unsigned long, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The unsigned long value.
+ #
+ def ulong
+ Cproton.pn_data_get_ulong(@impl)
+ end
- # Puts a long value.
- #
- # @param value [Integer] The long value.
- #
- def long=(value)
- check(Cproton.pn_data_put_long(@data, value))
- end
+ # Puts a long value.
+ #
+ # @param value [Integer] The long value.
+ #
+ def long=(value)
+ check(Cproton.pn_data_put_long(@impl, value))
+ end
- # If the current node is a long, returns its value. Otherwise, returns 0.
- #
- # @return [Integer] The long value.
- def long
- Cproton.pn_data_get_long(@data)
- end
+ # If the current node is a long, returns its value. Otherwise, returns 0.
+ #
+ # @return [Integer] The long value.
+ def long
+ Cproton.pn_data_get_long(@impl)
+ end
- # Puts a timestamp value.
- #
- # @param value [Integer] The timestamp value.
- #
- def timestamp=(value)
- value = value.to_i if (!value.nil? && value.is_a?(Time))
- check(Cproton.pn_data_put_timestamp(@data, value))
- end
+ # Puts a timestamp value.
+ #
+ # @param value [Integer] The timestamp value.
+ #
+ def timestamp=(value)
+ value = value.to_i if (!value.nil? && value.is_a?(Time))
+ check(Cproton.pn_data_put_timestamp(@impl, value))
+ end
- # If the current node is a timestamp, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The timestamp value.
- #
- def timestamp
- Cproton.pn_data_get_timestamp(@data)
- end
+ # If the current node is a timestamp, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The timestamp value.
+ #
+ def timestamp
+ Cproton.pn_data_get_timestamp(@impl)
+ end
- # Puts a float value.
- #
- # @param value [Float] The floating point value.
- #
- def float=(value)
- check(Cproton.pn_data_put_float(@data, value))
- end
+ # Puts a float value.
+ #
+ # @param value [Float] The floating point value.
+ #
+ def float=(value)
+ check(Cproton.pn_data_put_float(@impl, value))
+ end
- # If the current node is a float, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Float] The floating point value.
- #
- def float
- Cproton.pn_data_get_float(@data)
- end
+ # If the current node is a float, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Float] The floating point value.
+ #
+ def float
+ Cproton.pn_data_get_float(@impl)
+ end
- # Puts a double value.
- #
- # @param value [Float] The double precision floating point value.
- #
- def double=(value)
- check(Cproton.pn_data_put_double(@data, value))
- end
+ # Puts a double value.
+ #
+ # @param value [Float] The double precision floating point value.
+ #
+ def double=(value)
+ check(Cproton.pn_data_put_double(@impl, value))
+ end
- # If the current node is a double, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Float] The double precision floating point value.
- #
- def double
- Cproton.pn_data_get_double(@data)
- end
+ # If the current node is a double, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Float] The double precision floating point value.
+ #
+ def double
+ Cproton.pn_data_get_double(@impl)
+ end
- # Puts a decimal32 value.
- #
- # @param value [Integer] The decimal32 value.
- #
- def decimal32=(value)
- check(Cproton.pn_data_put_decimal32(@data, value))
- end
+ # Puts a decimal32 value.
+ #
+ # @param value [Integer] The decimal32 value.
+ #
+ def decimal32=(value)
+ check(Cproton.pn_data_put_decimal32(@impl, value))
+ end
- # If the current node is a decimal32, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The decimal32 value.
- #
- def decimal32
- Cproton.pn_data_get_decimal32(@data)
- end
+ # If the current node is a decimal32, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The decimal32 value.
+ #
+ def decimal32
+ Cproton.pn_data_get_decimal32(@impl)
+ end
- # Puts a decimal64 value.
- #
- # @param value [Integer] The decimal64 value.
- #
- def decimal64=(value)
- check(Cproton.pn_data_put_decimal64(@data, value))
- end
+ # Puts a decimal64 value.
+ #
+ # @param value [Integer] The decimal64 value.
+ #
+ def decimal64=(value)
+ check(Cproton.pn_data_put_decimal64(@impl, value))
+ end
- # If the current node is a decimal64, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Integer] The decimal64 value.
- #
- def decimal64
- Cproton.pn_data_get_decimal64(@data)
- end
+ # If the current node is a decimal64, returns its value. Otherwise,
+ # it returns 0.
+ #
+ # @return [Integer] The decimal64 value.
+ #
+ def decimal64
+ Cproton.pn_data_get_decimal64(@impl)
+ end
- # Puts a decimal128 value.
- #
- # @param value [Integer] The decimal128 value.
- #
- def decimal128=(value)
- raise TypeError, "invalid decimal128 value: #{value}" if value.nil?
- value = value.to_s(16).rjust(32, "0")
- bytes = []
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
- check(Cproton.pn_data_put_decimal128(@data, bytes))
- end
+ # Puts a decimal128 value.
+ #
+ # @param value [Integer] The decimal128 value.
+ #
+ def decimal128=(value)
+ raise TypeError, "invalid decimal128 value: #{value}" if value.nil?
+ value = value.to_s(16).rjust(32, "0")
+ bytes = []
+ value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
+ check(Cproton.pn_data_put_decimal128(@impl, bytes))
+ end
- # If the current node is a decimal128, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Integer] The decimal128 value.
- #
- def decimal128
- value = ""
- Cproton.pn_data_get_decimal128(@data).each{|val| value += ("%02x" % val)}
- value.to_i(16)
- end
+ # If the current node is a decimal128, returns its value. Otherwise,
+ # returns 0.
+ #
+ # @return [Integer] The decimal128 value.
+ #
+ def decimal128
+ value = ""
+ Cproton.pn_data_get_decimal128(@impl).each{|val| value += ("%02x" % val)}
+ value.to_i(16)
+ end
- # Puts a +UUID+ value.
- #
- # The UUID is expected to be in the format of a string or else a 128-bit
- # integer value.
- #
- # @param value [String, Numeric] A string or numeric representation of the UUID.
- #
- # @example
- #
- # # set a uuid value from a string value
- # require 'securerandom'
- # @data.uuid = SecureRandom.uuid
- #
- # # or
- # @data.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
- #
- # # set a uuid value from a 128-bit value
- # @data.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000
- #
- def uuid=(value)
- raise ::ArgumentError, "invalid uuid: #{value}" if value.nil?
-
- # if the uuid that was submitted was numeric value, then translated
- # it into a hex string, otherwise assume it was a string represtation
- # and attempt to decode it
- if value.is_a? Numeric
- value = "%032x" % value
- else
- raise ::ArgumentError, "invalid uuid: #{value}" if !valid_uuid?(value)
-
- value = (value[0, 8] +
- value[9, 4] +
- value[14, 4] +
- value[19, 4] +
- value[24, 12])
- end
- bytes = []
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
- check(Cproton.pn_data_put_uuid(@data, bytes))
- end
+ # Puts a +UUID+ value.
+ #
+ # The UUID is expected to be in the format of a string or else a 128-bit
+ # integer value.
+ #
+ # @param value [String, Numeric] A string or numeric representation of the UUID.
+ #
+ # @example
+ #
+ # # set a uuid value from a string value
+ # require 'securerandom'
+ # @impl.uuid = SecureRandom.uuid
+ #
+ # # or
+ # @impl.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
+ #
+ # # set a uuid value from a 128-bit value
+ # @impl.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000
+ #
+ def uuid=(value)
+ raise ::ArgumentError, "invalid uuid: #{value}" if value.nil?
+
+ # if the uuid that was submitted was numeric value, then translated
+ # it into a hex string, otherwise assume it was a string represtation
+ # and attempt to decode it
+ if value.is_a? Numeric
+ value = "%032x" % value
+ else
+ raise ::ArgumentError, "invalid uuid: #{value}" if !valid_uuid?(value)
- # If the current value is a +UUID+, returns its value. Otherwise,
- # it returns nil.
- #
- # @return [String] The string representation of the UUID.
- #
- def uuid
- value = ""
- Cproton.pn_data_get_uuid(@data).each{|val| value += ("%02x" % val)}
- value.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
- end
+ value = (value[0, 8] +
+ value[9, 4] +
+ value[14, 4] +
+ value[19, 4] +
+ value[24, 12])
+ end
+ bytes = []
+ value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
+ check(Cproton.pn_data_put_uuid(@impl, bytes))
+ end
- # Puts a binary value.
- #
- # A binary string is encoded as an ASCII 8-bit string value. This is in
- # contranst to other strings, which are treated as UTF-8 encoded.
- #
- # @param value [String] An arbitrary string value.
- #
- # @see #string=
- #
- def binary=(value)
- check(Cproton.pn_data_put_binary(@data, value))
- end
+ # If the current value is a +UUID+, returns its value. Otherwise,
+ # it returns nil.
+ #
+ # @return [String] The string representation of the UUID.
+ #
+ def uuid
+ value = ""
+ Cproton.pn_data_get_uuid(@impl).each{|val| value += ("%02x" % val)}
+ value.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
+ end
- # If the current node is binary, returns its value. Otherwise, it returns
- # an empty string ("").
- #
- # @return [String] The binary string.
- #
- # @see #string
- #
- def binary
- Qpid::Proton::Types::BinaryString.new(Cproton.pn_data_get_binary(@data))
- end
+ # Puts a binary value.
+ #
+ # A binary string is encoded as an ASCII 8-bit string value. This is in
+ # contranst to other strings, which are treated as UTF-8 encoded.
+ #
+ # @param value [String] An arbitrary string value.
+ #
+ # @see #string=
+ #
+ def binary=(value)
+ check(Cproton.pn_data_put_binary(@impl, value))
+ end
- # Puts a UTF-8 encoded string value.
- #
- # *NOTE:* A nil value is stored as an empty string rather than as a nil.
- #
- # @param value [String] The UTF-8 encoded string value.
- #
- # @see #binary=
- #
- def string=(value)
- check(Cproton.pn_data_put_string(@data, value))
- end
+ # If the current node is binary, returns its value. Otherwise, it returns
+ # an empty string ("").
+ #
+ # @return [String] The binary string.
+ #
+ # @see #string
+ #
+ def binary
+ Qpid::Proton::Types::BinaryString.new(Cproton.pn_data_get_binary(@impl))
+ end
- # If the current node is a string, returns its value. Otherwise, it
- # returns an empty string ("").
- #
- # @return [String] The UTF-8 encoded string.
- #
- # @see #binary
- #
- def string
- Qpid::Proton::Types::UTFString.new(Cproton.pn_data_get_string(@data))
- end
+ # Puts a UTF-8 encoded string value.
+ #
+ # *NOTE:* A nil value is stored as an empty string rather than as a nil.
+ #
+ # @param value [String] The UTF-8 encoded string value.
+ #
+ # @see #binary=
+ #
+ def string=(value)
+ check(Cproton.pn_data_put_string(@impl, value))
+ end
- # Puts a symbolic value.
- #
- # @param value [String|Symbol] The symbolic string value.
- #
- def symbol=(value)
- check(Cproton.pn_data_put_symbol(@data, value.to_s))
- end
+ # If the current node is a string, returns its value. Otherwise, it
+ # returns an empty string ("").
+ #
+ # @return [String] The UTF-8 encoded string.
+ #
+ # @see #binary
+ #
+ def string
+ Qpid::Proton::Types::UTFString.new(Cproton.pn_data_get_string(@impl))
+ end
- # If the current node is a symbol, returns its value. Otherwise, it
- # returns an empty string ("").
- #
- # @return [String] The symbolic string value.
- #
- def symbol
- Cproton.pn_data_get_symbol(@data)
- end
+ # Puts a symbolic value.
+ #
+ # @param value [String|Symbol] The symbolic string value.
+ #
+ def symbol=(value)
+ check(Cproton.pn_data_put_symbol(@impl, value.to_s))
+ end
- # Get the current value as a single object.
- #
- # @return [Object] The current node's object.
- #
- # @see #type_code
- # @see #type
- #
- def get
- type.get(self);
- end
+ # If the current node is a symbol, returns its value. Otherwise, it
+ # returns an empty string ("").
+ #
+ # @return [String] The symbolic string value.
+ #
+ def symbol
+ Cproton.pn_data_get_symbol(@impl)
+ end
- # Puts a new value with the given type into the current node.
- #
- # @param value [Object] The value.
- # @param type_code [Mapping] The value's type.
- #
- # @private
- #
- def put(value, type_code);
- type_code.put(self, value);
- end
+ # Get the current value as a single object.
+ #
+ # @return [Object] The current node's object.
+ #
+ # @see #type_code
+ # @see #type
+ #
+ def get
+ type.get(self);
+ end
- private
+ # Puts a new value with the given type into the current node.
+ #
+ # @param value [Object] The value.
+ # @param type_code [Mapping] The value's type.
+ #
+ # @private
+ #
+ def put(value, type_code);
+ type_code.put(self, value);
+ end
- def valid_uuid?(value)
- # ensure that the UUID is in the right format
- # xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
- value =~ /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
- end
+ private
- # @private
- def check(err)
- if err < 0
- raise DataError, "[#{err}]: #{Cproton.pn_data_error(@data)}"
- else
- return err
+ def valid_uuid?(value)
+ # ensure that the UUID is in the right format
+ # xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
+ value =~ /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
end
+
+ # @private
+ def check(err)
+ if err < 0
+ raise DataError, "[#{err}]: #{Cproton.pn_data_error(@impl)}"
+ else
+ return err
+ end
+ end
+
end
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/proton-c/bindings/ruby/lib/codec/mapping.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/mapping.rb b/proton-c/bindings/ruby/lib/codec/mapping.rb
index fbebb57..92d0858 100644
--- a/proton-c/bindings/ruby/lib/codec/mapping.rb
+++ b/proton-c/bindings/ruby/lib/codec/mapping.rb
@@ -75,8 +75,11 @@ module Qpid::Proton::Codec
data.__send__(@get_method)
end
- def self.for_class(klass) # :nodoc:
- klass and (@@by_class[klass] or self.for_class(klass.superclass))
+ def self.for_class(klass)
+ c = klass
+ c = c.superclass while c && (x = @@by_class[c]).nil?
+ raise DataError, "no mapping for #{klass.inspect}" unless x
+ x
end
def self.for_code(code)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 96fd211..ed82dc8 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -21,26 +21,24 @@ module Qpid::Proton
# An AMQP connection.
class Connection < Endpoint
- protected
- include Util::SwigHelper
+ # @private
PROTON_METHOD_PREFIX = "pn_connection"
-
- public
+ # @private
+ include Util::Wrapper
# @!attribute hostname
# @return [String] The AMQP hostname for the connection.
- proton_accessor :hostname
+ proton_set_get :hostname
# @!attribute user
# @return [String] User name used for authentication (outgoing connection) or the authenticated user name (incoming connection)
- proton_accessor :user
+ proton_set_get :user
private
- proton_writer :password
+ proton_set :password
attr_accessor :overrides
attr_accessor :session_policy
- include Util::Wrapper
def self.wrap(impl)
return nil if impl.nil?
@@ -271,6 +269,6 @@ module Qpid::Proton
Cproton.pn_connection_remote_condition(@impl)
end
- proton_reader :attachments
+ proton_get :attachments
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index 71a4593..9cecf69 100644
--- a/proton-c/bindings/ruby/lib/core/disposition.rb
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -20,6 +20,11 @@ module Qpid::Proton
# @deprecated use {Delivery}
class Disposition
+ # @private
+ PROTON_METHOD_PREFIX = "pn_disposition"
+ # @private
+ include Util::Wrapper
+
ACCEPTED = Cproton::PN_ACCEPTED
REJECTED = Cproton::PN_REJECTED
@@ -39,36 +44,29 @@ module Qpid::Proton
@annotations = nil
end
- # @private
- include Util::SwigHelper
-
-
- # @private
- PROTON_METHOD_PREFIX = "pn_disposition"
-
# @!attribute section_number
#
# @return [Integer] The section number of the disposition.
#
- proton_accessor :section_number
+ proton_set_get :section_number
# @!attribute section_offset
#
# @return [Integer] The section offset of the disposition.
#
- proton_accessor :section_offset
+ proton_set_get :section_offset
# @!attribute failed?
#
# @return [Boolean] The failed flag.
#
- proton_accessor :failed, :is_or_get => :is
+ proton_set_is :failed
# @!attribute undeliverable?
#
# @return [Boolean] The undeliverable flag.
#
- proton_accessor :undeliverable, :is_or_get => :is
+ proton_set_is :undeliverable
# Sets the data for the disposition.
#
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index 37a089b..a5aa08e 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -24,7 +24,8 @@ module Qpid::Proton
class Event
private
- include Qpid::Proton::Util::Wrapper
+ PROTON_METHOD_PREFIX = "pn_disposition"
+ include Util::Wrapper
EVENT_TYPE_NAMES = [:PN_EVENT_NONE,
:PN_CONNECTION_INIT,
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index f8999cd..209d018 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -25,6 +25,11 @@ module Qpid::Proton
#
class Link < Endpoint
+ # @private
+ PROTON_METHOD_PREFIX = "pn_link"
+ # @private
+ include Util::Wrapper
+
# The sender will send all deliveries initially unsettled.
SND_UNSETTLED = Cproton::PN_SND_UNSETTLED
# The sender will send all deliveries settled to the receiver.
@@ -37,12 +42,6 @@ module Qpid::Proton
# 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.
@@ -171,7 +170,7 @@ module Qpid::Proton
#
# @return [Boolean] True if the link is a sender.
#
- proton_reader :sender, :is_or_get => :is
+ proton_is :sender
# @!attribute [r] receiver?
#
@@ -179,10 +178,10 @@ module Qpid::Proton
#
# @return [Boolean] True if the link is a receiver.
#
- proton_reader :receiver, :is_or_get => :is
+ proton_is :receiver
# @private
- proton_reader :attachments
+ proton_get :attachments
# Drains excess credit.
#
@@ -203,9 +202,6 @@ module Qpid::Proton
proton_caller :drained
# @private
- include Util::Wrapper
-
- # @private
def self.wrap(impl)
return unless impl
return fetch_instance(impl, :pn_link_attachments) ||
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 0f0c072..8f4f67c 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -32,6 +32,11 @@ module Qpid::Proton
#
class Message
+ # @private
+ PROTON_METHOD_PREFIX = "pn_message"
+ # @private
+ include Util::Wrapper
+
# Decodes a message from AMQP binary data.
# @param encoded [String] the encoded bytes
# @return[Integer] the number of bytes consumed
@@ -40,7 +45,8 @@ module Qpid::Proton
post_decode
end
- def post_decode # :nodoc:
+ # @private
+ def post_decode
# decode elements from the message
@properties = {}
props = Codec::Data.new(Cproton::pn_message_properties(@impl))
@@ -79,7 +85,8 @@ module Qpid::Proton
end
end
- def pre_encode # :nodoc:
+ # @private
+ def pre_encode
# encode elements from the message
props = Codec::Data.new(Cproton::pn_message_properties(@impl))
props.clear
@@ -106,30 +113,22 @@ module Qpid::Proton
# Creates a new +Message+ instance.
# @param body the body of the message, equivalent to calling m.body=(body)
- # @param set [Hash] additional settings, equivalent to m.key=value for each key=>value in settings
- def initialize(body = nil, settings={})
+ # @param opts [Hash] additional options, equivalent to +Message#key=value+ for each +key=>value+
+ def initialize(body = nil, opts={})
@impl = Cproton.pn_message
ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
@properties = {}
@instructions = {}
@annotations = {}
self.body = body unless body.nil?
- if !settings.nil? then
- settings.each do |k, v|
+ if !opts.nil? then
+ opts.each do |k, v|
setter = (k.to_s+"=").to_sym()
self.send setter, v
end
end
end
- def to_s
- tmp = Cproton.pn_string("")
- Cproton.pn_inspect(@impl, tmp)
- result = Cproton.pn_string_get(tmp)
- Cproton.pn_free(tmp)
- return result
- end
-
# Invoked by garbage collection to clean up resources used
# by the underlying message implementation.
def self.finalize!(impl) # :nodoc:
@@ -587,6 +586,7 @@ module Qpid::Proton
# Assigns a new value to the body of the message.
#
def body=(body)
+ Qpid::Proton::Codec::Mapping.for_class(body.class) unless body.nil? # Fail now if not convertible
@body = body
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index a78e5b5..791e891 100644
--- a/proton-c/bindings/ruby/lib/core/receiver.rb
+++ b/proton-c/bindings/ruby/lib/core/receiver.rb
@@ -25,10 +25,9 @@ module Qpid::Proton
class Receiver < Link
# @private
- include Util::SwigHelper
-
- # @private
PROTON_METHOD_PREFIX = "pn_link"
+ # @private
+ include Util::Wrapper
# @!attribute drain
#
@@ -42,7 +41,7 @@ module Qpid::Proton
#
# @return [Boolean] True if drain mode is set.
#
- proton_accessor :drain
+ proton_set_get :drain
# @!attribute [r] draining?
#
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index 3787637..08b5e4e 100644
--- a/proton-c/bindings/ruby/lib/core/sasl.rb
+++ b/proton-c/bindings/ruby/lib/core/sasl.rb
@@ -39,7 +39,7 @@ module Qpid::Proton
private
- include Util::SwigHelper
+ include Util::Wrapper
PROTON_METHOD_PREFIX = "pn_sasl"
public
@@ -52,11 +52,11 @@ module Qpid::Proton
# @!attribute allow_insecure_mechs
# @return [Bool] true if clear text authentication is allowed on insecure connections.
- proton_accessor :allow_insecure_mechs
+ proton_set_get :allow_insecure_mechs
# @!attribute user [r]
# @return [String] the authenticated user name
- proton_reader :user
+ proton_get :user
# Set the mechanisms allowed for SASL negotation
# @param mechanisms [String] space-delimited list of allowed mechanisms
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 bdc128f..26a7a2f 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -25,13 +25,9 @@ module Qpid::Proton
class Session < Endpoint
# @private
- include Util::Wrapper
-
- # @private
- include Util::SwigHelper
-
- # @private
PROTON_METHOD_PREFIX = "pn_session"
+ # @private
+ include Util::Wrapper
# @!attribute incoming_capacity
#
@@ -42,10 +38,10 @@ module Qpid::Proton
#
# @return [Integer] The incoing capacity of the session, measured in bytes.
#
- proton_accessor :incoming_capacity
+ proton_set_get :incoming_capacity
# @private
- proton_reader :attachments
+ proton_get :attachments
# @!attribute [r] outgoing_bytes
#
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 2db1c1c..11db54d 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -60,11 +60,9 @@ module Qpid::Proton
RESUME_REUSED = Cproton::PN_SSL_RESUME_REUSED
# @private
- include Util::SwigHelper
-
- # @private
PROTON_METHOD_PREFIX = "pn_ssl"
-
+ # @private
+ include Util::Wrapper
# @private
include Util::ErrorHandler
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index b3d7c05..82ac9f7 100644
--- a/proton-c/bindings/ruby/lib/core/terminus.rb
+++ b/proton-c/bindings/ruby/lib/core/terminus.rb
@@ -65,10 +65,9 @@ module Qpid::Proton
DIST_MODE_MOVE = Cproton::PN_DIST_MODE_MOVE
# @private
- include Util::SwigHelper
-
- # @private
PROTON_METHOD_PREFIX = "pn_terminus"
+ # @private
+ include Util::Wrapper
# @!attribute type
#
@@ -78,13 +77,13 @@ module Qpid::Proton
# @see TARGET
# @see COORDINATOR
#
- proton_accessor :type
+ proton_set_get :type
# @!attribute address
#
# @return [String] The terminus address.
#
- proton_accessor :address
+ proton_set_get :address
# @!attribute durability
#
@@ -94,7 +93,7 @@ module Qpid::Proton
# @see CONFIGURATION
# @see DELIVERIES
#
- proton_accessor :durability
+ proton_set_get :durability
# @!attribute expiry_policy
#
@@ -105,19 +104,19 @@ module Qpid::Proton
# @see EXPIRE_WITH_CONNECTION
# @see EXPIRE_NEVER
#
- proton_accessor :expiry_policy
+ proton_set_get :expiry_policy
# @!attribute timeout
#
# @return [Integer] The timeout period.
#
- proton_accessor :timeout
+ proton_set_get :timeout
# @!attribute dynamic?
#
# @return [Boolean] True if the terminus is dynamic.
#
- proton_accessor :dynamic, :is_or_get => :is
+ proton_set_is :dynamic
# @!attribute distribution_mode
#
@@ -127,7 +126,7 @@ module Qpid::Proton
# @see DIST_MODE_COPY
# @see DIST_MODE_MOVE
#
- proton_accessor :distribution_mode
+ proton_set_get :distribution_mode
# @private
include Util::ErrorHandler
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index 7c3a502..57e8b55 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -24,9 +24,8 @@ module Qpid::Proton
private
- include Util::Wrapper
- include Util::SwigHelper
PROTON_METHOD_PREFIX = "pn_delivery"
+ include Util::Wrapper
protected
@@ -77,9 +76,6 @@ module Qpid::Proton
# @return [Integer] Remote state of the transfer, one of the values in {State}
def state() Cproton.pn_delivery_remote_state(@impl); end
- def to_s() Cproton.pn_delivery_dump(@impl); end
- alias inspect to_s
-
# @return [Link] The parent link.
def link() Link.wrap(Cproton.pn_delivery_link(@impl)); end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 4398966..c1593a0 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -62,6 +62,10 @@ module Qpid::Proton
# PN_TRACE_FRM=1 ruby my_proton_app.rb
#
class Transport
+ # @private
+ PROTON_METHOD_PREFIX = "pn_transport"
+ # @private
+ include Util::Wrapper
# Turn logging off entirely.
TRACE_OFF = Cproton::PN_TRACE_OFF
@@ -72,17 +76,12 @@ module Qpid::Proton
# Log driver related events; i.e., initialization, end of stream, etc.
TRACE_DRV = Cproton::PN_TRACE_DRV
- # @private
- include Util::SwigHelper
-
- # @private
- PROTON_METHOD_PREFIX = "pn_transport"
# @!attribute channel_max
#
# @return [Integer] The maximum allowed channel.
#
- proton_accessor :channel_max
+ proton_set_get :channel_max
# @!attribute [r] remote_channel_max
#
@@ -94,25 +93,25 @@ module Qpid::Proton
#
# @return [Integer] The maximum frame size.
#
- proton_accessor :max_frame_size
+ proton_set_get :max_frame_size
# @!attribute [r] remote_max_frame_size
#
# @return [Integer] The maximum frame size of the transport's remote peer.
#
- proton_reader :remote_max_frame_size
+ proton_get :remote_max_frame_size
# @!attribute idle_timeout
#
# @return [Integer] The idle timeout.
#
- proton_accessor :idle_timeout
+ proton_set_get :idle_timeout
# @!attribute [r] remote_idle_timeout
#
# @return [Integer] The idle timeout for the transport's remote peer.
#
- proton_accessor :remote_idle_timeout
+ proton_set_get :remote_idle_timeout
# @!attribute [r] capacity
#
@@ -181,13 +180,13 @@ module Qpid::Proton
#
# @return [Integer] The number of frames output by a transport.
#
- proton_reader :frames_output
+ proton_get :frames_output
# @!attribute [r] frames_input
#
# @return [Integer] The number of frames input by a transport.
#
- proton_reader :frames_input
+ proton_get :frames_input
# @private
include Util::ErrorHandler
@@ -198,9 +197,6 @@ module Qpid::Proton
can_raise_error :close_head, :error_class => TransportError
# @private
- include Util::Wrapper
-
- # @private
def self.wrap(impl)
return nil if impl.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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 6164fde..a226838 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -47,7 +47,6 @@ require "core/exceptions"
# Utility classes
require "util/version"
require "util/error_handler"
-require "util/swig_helper"
require "util/wrapper"
require "util/timeout"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
deleted file mode 100644
index 1013df8..0000000
--- a/proton-c/bindings/ruby/lib/util/swig_helper.rb
+++ /dev/null
@@ -1,113 +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
-
- # 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 method,
- # avoids repetitive boiler plate coding.
- #
- # == Arguments
- #
- # [:is_or_get => {:is, :get}] For both the getter and the mutator types
- # you can also declare that the method uses "is" instead of "get" in the
- # underlying API. Such methods are then defined with "?"
- #
- # @example
- # class Terminus
- #
- # include WrapperHelper
- #
- # PROTON_METHOD_PREFIX = "pn_terminus"
- #
- # # add methods "type" and "type=" that call "pn_terminus_{get,set}_type"
- # proton_accessor :type
- #
- # # adds the method "dynamic?" that calls "pn_terminus_is_dynamic"
- # proton_accessor :dynamic, :is_or_get => :is
- #
- # # adds a method named "foo" that calls "pn_terminus_foo"
- # proton_caller :foo
- #
- # end
- #
- # @private
- module SwigHelper
-
- def self.included(base)
- base.extend ClassMethods
- end
-
- module ClassMethods # :nodoc:
-
- def create_wrapper_method(name, proton_method, with_arg = false)
- if with_arg
- define_method "#{name}" do |arg|
- Cproton.__send__(proton_method.to_sym, @impl, arg)
- end
- else
- define_method "#{name}" do
- Cproton.__send__(proton_method.to_sym, @impl)
- end
- end
- end
-
- # Defines a method that calls an underlying C library function.
- def proton_caller(name, options = {})
- proton_method = "#{self::PROTON_METHOD_PREFIX}_#{name}"
- # drop the trailing '?' if this is a property method
- proton_method = proton_method[0..-2] if proton_method.end_with? "?"
- create_wrapper_method(name, proton_method, options[:arg])
- end
-
- def proton_writer(name, options = {})
- proton_method = "#{self::PROTON_METHOD_PREFIX}_set_#{name}"
- create_wrapper_method("#{name}=", proton_method, true)
- end
-
- def proton_reader(name, options = {})
- an_is_method = options[:is_or_get] == :is
- prefix = (an_is_method) ? "is" : "get"
- proton_method = "#{self::PROTON_METHOD_PREFIX}_#{prefix}_#{name}"
- name = "#{name}?" if an_is_method
- create_wrapper_method(name, proton_method)
- end
-
- def proton_accessor(name, options = {})
- proton_writer(name, options)
- proton_reader(name, options)
- end
-
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/889c0c6d/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
index c6e0e72..39cd7b4 100644
--- a/proton-c/bindings/ruby/lib/util/wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/wrapper.rb
@@ -16,47 +16,46 @@
# under the License.
-module Qpid::Proton::Util
-
- # @private
- module Wrapper
+module Qpid::Proton
+ module Util
# @private
- def impl=(impl)
- @impl = impl
- end
+ # Class methods to help wrapper classes define forwarding methods to proton-C functions
+ #
+ # The extending class must define PROTON_METHOD_PREFIX, the functions here
+ # make it easy to define ruby methods to forward calls to C functions.
+ #
+ module SWIGClassHelper
+ # Define ruby method +name+ to forward arguments to
+ # CProton.PROTON_METHOD_PREFIX_+pn_name+(@impl, ...)
+ def proton_forward(name, pn_name)
+ pn_name = pn_name[0..-2] if pn_name.to_s.end_with? "?" # Drop trailing ? for ruby bool methods
+ pn_name = "#{self::PROTON_METHOD_PREFIX}_#{pn_name}".to_sym
+ define_method(name.to_sym) { |*args| Cproton.__send__(pn_name, @impl, *args) }
+ end
- # @private
- def impl
- @impl
- end
+ def proton_caller(*names) names.each { |name| proton_forward(name, name) }; end
+ def proton_set(*names) names.each { |name| proton_forward("#{name}=", "set_#{name}") }; end
+ def proton_get(*names) names.each { |name| proton_forward(name, "get_#{name}") }; end
+ def proton_is(*names) names.each { |name| proton_forward("#{name}?", "is_#{name}") }; end
+ def proton_set_get(*names) names.each { |name| proton_get(name); proton_set(name) }; end
+ def proton_set_is(*names) names.each { |name| proton_is(name); proton_set(name) }; end
- def self.registry
- @registry ||= {}
- end
+ # Store ruby wrappers as attachments so they can be retrieved from the C pointer.
+ #
+ # 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.
- 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
+ @@registry = {}
# @private
def get_key(impl)
("%032x" % Cproton.pni_address_of(impl))
end
+ # @private
# Stores the given object for later retrieval.
#
# @param object [Object] The object.
@@ -75,7 +74,7 @@ module Qpid::Proton::Util
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
+ @@registry[registry_key] = object
end
# Retrieves the wrapper object with the supplied Proton struct.
@@ -100,9 +99,9 @@ module Qpid::Proton::Util
registry_key = get_key(impl)
end
# if the object's not in the registry then return
- return nil unless Qpid::Proton::Util::Wrapper.registry.has_key?(registry_key)
+ return nil unless @@registry.has_key?(registry_key)
- result = Qpid::Proton::Util::Wrapper.registry[registry_key]
+ result = @@registry[registry_key]
# result = nil unless result.weakref_alive?
if result.nil?
raise Qpid::Proton::ProtonError.new("missing object for key=#{registry_key}")
@@ -112,18 +111,32 @@ module Qpid::Proton::Util
end
return result
end
-
+ RBCTX = self.hash.to_i
end
+ # @private
+ module Wrapper
- # Hash/equality of wrappers is based on their @impl pointers, not object_id
+ def self.included(base)
+ base.extend(SWIGClassHelper)
+ end
- def hash() @impl.hash; end
- def ==(x) @impl == x.impl; end
- alias eql? ==
+ attr_accessor :impl
- end
+ def inspect
+ pstr = Cproton.pn_string("")
+ begin
+ Cproton.pn_inspect(@impl, pstr)
+ return Cproton.pn_string_get(pstr)
+ ensure
+ Cproton.pn_free(pstr)
+ end
+ end
- # @private
- RBCTX = Wrapper.hash.to_i
+ alias to_s inspect
+ def self.registry
+ @registry ||= {}
+ end
+ end
+ end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[08/50] [abbrv] qpid-proton git commit: PROTON-1680: Handle various
string inputs for allowed SASL mechanisms and add docs
Posted by ac...@apache.org.
PROTON-1680: Handle various string inputs for allowed SASL mechanisms and add docs
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e4b5a4fe
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e4b5a4fe
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e4b5a4fe
Branch: refs/heads/go1
Commit: e4b5a4fef1c7f31d11dbec62f40110141c373e49
Parents: d80a792
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 09:35:00 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 09:35:00 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 2 +-
proton-c/bindings/python/proton/reactor.py | 15 ++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e4b5a4fe/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 ddc7d3e..3671e2b 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -3573,7 +3573,7 @@ class SASL(Wrapper):
return outcome
def allowed_mechs(self, mechs):
- pn_sasl_allowed_mechs(self._sasl, mechs)
+ pn_sasl_allowed_mechs(self._sasl, unicode2utf8(mechs))
def _get_allow_insecure_mechs(self):
return pn_sasl_get_allow_insecure_mechs(self._sasl)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e4b5a4fe/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 537b280..c210a8f 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -713,14 +713,15 @@ class Container(Reactor):
called to process any events in the scope of this connection
or its child links
- @param kwargs: sasl_enabled, which determines whether a sasl layer is
- used for the connection; allowed_mechs an optional list of SASL
- mechanisms to allow if sasl is enabled; allow_insecure_mechs a flag
+ @param kwargs: sasl_enabled, which determines whether a sasl
+ layer is used for the connection; allowed_mechs an optional
+ string containing a space-separated list of SASL mechanisms to
+ allow if sasl is enabled; allow_insecure_mechs a flag
indicating whether insecure mechanisms, such as PLAIN over a
- non-encrypted socket, are allowed; 'virtual_host' the hostname to set
- in the Open performative used by peer to determine the correct
- back-end service for the client. If 'virtual_host' is not supplied the
- host field from the URL is used instead."
+ non-encrypted socket, are allowed; 'virtual_host' the hostname
+ to set in the Open performative used by peer to determine the
+ correct back-end service for the client. If 'virtual_host' is
+ not supplied the host field from the URL is used instead."
"""
conn = self.connection(handler)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[02/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fix
copyright comments and top-level yard doc
Posted by ac...@apache.org.
PROTON-1537: [ruby] Fix copyright comments and top-level yard doc
Removed useless #-- #++ brackets around copyright comments; they were supposed
to prevent them being attached as doc comments to the first definition in the
file but they don't. What does work is making sure there are 2 empty lines after
the copyright comment and before the first definition.
Clean up the top level doc comments and references.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7c004d3e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7c004d3e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7c004d3e
Branch: refs/heads/go1
Commit: 7c004d3eb0408bff6548db60e9db228fd1c6880f
Parents: 5690209
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 5 14:50:08 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 5 16:54:52 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/README.rdoc | 128 +++++---
proton-c/bindings/ruby/lib/codec/data.rb | 3 +-
proton-c/bindings/ruby/lib/codec/mapping.rb | 3 +-
proton-c/bindings/ruby/lib/core/condition.rb | 3 +-
proton-c/bindings/ruby/lib/core/connection.rb | 3 +-
.../bindings/ruby/lib/core/connection_driver.rb | 314 +++++++++----------
proton-c/bindings/ruby/lib/core/container.rb | 3 +-
proton-c/bindings/ruby/lib/core/delivery.rb | 3 +-
proton-c/bindings/ruby/lib/core/disposition.rb | 3 +-
proton-c/bindings/ruby/lib/core/endpoint.rb | 3 +-
proton-c/bindings/ruby/lib/core/event.rb | 3 +-
proton-c/bindings/ruby/lib/core/exceptions.rb | 217 +++++++------
proton-c/bindings/ruby/lib/core/link.rb | 3 +-
proton-c/bindings/ruby/lib/core/listener.rb | 3 +-
proton-c/bindings/ruby/lib/core/message.rb | 3 +-
.../bindings/ruby/lib/core/messaging_handler.rb | 3 +-
proton-c/bindings/ruby/lib/core/receiver.rb | 3 +-
proton-c/bindings/ruby/lib/core/sasl.rb | 3 +-
proton-c/bindings/ruby/lib/core/sender.rb | 3 +-
proton-c/bindings/ruby/lib/core/session.rb | 3 +-
proton-c/bindings/ruby/lib/core/ssl.rb | 3 +-
proton-c/bindings/ruby/lib/core/ssl_details.rb | 3 +-
proton-c/bindings/ruby/lib/core/ssl_domain.rb | 3 +-
proton-c/bindings/ruby/lib/core/terminus.rb | 3 +-
proton-c/bindings/ruby/lib/core/tracker.rb | 5 +-
proton-c/bindings/ruby/lib/core/transfer.rb | 3 +-
proton-c/bindings/ruby/lib/core/transport.rb | 3 +-
proton-c/bindings/ruby/lib/core/uri.rb | 3 +-
proton-c/bindings/ruby/lib/core/url.rb | 3 +-
proton-c/bindings/ruby/lib/handler/adapter.rb | 3 +-
.../bindings/ruby/lib/messenger/messenger.rb | 3 +-
.../bindings/ruby/lib/messenger/subscription.rb | 3 +-
proton-c/bindings/ruby/lib/messenger/tracker.rb | 3 +-
.../ruby/lib/messenger/tracker_status.rb | 3 +-
proton-c/bindings/ruby/lib/qpid_proton.rb | 5 +-
proton-c/bindings/ruby/lib/reactor/container.rb | 3 +-
proton-c/bindings/ruby/lib/types/array.rb | 3 +-
proton-c/bindings/ruby/lib/types/described.rb | 3 +-
proton-c/bindings/ruby/lib/types/hash.rb | 3 +-
proton-c/bindings/ruby/lib/types/strings.rb | 3 +-
.../bindings/ruby/lib/util/error_handler.rb | 3 +-
proton-c/bindings/ruby/lib/util/swig_helper.rb | 3 +-
proton-c/bindings/ruby/lib/util/timeout.rb | 3 +-
proton-c/bindings/ruby/lib/util/version.rb | 3 +-
proton-c/bindings/ruby/lib/util/wrapper.rb | 3 +-
proton-c/bindings/ruby/spec/data_spec.rb | 3 +-
.../ruby/spec/exception_handling_spec.rb | 3 +-
proton-c/bindings/ruby/spec/message_spec.rb | 3 +-
.../bindings/ruby/tests/old_examples/broker.rb | 3 +-
.../bindings/ruby/tests/old_examples/client.rb | 3 +-
.../ruby/tests/old_examples/direct_recv.rb | 3 +-
.../ruby/tests/old_examples/direct_send.rb | 3 +-
.../ruby/tests/old_examples/helloworld.rb | 3 +-
.../tests/old_examples/helloworld_direct.rb | 3 +-
.../ruby/tests/old_examples/lib/debugging.rb | 3 +-
.../ruby/tests/old_examples/lib/driver.rb | 3 +-
.../tests/old_examples/lib/qpid_examples.rb | 3 +-
.../ruby/tests/old_examples/lib/selectable.rb | 3 +-
.../tests/old_examples/lib/send_and_receive.rb | 3 +-
.../bindings/ruby/tests/old_examples/server.rb | 3 +-
.../ruby/tests/old_examples/simple_recv.rb | 3 +-
.../ruby/tests/old_examples/simple_send.rb | 3 +-
proton-c/bindings/ruby/tests/test_adapter.rb | 3 +-
.../ruby/tests/test_connection_driver.rb | 3 +-
proton-c/bindings/ruby/tests/test_container.rb | 3 +-
proton-c/bindings/ruby/tests/test_tools.rb | 3 +-
proton-c/bindings/ruby/tests/test_uri.rb | 3 +-
67 files changed, 416 insertions(+), 439 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/README.rdoc
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/README.rdoc b/proton-c/bindings/ruby/README.rdoc
index 75552c8..5eec00f 100644
--- a/proton-c/bindings/ruby/README.rdoc
+++ b/proton-c/bindings/ruby/README.rdoc
@@ -1,73 +1,121 @@
-= Qpid Proton Ruby Language Bindings
+= Qpid Proton AMQP Library
-This is a Ruby language binding for the Qpid proton AMQP messaging library.
-You can build clients and servers using this library.
+This is a library for sending and receiving AMQP messages. It can be used to
+build clients and servers.
-== Class Overview
-
-The {Qpid::Proton} module contains the key classes:
+== Installing
-{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.
+You can install the latest published Gem with
-{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.
+ gem install qpid_proton
-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.
+*NOTE:* before installing the Gem, you must install the proton-C library.
-Sessions belong to a {Qpid::Proton::Connection}. If you don't need multiple sessions, a connection will create links directly using a default session.
+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
-A {Qpid::Proton::Transfer} represents the transfer of a message, the {Qpid::Proton::Delivery} subclass allows a receiver to accept or reject an incoming message. The {Qpid::Proton::Tracker} subclass allows a sender to track the status of a sent message and find out if it was accepted or rejected.
+You can also download a source release or the latest development code from
+http://qpid.apache.org/proton. To build from source:
-A transfer 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.
+ cmake -DBUILD_BINDINGS=ruby && make
-== The anatomy of a Proton application
+This produces a Gem file at:
-{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.
+ ${CMAKE_BUILD_DIR}/proton-c/bindings/ruby/qpid_proton-${PN_VERSION}.gem
-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.
+You can install the gem with +gem install+
-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.
+== Overview
-== Sources and targets
+{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.
-Every link has two addresses, _source_ and _target_. The most common pattern for using these addresses is as follows:
+{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.
-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".
+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.
-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.
+Sessions belong to a {Qpid::Proton::Connection}. If you don't need multiple
+sessions, a connection will create links directly using a default session.
-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.
+A {Qpid::Proton::Transfer} represents the transfer of a message, the
+{Qpid::Proton::Delivery} subclass allows a receiver to accept or reject an
+incoming message. The {Qpid::Proton::Tracker} subclass allows a sender to track
+the status of a sent message and find out if it was accepted or rejected.
-The server_direct.cpp example shows how to implement a request-response server.
+A transfer 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.
-== Settling a Message Transfer
+== Anatomy of a Proton application
-A message transfer is _settled_ at one end of a link when that end of the link
-has finished with the message and forgotten it.
+{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.
-_Pre-settled_ messages are settled by the sender before sending. This gives _at most once_ reliability(also known as _best effort_, _unreliable_ or _fire and forget_) since the sender never knows for sure if the message arrived. If the connection is lost before the message is received by the receiver, the message will not be delivered.
+Proton is an event-driven library. You implement one or more _handlers_ which
+subclass {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.
-If the sender does not pre-settle a message, then the receiver settles it once it has been processed. The sender is informed of the settlement via the {Qpid::Proton::Tracker Tracker}. If the connection is lost before the sender has received notice of settlement, the delivery is considered in-doubt and the sender can re-send it. This ensures it eventually gets delivered (provided the connection and link can be reestablished) but it is possible for multiple copies of the same message are delivered, so the receiver must be aware of that. This is known as _at_least_once_ reliability.
+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.
-== Installing
+== Sources and targets
-You can install the latest published Gem with
+Every link has two addresses, _source_ and _target_. The most common pattern for
+using these addresses is as follows:
- gem install qpid_proton
+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".
-*NOTE:* before installing the Gem, you must install the proton-C library.
+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.
-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
+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.
-You can also download a source release or the latest development code from http://qpid.apache.org/proton. To build from source:
+The server_direct.cpp example shows how to implement a request-response server.
- cmake -DBUILD_BINDINGS=ruby && make
+== Settling a Message Transfer
-This produces a Gem file at:
+A message transfer is _settled_ at one end of a link when that end of the link
+has finished with the message and forgotten it.
- ${CMAKE_BUILD_DIR}/proton-c/bindings/ruby/qpid_proton-${PN_VERSION}.gem
+_Pre-settled_ messages are settled by the sender before sending. This gives _at
+most once_ reliability(also known as _best effort_, _unreliable_ or _fire and
+forget_) since the sender never knows for sure if the message arrived. 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 has been processed. The sender is informed of the settlement via the
+{Qpid::Proton::Tracker Tracker}. If the connection is lost before the sender has
+received notice of settlement, the delivery is considered in-doubt and the
+sender can re-send it. This ensures it eventually gets delivered (provided the
+connection and link can be reestablished) but it is possible for multiple copies
+of the same message are delivered, so the receiver must be aware of that. This
+is known as _at_least_once_ reliability.
-You can install the gem with +gem install+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 2742008..f287d64 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Codec
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/codec/mapping.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/mapping.rb b/proton-c/bindings/ruby/lib/codec/mapping.rb
index 5a498b4..fbebb57 100644
--- a/proton-c/bindings/ruby/lib/codec/mapping.rb
+++ b/proton-c/bindings/ruby/lib/codec/mapping.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Codec
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/condition.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/condition.rb b/proton-c/bindings/ruby/lib/core/condition.rb
index 05231c6..d22dafe 100644
--- a/proton-c/bindings/ruby/lib/core/condition.rb
+++ b/proton-c/bindings/ruby/lib/core/condition.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 3715080..96fd211 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index 969b558..fe52d75 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -17,190 +17,188 @@
require 'socket'
-module Qpid
- module Proton
-
- # Associate an AMQP {Connection} and {Transport} with an {IO}
- #
- # - {#read} reads AMQP binary data from the {IO} and generates events
- # - {#tick} generates timing-related events
- # - {#event} gets events to be dispatched to {Handler::MessagingHandler}s
- # - {#write} writes AMQP binary data to the {IO}
- #
- # Thread safety: The {ConnectionDriver} is not thread safe but separate
- # {ConnectionDriver} instances can be processed concurrently. The
- # {Container} handles multiple connections concurrently in multiple threads.
- #
- class ConnectionDriver
- # Create a {Connection} and {Transport} associated with +io+
- # @param io [IO] An {IO} or {IO}-like object that responds
- # to {IO#read_nonblock} and {IO#write_nonblock}
- def initialize(io)
- @impl = Cproton.pni_connection_driver or raise NoMemoryError
- @io = io
- @rbuf = "" # String for re-usable read buffer
- end
+module Qpid::Proton
+
+ # Associate an AMQP {Connection} and {Transport} with an {IO}
+ #
+ # - {#read} reads AMQP binary data from the {IO} and generates events
+ # - {#tick} generates timing-related events
+ # - {#event} gets events to be dispatched to {Handler::MessagingHandler}s
+ # - {#write} writes AMQP binary data to the {IO}
+ #
+ # Thread safety: The {ConnectionDriver} is not thread safe but separate
+ # {ConnectionDriver} instances can be processed concurrently. The
+ # {Container} handles multiple connections concurrently in multiple threads.
+ #
+ class ConnectionDriver
+ # Create a {Connection} and {Transport} associated with +io+
+ # @param io [IO] An {IO} or {IO}-like object that responds
+ # to {IO#read_nonblock} and {IO#write_nonblock}
+ def initialize(io)
+ @impl = Cproton.pni_connection_driver or raise NoMemoryError
+ @io = io
+ @rbuf = "" # String for re-usable read buffer
+ end
- # @return [Connection]
- def connection()
- @connection ||= Connection.wrap(Cproton.pni_connection_driver_connection(@impl))
- end
+ # @return [Connection]
+ def connection()
+ @connection ||= Connection.wrap(Cproton.pni_connection_driver_connection(@impl))
+ end
- # @return [Transport]
- def transport()
- @transport ||= Transport.wrap(Cproton.pni_connection_driver_transport(@impl))
- end
+ # @return [Transport]
+ def transport()
+ @transport ||= Transport.wrap(Cproton.pni_connection_driver_transport(@impl))
+ end
- # @return [IO] Allows ConnectionDriver to be passed directly to {IO#select}
- def to_io() @io; end
+ # @return [IO] Allows ConnectionDriver to be passed directly to {IO#select}
+ def to_io() @io; end
- # @return [Bool] True if the driver can read more data
- def can_read?() Cproton.pni_connection_driver_read_size(@impl) > 0; end
+ # @return [Bool] True if the driver can read more data
+ def can_read?() Cproton.pni_connection_driver_read_size(@impl) > 0; end
- # @return [Bool] True if the driver has data to write
- def can_write?() Cproton.pni_connection_driver_write_size(@impl) > 0; end
+ # @return [Bool] True if the driver has data to write
+ def can_write?() Cproton.pni_connection_driver_write_size(@impl) > 0; end
- # True if the ConnectionDriver has nothing left to do: both sides of the
- # transport are closed and there are no events to dispatch.
- def finished?() Cproton.pn_connection_driver_finished(@impl); end
+ # True if the ConnectionDriver has nothing left to do: both sides of the
+ # transport are closed and there are no events to dispatch.
+ def finished?() Cproton.pn_connection_driver_finished(@impl); end
- # Get the next event to dispatch, nil if no events available
- def event()
- e = Cproton.pn_connection_driver_next_event(@impl)
- Event.new(e) if e
- end
+ # Get the next event to dispatch, nil if no events available
+ def event()
+ e = Cproton.pn_connection_driver_next_event(@impl)
+ Event.new(e) if e
+ end
- # True if {#event} will return non-nil
- def event?() Cproton.pn_connection_driver_has_event(@impl); end
+ # True if {#event} will return non-nil
+ def event?() Cproton.pn_connection_driver_has_event(@impl); end
- # Iterator for all available events
- def each_event()
- while e = event
- yield e
- end
+ # Iterator for all available events
+ def each_event()
+ while e = event
+ yield e
end
+ end
- # Non-blocking read from {#io}, generate events for {#event}
- # IO errors are returned as transport errors by {#event}, not raised
- def read
- size = Cproton.pni_connection_driver_read_size(@impl)
- return if size <= 0
- @io.read_nonblock(size, @rbuf) # Use the same string rbuf for reading each time
- Cproton.pni_connection_driver_read_copy(@impl, @rbuf) unless @rbuf.empty?
- rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
- # Try again later.
- rescue EOFError # EOF is not an error
- close_read
- rescue IOError, SystemCallError => e
- close e
- end
+ # Non-blocking read from {#io}, generate events for {#event}
+ # IO errors are returned as transport errors by {#event}, not raised
+ def read
+ size = Cproton.pni_connection_driver_read_size(@impl)
+ return if size <= 0
+ @io.read_nonblock(size, @rbuf) # Use the same string rbuf for reading each time
+ Cproton.pni_connection_driver_read_copy(@impl, @rbuf) unless @rbuf.empty?
+ rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
+ # Try again later.
+ rescue EOFError # EOF is not an error
+ close_read
+ rescue IOError, SystemCallError => e
+ close e
+ end
- # Non-blocking write to {#io}
- # IO errors are returned as transport errors by {#event}, not raised
- def write
- n = @io.write_nonblock(Cproton.pn_connection_driver_write_buffer(@impl))
- Cproton.pn_connection_driver_write_done(@impl, n) if n > 0
- rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
- # Try again later.
- rescue IOError, SystemCallError => e
- close e
- end
+ # Non-blocking write to {#io}
+ # IO errors are returned as transport errors by {#event}, not raised
+ def write
+ n = @io.write_nonblock(Cproton.pn_connection_driver_write_buffer(@impl))
+ Cproton.pn_connection_driver_write_done(@impl, n) if n > 0
+ rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
+ # Try again later.
+ rescue IOError, SystemCallError => e
+ close e
+ end
- # Handle time-related work, for example idle-timeout events.
- # May generate events for {#event} and change {#can_read?}, {#can_write?}
- #
- # @param [Time] now the current time, defaults to {Time#now}.
- #
- # @return [Time] time of the next scheduled event, or nil if there are no
- # scheduled events. If non-nil you must call {#tick} again no later than
- # this time.
- def tick(now=Time.now)
- transport = Cproton.pni_connection_driver_transport(@impl)
- ms = Cproton.pn_transport_tick(transport, (now.to_r * 1000).to_i)
- return ms.zero? ? nil : Time.at(ms.to_r / 1000);
- end
+ # Handle time-related work, for example idle-timeout events.
+ # May generate events for {#event} and change {#can_read?}, {#can_write?}
+ #
+ # @param [Time] now the current time, defaults to {Time#now}.
+ #
+ # @return [Time] time of the next scheduled event, or nil if there are no
+ # scheduled events. If non-nil you must call {#tick} again no later than
+ # this time.
+ def tick(now=Time.now)
+ transport = Cproton.pni_connection_driver_transport(@impl)
+ ms = Cproton.pn_transport_tick(transport, (now.to_r * 1000).to_i)
+ return ms.zero? ? nil : Time.at(ms.to_r / 1000);
+ end
- # Disconnect the write side of the transport, *without* sending an AMQP
- # close frame. To close politely, you should use {Connection#close}, the
- # transport will close itself once the protocol close is complete.
- #
- def close_write error=nil
- set_error error
- Cproton.pn_connection_driver_write_close(@impl)
- @io.close_write rescue nil # Allow double-close
- end
+ # Disconnect the write side of the transport, *without* sending an AMQP
+ # close frame. To close politely, you should use {Connection#close}, the
+ # transport will close itself once the protocol close is complete.
+ #
+ def close_write error=nil
+ set_error error
+ Cproton.pn_connection_driver_write_close(@impl)
+ @io.close_write rescue nil # Allow double-close
+ end
- # Is the read side of the driver closed?
- def read_closed?() Cproton.pn_connection_driver_read_closed(@impl); end
+ # Is the read side of the driver closed?
+ def read_closed?() Cproton.pn_connection_driver_read_closed(@impl); end
- # Is the write side of the driver closed?
- def write_closed?() Cproton.pn_connection_driver_read_closed(@impl); end
+ # Is the write side of the driver closed?
+ def write_closed?() Cproton.pn_connection_driver_read_closed(@impl); end
- # Disconnect the read side of the transport, without waiting for an AMQP
- # close frame. See comments on {#close_write}
- def close_read error=nil
- set_error error
- Cproton.pn_connection_driver_read_close(@impl)
- @io.close_read rescue nil # Allow double-close
- end
+ # Disconnect the read side of the transport, without waiting for an AMQP
+ # close frame. See comments on {#close_write}
+ def close_read error=nil
+ set_error error
+ Cproton.pn_connection_driver_read_close(@impl)
+ @io.close_read rescue nil # Allow double-close
+ end
- # Disconnect both sides of the transport sending/waiting for AMQP close
- # frames. See comments on {#close_write}
- def close error=nil
- close_write error
- close_read
- end
+ # Disconnect both sides of the transport sending/waiting for AMQP close
+ # frames. See comments on {#close_write}
+ def close error=nil
+ close_write error
+ close_read
+ end
- private
+ private
- def set_error err
- transport.condition ||= Condition.convert(err, "proton:io") if err
- end
+ def set_error err
+ transport.condition ||= Condition.convert(err, "proton:io") if err
end
+ end
- # A {ConnectionDriver} that feeds events to a {Handler::MessagingHandler}
- class HandlerDriver < ConnectionDriver
- # Combine an {IO} with a {Handler::MessagingHandler} and provide
- # a simplified way to run the driver via {#process}
- #
- # @param io [IO]
- # @param handler [Handler::MessagingHandler] to receive events in
- # {#dispatch} and {#process}
- def initialize(io, handler)
- super(io)
- # Allow multiple handlers for backwards compatibility
- a = Array(handler)
- @handler = a.size > 1 ? MessagingHandlers.new(a) : handler
- @adapter = Handler::Adapter.try_convert(handler)
- end
-
- # @return [MessagingHandler] The handler dispatched to by {#process}
- attr_reader :handler
+ # A {ConnectionDriver} that feeds events to a {Handler::MessagingHandler}
+ class HandlerDriver < ConnectionDriver
+ # Combine an {IO} with a {Handler::MessagingHandler} and provide
+ # a simplified way to run the driver via {#process}
+ #
+ # @param io [IO]
+ # @param handler [Handler::MessagingHandler] to receive events in
+ # {#dispatch} and {#process}
+ def initialize(io, handler)
+ super(io)
+ # Allow multiple handlers for backwards compatibility
+ a = Array(handler)
+ @handler = a.size > 1 ? MessagingHandlers.new(a) : handler
+ @adapter = Handler::Adapter.try_convert(handler)
+ end
- # Dispatch all events available from {#event} to {#handler}
- def dispatch() each_event do |e|
- e.dispatch self # See private on_transport_ methods below
- e.dispatch @adapter
- end
- end
+ # @return [MessagingHandler] The handler dispatched to by {#process}
+ attr_reader :handler
- # Do {#read}, {#tick}, {#write} and {#dispatch} without blocking.
- # @param [Time] now the current time
- # @return [Time] Latest time to call {#process} again for scheduled events,
- # or nil if there are no scheduled events
- def process(now=Time.now)
- read
- next_tick = tick(now)
- dispatch # Generate data for write
- write
- dispatch # Consume all events
- return next_tick
+ # Dispatch all events available from {#event} to {#handler}
+ def dispatch() each_event do |e|
+ e.dispatch self # See private on_transport_ methods below
+ e.dispatch @adapter
end
+ end
- private
- def on_transport_tail_closed(event) close_read; end
- def on_transport_head_closed(event) close_write; end
- def on_transport_authenticated(event) connection.user = transport.user; end
+ # Do {#read}, {#tick}, {#write} and {#dispatch} without blocking.
+ # @param [Time] now the current time
+ # @return [Time] Latest time to call {#process} again for scheduled events,
+ # or nil if there are no scheduled events
+ def process(now=Time.now)
+ read
+ next_tick = tick(now)
+ dispatch # Generate data for write
+ write
+ dispatch # Consume all events
+ return next_tick
end
+
+ private
+ def on_transport_tail_closed(event) close_read; end
+ def on_transport_head_closed(event) close_write; end
+ def on_transport_authenticated(event) connection.user = transport.user; end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 fdc0247..91a3d2a 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'thread'
require 'set'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 30307f6..b08c667 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -14,7 +13,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
# Allow a {Receiver} to indicate the status of a received message to the {Sender}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 3a24f7a..71a4593 100644
--- a/proton-c/bindings/ruby/lib/core/disposition.rb
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 ea2b11f..bd66f7a 100644
--- a/proton-c/bindings/ruby/lib/core/endpoint.rb
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index 552a605..37a089b 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
# AMQP protocol event.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 adef927..f88b3c8 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,117 +14,113 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
-
-module Qpid
-
- module Proton
-
- module Error
-
- NONE = 0
- EOS = Cproton::PN_EOS
- ERROR = Cproton::PN_ERR
- OVERFLOW = Cproton::PN_OVERFLOW
- UNDERFLOW = Cproton::PN_UNDERFLOW
- STATE = Cproton::PN_STATE_ERR
- ARGUMENT = Cproton::PN_ARG_ERR
- TIMEOUT = Cproton::PN_TIMEOUT
- INTERRUPTED = Cproton::PN_INTR
- INPROGRESS = Cproton::PN_INPROGRESS
-
- end
-
- # Represents a generic error at the messaging level.
- #
- class ProtonError < RuntimeError
- end
-
- # Represents an end-of-stream error while messaging.
- #
- class EOSError < ProtonError
- end
-
- # Represents a data overflow exception while messaging.
- #
- class OverflowError < ProtonError
- end
-
- # Represents a data underflow exception while messaging.
- #
- class UnderflowError < ProtonError
- end
-
- # Represents an invalid, missing or illegal argument while messaging.
- #
- class ArgumentError < ProtonError
- end
-
- # Represents that the client has got into an unexpected state during
- # messaging.
- #
- class StateError < ProtonError
- end
-
- # Represents a timeout during messaging.
- #
- class TimeoutError < ProtonError
- end
-
- # Represents an interrupting during a blocking I/O operation.
- #
- class InterruptedError < ProtonError
- end
-
- class InProgressError < ProtonError
- end
-
- # Raised by instances of Transport.
- #
- class TransportError < ProtonError
- end
-
- # Raised by instances of SASL
- #
- class SASLError < TransportError
- end
-
- # Raised by Session.
- #
- class SessionError < ProtonError
- end
-
- # Raised when an attempt is made to change an attribute that is read-only.
- #
- class AttributeError < ProtonError
- end
-
- # Raised by link components.
- #
- class LinkError < ProtonError
- end
-
- class SSLError < TransportError
- end
-
- class SSLUnavailableError < SSLError
- end
-
- # Raised when a message is rejected.
- #
- class Reject < ProtonError
- end
-
- # Raised when a message is released.
- #
- class Release < ProtonError
- end
-
- # Raised when a message is aborted.
- #
- class Aborted < ProtonError
- end
+
+module Qpid::Proton
+
+ module Error
+
+ NONE = 0
+ EOS = Cproton::PN_EOS
+ ERROR = Cproton::PN_ERR
+ OVERFLOW = Cproton::PN_OVERFLOW
+ UNDERFLOW = Cproton::PN_UNDERFLOW
+ STATE = Cproton::PN_STATE_ERR
+ ARGUMENT = Cproton::PN_ARG_ERR
+ TIMEOUT = Cproton::PN_TIMEOUT
+ INTERRUPTED = Cproton::PN_INTR
+ INPROGRESS = Cproton::PN_INPROGRESS
+
+ end
+
+ # Represents a generic error at the messaging level.
+ #
+ class ProtonError < RuntimeError
+ end
+
+ # Represents an end-of-stream error while messaging.
+ #
+ class EOSError < ProtonError
+ end
+
+ # Represents a data overflow exception while messaging.
+ #
+ class OverflowError < ProtonError
+ end
+
+ # Represents a data underflow exception while messaging.
+ #
+ class UnderflowError < ProtonError
+ end
+
+ # Represents an invalid, missing or illegal argument while messaging.
+ #
+ class ArgumentError < ProtonError
+ end
+
+ # Represents that the client has got into an unexpected state during
+ # messaging.
+ #
+ class StateError < ProtonError
+ end
+
+ # Represents a timeout during messaging.
+ #
+ class TimeoutError < ProtonError
+ end
+
+ # Represents an interrupting during a blocking I/O operation.
+ #
+ class InterruptedError < ProtonError
+ end
+
+ class InProgressError < ProtonError
+ end
+
+ # Raised by instances of Transport.
+ #
+ class TransportError < ProtonError
+ end
+
+ # Raised by instances of SASL
+ #
+ class SASLError < TransportError
+ end
+
+ # Raised by Session.
+ #
+ class SessionError < ProtonError
+ end
+
+ # Raised when an attempt is made to change an attribute that is read-only.
+ #
+ class AttributeError < ProtonError
+ end
+
+ # Raised by link components.
+ #
+ class LinkError < ProtonError
+ end
+
+ class SSLError < TransportError
+ end
+
+ class SSLUnavailableError < SSLError
+ end
+
+ # Raised when a message is rejected.
+ #
+ class Reject < ProtonError
+ end
+
+ # Raised when a message is released.
+ #
+ class Release < ProtonError
+ end
+
+ # Raised when a message is aborted.
+ #
+ class Aborted < ProtonError
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index e525aa9..f8999cd 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/listener.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/listener.rb b/proton-c/bindings/ruby/lib/core/listener.rb
index 3feb44b..e69e88a 100644
--- a/proton-c/bindings/ruby/lib/core/listener.rb
+++ b/proton-c/bindings/ruby/lib/core/listener.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
# A listener for incoming connections.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 a39ab09..0f0c072 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/messaging_handler.rb b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
index 8ef9a06..7a793df 100644
--- a/proton-c/bindings/ruby/lib/core/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index df767e2..a78e5b5 100644
--- a/proton-c/bindings/ruby/lib/core/receiver.rb
+++ b/proton-c/bindings/ruby/lib/core/receiver.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 965c889..3787637 100644
--- a/proton-c/bindings/ruby/lib/core/sasl.rb
+++ b/proton-c/bindings/ruby/lib/core/sasl.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 2f45356..bef3460 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 6bed0ba..bdc128f 100644
--- a/proton-c/bindings/ruby/lib/core/session.rb
+++ b/proton-c/bindings/ruby/lib/core/session.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 0b16075..2db1c1c 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/ssl_details.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl_details.rb b/proton-c/bindings/ruby/lib/core/ssl_details.rb
index 5367c80..3f1984a 100644
--- a/proton-c/bindings/ruby/lib/core/ssl_details.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl_details.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/ssl_domain.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl_domain.rb b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
index 26b4e9d..2a3940d 100644
--- a/proton-c/bindings/ruby/lib/core/ssl_domain.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index b4927d8..b3d7c05 100644
--- a/proton-c/bindings/ruby/lib/core/terminus.rb
+++ b/proton-c/bindings/ruby/lib/core/terminus.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/tracker.rb b/proton-c/bindings/ruby/lib/core/tracker.rb
index fbecd61..7363e3a 100644
--- a/proton-c/bindings/ruby/lib/core/tracker.rb
+++ b/proton-c/bindings/ruby/lib/core/tracker.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
@@ -24,7 +23,7 @@ module Qpid::Proton
# @return [Sender] The parent {Sender} link.
def sender() link; end
- # If {#state} == {#MODIFIED} this method returns additional information
+ # If {#state} == {MODIFIED} this method returns additional information
# about re-delivery from the receiver's call to {Delivery#release}
#
# @return [Hash] See {Delivery#release} options for the meaning of hash entries.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index 4d640f0..db2a03e 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 9b12be3..4398966 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 e9c5add..e347849 100644
--- a/proton-c/bindings/ruby/lib/core/uri.rb
+++ b/proton-c/bindings/ruby/lib/core/uri.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'uri'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 88545e3..48f295c 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/handler/adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/adapter.rb b/proton-c/bindings/ruby/lib/handler/adapter.rb
index 2d9bdc8..8fe9bc5 100644
--- a/proton-c/bindings/ruby/lib/handler/adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/adapter.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
# @private
module Qpid::Proton::Handler
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index 65e0ae8..0c39429 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -1,4 +1,3 @@
-# --
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# ++
+
module Qpid::Proton::Messenger
# @deprecated use {Qpid::Proton::Container}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/messenger/subscription.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/subscription.rb b/proton-c/bindings/ruby/lib/messenger/subscription.rb
index 6d4973e..49fb50e 100644
--- a/proton-c/bindings/ruby/lib/messenger/subscription.rb
+++ b/proton-c/bindings/ruby/lib/messenger/subscription.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Messenger
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/messenger/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/tracker.rb b/proton-c/bindings/ruby/lib/messenger/tracker.rb
index 55507e5..5fb98e5 100644
--- a/proton-c/bindings/ruby/lib/messenger/tracker.rb
+++ b/proton-c/bindings/ruby/lib/messenger/tracker.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Messenger
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 6eea9ce..ab77683 100644
--- a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb
+++ b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Messenger
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 36c14a1..6164fde 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require "cproton"
require "date"
@@ -37,7 +36,7 @@ module Qpid
end
# Proton is a ruby API for sending and receiving AMQP messages in clients or servers.
- # {overveiw}[README.rdoc]
+ # See the {overview}[../file.README.html] for more.
module Proton
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 9c6b13d..8ce5ea6 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Reactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 f5c6b50..88eb26b 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# 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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 7c09d3f..fb880ba 100644
--- a/proton-c/bindings/ruby/lib/types/described.rb
+++ b/proton-c/bindings/ruby/lib/types/described.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Types
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index e6836d5..9415f86 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
#--
# Patch the Hash class to provide methods for adding its contents
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/types/strings.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/strings.rb b/proton-c/bindings/ruby/lib/types/strings.rb
index ffbea3c..3edbd80 100644
--- a/proton-c/bindings/ruby/lib/types/strings.rb
+++ b/proton-c/bindings/ruby/lib/types/strings.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Types
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 da51214..58545fb 100644
--- a/proton-c/bindings/ruby/lib/util/error_handler.rb
+++ b/proton-c/bindings/ruby/lib/util/error_handler.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Util
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 5567235..1013df8 100644
--- a/proton-c/bindings/ruby/lib/util/swig_helper.rb
+++ b/proton-c/bindings/ruby/lib/util/swig_helper.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Util
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index f4647f5..5e299dd 100644
--- a/proton-c/bindings/ruby/lib/util/timeout.rb
+++ b/proton-c/bindings/ruby/lib/util/timeout.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Util
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/lib/util/version.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/version.rb b/proton-c/bindings/ruby/lib/util/version.rb
index f9962ba..f4571a3 100644
--- a/proton-c/bindings/ruby/lib/util/version.rb
+++ b/proton-c/bindings/ruby/lib/util/version.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Util
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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
index 8537e4b..c6e0e72 100644
--- a/proton-c/bindings/ruby/lib/util/wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/wrapper.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Qpid::Proton::Util
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/spec/data_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/data_spec.rb b/proton-c/bindings/ruby/spec/data_spec.rb
index 3123f61..f4041e4 100644
--- a/proton-c/bindings/ruby/spec/data_spec.rb
+++ b/proton-c/bindings/ruby/spec/data_spec.rb
@@ -1,4 +1,3 @@
-# --
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# ++
+
require "spec_helper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/spec/exception_handling_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/exception_handling_spec.rb b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
index a78dcd9..7470e37 100644
--- a/proton-c/bindings/ruby/spec/exception_handling_spec.rb
+++ b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
@@ -1,4 +1,3 @@
-# --
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# ++
+
require "spec_helper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/spec/message_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/message_spec.rb b/proton-c/bindings/ruby/spec/message_spec.rb
index 6486d24..2951f9c 100644
--- a/proton-c/bindings/ruby/spec/message_spec.rb
+++ b/proton-c/bindings/ruby/spec/message_spec.rb
@@ -1,4 +1,3 @@
-# --
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-# ++
+
require "spec_helper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/broker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/broker.rb b/proton-c/bindings/ruby/tests/old_examples/broker.rb
index e7cc9b3..d76dfba 100644
--- a/proton-c/bindings/ruby/tests/old_examples/broker.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/broker.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/client.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/client.rb b/proton-c/bindings/ruby/tests/old_examples/client.rb
index 8c38f38..ff22e6b 100644
--- a/proton-c/bindings/ruby/tests/old_examples/client.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/client.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/direct_recv.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/direct_recv.rb b/proton-c/bindings/ruby/tests/old_examples/direct_recv.rb
index ff3366a..7281845 100644
--- a/proton-c/bindings/ruby/tests/old_examples/direct_recv.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/direct_recv.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/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 c507b46..1a7a71a 100644
--- a/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/direct_send.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/helloworld.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/helloworld.rb b/proton-c/bindings/ruby/tests/old_examples/helloworld.rb
index 9b02e8a..65b9ccc 100644
--- a/proton-c/bindings/ruby/tests/old_examples/helloworld.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/helloworld.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/helloworld_direct.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/helloworld_direct.rb b/proton-c/bindings/ruby/tests/old_examples/helloworld_direct.rb
index e98cc1f..f329723 100644
--- a/proton-c/bindings/ruby/tests/old_examples/helloworld_direct.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/helloworld_direct.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/lib/debugging.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/lib/debugging.rb b/proton-c/bindings/ruby/tests/old_examples/lib/debugging.rb
index 5065d51..4f7414e 100644
--- a/proton-c/bindings/ruby/tests/old_examples/lib/debugging.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/lib/debugging.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
module Debugging
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/lib/driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/lib/driver.rb b/proton-c/bindings/ruby/tests/old_examples/lib/driver.rb
index 4e223d0..129f499 100644
--- a/proton-c/bindings/ruby/tests/old_examples/lib/driver.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/lib/driver.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
class Driver
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/lib/qpid_examples.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/lib/qpid_examples.rb b/proton-c/bindings/ruby/tests/old_examples/lib/qpid_examples.rb
index 665812d..0a369a6 100644
--- a/proton-c/bindings/ruby/tests/old_examples/lib/qpid_examples.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/lib/qpid_examples.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require "qpid_proton"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/lib/selectable.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/lib/selectable.rb b/proton-c/bindings/ruby/tests/old_examples/lib/selectable.rb
index 779ea24..4634743 100644
--- a/proton-c/bindings/ruby/tests/old_examples/lib/selectable.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/lib/selectable.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
class Selectable
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/lib/send_and_receive.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/lib/send_and_receive.rb b/proton-c/bindings/ruby/tests/old_examples/lib/send_and_receive.rb
index 9fd7417..3b1cf4f 100644
--- a/proton-c/bindings/ruby/tests/old_examples/lib/send_and_receive.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/lib/send_and_receive.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# 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
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/server.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/server.rb b/proton-c/bindings/ruby/tests/old_examples/server.rb
index 9373272..265a63d 100644
--- a/proton-c/bindings/ruby/tests/old_examples/server.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/server.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/simple_recv.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/simple_recv.rb b/proton-c/bindings/ruby/tests/old_examples/simple_recv.rb
index 136e332..21feedd 100644
--- a/proton-c/bindings/ruby/tests/old_examples/simple_recv.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/simple_recv.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/old_examples/simple_send.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/simple_send.rb b/proton-c/bindings/ruby/tests/old_examples/simple_send.rb
index 5e5d0a6..0b84c4c 100644
--- a/proton-c/bindings/ruby/tests/old_examples/simple_send.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/simple_send.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'qpid_proton'
require 'optparse'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/test_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_adapter.rb b/proton-c/bindings/ruby/tests/test_adapter.rb
index 77aee76..c90f788 100644
--- a/proton-c/bindings/ruby/tests/test_adapter.rb
+++ b/proton-c/bindings/ruby/tests/test_adapter.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'minitest/autorun'
require 'qpid_proton'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/test_connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_connection_driver.rb b/proton-c/bindings/ruby/tests/test_connection_driver.rb
index f12076f..3617dce 100644
--- a/proton-c/bindings/ruby/tests/test_connection_driver.rb
+++ b/proton-c/bindings/ruby/tests/test_connection_driver.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -14,7 +13,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'test_tools'
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7c004d3e/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index be74be8..bfa40b1 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -1,4 +1,3 @@
-#--
# 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
@@ -15,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#++
+
require 'test_tools'
require 'minitest/unit'
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[11/50] [abbrv] qpid-proton git commit: PROTON-1687: consolidate
transport buffers in transport - Use pn_buffer_t for transport output buffer.
Posted by ac...@apache.org.
PROTON-1687: consolidate transport buffers in transport
- Use pn_buffer_t for transport output buffer.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/85755ac4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/85755ac4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/85755ac4
Branch: refs/heads/go1
Commit: 85755ac4bde591a02953d080a36a23af80287be8
Parents: 7a936e9
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Aug 16 17:32:23 2016 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri Dec 8 15:46:21 2017 -0500
----------------------------------------------------------------------
proton-c/src/core/buffer.c | 19 +++++++++++-----
proton-c/src/core/buffer.h | 3 ++-
proton-c/src/core/dispatcher.c | 6 ++---
proton-c/src/core/engine-internal.h | 7 +++---
proton-c/src/core/framing.c | 12 ++++++----
proton-c/src/core/framing.h | 4 +++-
proton-c/src/core/transport.c | 38 +++++++++++---------------------
proton-c/src/core/util.c | 12 ++++++----
proton-c/src/core/util.h | 2 ++
proton-c/src/sasl/sasl.c | 2 +-
10 files changed, 56 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/buffer.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/buffer.c b/proton-c/src/core/buffer.c
index 96c6b37..7bfc813 100644
--- a/proton-c/src/core/buffer.c
+++ b/proton-c/src/core/buffer.c
@@ -238,6 +238,11 @@ int pn_buffer_trim(pn_buffer_t *buf, size_t left, size_t right)
{
if (left + right > buf->size) return PN_ARG_ERR;
+ // In special case where we trim everything just clear buffer
+ if (left + right == buf->size) {
+ pn_buffer_clear(buf);
+ return 0;
+ }
buf->start += left;
if (buf->start >= buf->capacity)
buf->start -= buf->capacity;
@@ -301,11 +306,15 @@ pn_rwbytes_t pn_buffer_memory(pn_buffer_t *buf)
}
}
-int pn_buffer_print(pn_buffer_t *buf)
+int pn_buffer_quote(pn_buffer_t *buf, pn_string_t *str, size_t n)
{
- printf("pn_buffer(\"");
- pn_print_data(buf->bytes + pni_buffer_head(buf), pni_buffer_head_size(buf));
- pn_print_data(buf->bytes, pni_buffer_tail_size(buf));
- printf("\")");
+ size_t hsize = pni_buffer_head_size(buf);
+ size_t tsize = pni_buffer_tail_size(buf);
+ if (hsize >= n) {
+ pn_quote(str, buf->bytes + pni_buffer_head(buf), n);
+ return 0;
+ }
+ pn_quote(str, buf->bytes + pni_buffer_head(buf), hsize);
+ if (tsize-(n-hsize) > 0) pn_quote(str, buf->bytes, tsize-(n-hsize));
return 0;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/buffer.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/buffer.h b/proton-c/src/core/buffer.h
index da557ef..7193f8f 100644
--- a/proton-c/src/core/buffer.h
+++ b/proton-c/src/core/buffer.h
@@ -23,6 +23,7 @@
*/
#include <proton/import_export.h>
+#include <proton/object.h>
#include <proton/types.h>
#ifdef __cplusplus
@@ -45,7 +46,7 @@ void pn_buffer_clear(pn_buffer_t *buf);
int pn_buffer_defrag(pn_buffer_t *buf);
pn_bytes_t pn_buffer_bytes(pn_buffer_t *buf);
pn_rwbytes_t pn_buffer_memory(pn_buffer_t *buf);
-int pn_buffer_print(pn_buffer_t *buf);
+int pn_buffer_quote(pn_buffer_t *buf, pn_string_t *string, size_t n);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/dispatcher.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/dispatcher.c b/proton-c/src/core/dispatcher.c
index 36f8cc9..87e4d97 100644
--- a/proton-c/src/core/dispatcher.c
+++ b/proton-c/src/core/dispatcher.c
@@ -149,10 +149,8 @@ ssize_t pn_dispatcher_input(pn_transport_t *transport, const char *bytes, size_t
ssize_t pn_dispatcher_output(pn_transport_t *transport, char *bytes, size_t size)
{
- int n = transport->available < size ? transport->available : size;
- memmove(bytes, transport->output, n);
- memmove(transport->output, transport->output + n, transport->available - n);
- transport->available -= n;
+ int n = pn_buffer_get(transport->output_buffer, 0, size, bytes);
+ pn_buffer_trim(transport->output_buffer, n, 0);
// XXX: need to check for errors
return n;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/engine-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/engine-internal.h b/proton-c/src/core/engine-internal.h
index 39d1572..ec1603d 100644
--- a/proton-c/src/core/engine-internal.h
+++ b/proton-c/src/core/engine-internal.h
@@ -164,10 +164,9 @@ struct pn_transport_t {
pn_data_t *args;
pn_data_t *output_args;
pn_buffer_t *frame; // frame under construction
- // Temporary
- size_t capacity;
- size_t available; /* number of raw bytes pending output */
- char *output;
+
+ // Temporary - ??
+ pn_buffer_t *output_buffer;
/* statistics */
uint64_t bytes_input;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/framing.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/framing.c b/proton-c/src/core/framing.c
index 18e3c38..9f78666 100644
--- a/proton-c/src/core/framing.c
+++ b/proton-c/src/core/framing.c
@@ -83,20 +83,24 @@ ssize_t pn_read_frame(pn_frame_t *frame, const char *bytes, size_t available, ui
return size;
}
-size_t pn_write_frame(char *bytes, size_t available, pn_frame_t frame)
+size_t pn_write_frame(pn_buffer_t* buffer, pn_frame_t frame)
{
size_t size = AMQP_HEADER_SIZE + frame.ex_size + frame.size;
- if (size <= available)
+ if (size <= pn_buffer_available(buffer))
{
+ // Prepare header
+ char bytes[8];
pn_i_write32(&bytes[0], size);
int doff = (frame.ex_size + AMQP_HEADER_SIZE - 1)/4 + 1;
bytes[4] = doff;
bytes[5] = frame.type;
pn_i_write16(&bytes[6], frame.channel);
+ // Write header then rest of frame
+ pn_buffer_append(buffer, bytes, 8);
if (frame.extended)
- memmove(bytes + AMQP_HEADER_SIZE, frame.extended, frame.ex_size);
- memmove(bytes + 4*doff, frame.payload, frame.size);
+ pn_buffer_append(buffer, frame.extended, frame.ex_size);
+ pn_buffer_append(buffer, frame.payload, frame.size);
return size;
} else {
return 0;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/framing.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/framing.h b/proton-c/src/core/framing.h
index ecb88a4..792d664 100644
--- a/proton-c/src/core/framing.h
+++ b/proton-c/src/core/framing.h
@@ -22,6 +22,8 @@
*
*/
+#include "buffer.h"
+
#include <proton/import_export.h>
#include <proton/type_compat.h>
#include <proton/error.h>
@@ -39,6 +41,6 @@ typedef struct {
} pn_frame_t;
ssize_t pn_read_frame(pn_frame_t *frame, const char *bytes, size_t available, uint32_t max);
-size_t pn_write_frame(char *bytes, size_t size, pn_frame_t frame);
+size_t pn_write_frame(pn_buffer_t* buffer, pn_frame_t frame);
#endif /* framing.h */
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c
index 3538e93..21d62db 100644
--- a/proton-c/src/core/transport.c
+++ b/proton-c/src/core/transport.c
@@ -578,10 +578,8 @@ pn_transport_t *pn_transport(void)
return NULL;
}
- transport->capacity = 4*1024;
- transport->available = 0;
- transport->output = (char *) malloc(transport->capacity);
- if (!transport->output) {
+ transport->output_buffer = pn_buffer(4*1024);
+ if (!transport->output_buffer) {
pn_transport_free(transport);
return NULL;
}
@@ -682,7 +680,7 @@ static void pn_transport_finalize(void *object)
pn_data_free(transport->output_args);
pn_buffer_free(transport->frame);
pn_free(transport->context);
- free(transport->output);
+ pn_buffer_free(transport->output_buffer);
}
static void pni_post_remote_open_events(pn_transport_t *transport, pn_connection_t *connection) {
@@ -943,25 +941,20 @@ int pn_post_frame(pn_transport_t *transport, uint8_t type, uint16_t ch, const ch
return PN_ERR;
}
- pn_frame_t frame = {0,};
+ pn_frame_t frame = {AMQP_FRAME_TYPE};
frame.type = type;
frame.channel = ch;
frame.payload = buf.start;
frame.size = wr;
- size_t n;
- while (!(n = pn_write_frame(transport->output + transport->available,
- transport->capacity - transport->available, frame))) {
- transport->capacity *= 2;
- transport->output = (char *) realloc(transport->output, transport->capacity);
- }
+ pn_buffer_ensure(transport->output_buffer, AMQP_HEADER_SIZE+frame.ex_size+frame.size);
+ pn_write_frame(transport->output_buffer, frame);
transport->output_frames_ct += 1;
if (transport->trace & PN_TRACE_RAW) {
pn_string_set(transport->scratch, "RAW: \"");
- pn_quote(transport->scratch, transport->output + transport->available, n);
+ pn_buffer_quote(transport->output_buffer, transport->scratch, AMQP_HEADER_SIZE+frame.ex_size+frame.size);
pn_string_addf(transport->scratch, "\"");
pn_transport_log(transport, pn_string_get(transport->scratch));
}
- transport->available += n;
return 0;
}
@@ -1053,21 +1046,16 @@ static int pni_post_amqp_transfer_frame(pn_transport_t *transport, uint16_t ch,
frame.payload = buf.start;
frame.size = buf.size;
- size_t n;
- while (!(n = pn_write_frame(transport->output + transport->available,
- transport->capacity - transport->available, frame))) {
- transport->capacity *= 2;
- transport->output = (char *) realloc(transport->output, transport->capacity);
- }
+ pn_buffer_ensure(transport->output_buffer, AMQP_HEADER_SIZE+frame.ex_size+frame.size);
+ pn_write_frame(transport->output_buffer, frame);
transport->output_frames_ct += 1;
framecount++;
if (transport->trace & PN_TRACE_RAW) {
pn_string_set(transport->scratch, "RAW: \"");
- pn_quote(transport->scratch, transport->output + transport->available, n);
+ pn_buffer_quote(transport->output_buffer, transport->scratch, AMQP_HEADER_SIZE+frame.ex_size+frame.size);
pn_string_addf(transport->scratch, "\"");
pn_transport_log(transport, pn_string_get(transport->scratch));
}
- transport->available += n;
} while (payload->size > 0 && framecount < frame_limit);
return framecount;
@@ -2608,10 +2596,10 @@ static pn_timestamp_t pn_tick_amqp(pn_transport_t* transport, unsigned int layer
transport->last_bytes_output = transport->bytes_output;
} else if (transport->keepalive_deadline <= now) {
transport->keepalive_deadline = now + (pn_timestamp_t)(transport->remote_idle_timeout/2.0);
- if (transport->available == 0) { // no outbound data pending
+ if (pn_buffer_size(transport->output_buffer) == 0) { // no outbound data pending
// so send empty frame (and account for it!)
pn_post_frame(transport, AMQP_FRAME_TYPE, 0, "");
- transport->last_bytes_output += transport->available;
+ transport->last_bytes_output += pn_buffer_size(transport->output_buffer);
}
}
timeout = pn_timestamp_min( timeout, transport->keepalive_deadline );
@@ -2653,7 +2641,7 @@ static ssize_t pn_output_write_amqp(pn_transport_t* transport, unsigned int laye
// write out any buffered data _before_ returning PN_EOS, else we
// could truncate an outgoing Close frame containing a useful error
// status
- if (!transport->available && transport->close_sent) {
+ if (!pn_buffer_size(transport->output_buffer) && transport->close_sent) {
return PN_EOS;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/util.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/util.c b/proton-c/src/core/util.c
index 4309de3..a676e9f 100644
--- a/proton-c/src/core/util.c
+++ b/proton-c/src/core/util.c
@@ -19,15 +19,19 @@
*
*/
+#include "util.h"
+
+#include "buffer.h"
+
+#include <proton/error.h>
+#include <proton/types.h>
+#include <proton/type_compat.h>
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <proton/type_compat.h>
#include <ctype.h>
#include <string.h>
-#include <proton/error.h>
-#include <proton/types.h>
-#include "util.h"
ssize_t pn_quote_data(char *dst, size_t capacity, const char *src, size_t size)
{
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/core/util.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/util.h b/proton-c/src/core/util.h
index 4d3ba3b..78b1c4d 100644
--- a/proton-c/src/core/util.h
+++ b/proton-c/src/core/util.h
@@ -22,6 +22,8 @@
*
*/
+#include "buffer.h"
+
#include <errno.h>
#ifndef __cplusplus
#include <stdbool.h>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/85755ac4/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index fe778be..bb95429 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -637,7 +637,7 @@ static ssize_t pn_output_write_sasl(pn_transport_t* transport, unsigned int laye
pni_post_sasl_frame(transport);
- if (transport->available != 0 || !pni_sasl_is_final_output_state(sasl)) {
+ if (pn_buffer_size(transport->output_buffer) != 0 || !pni_sasl_is_final_output_state(sasl)) {
return pn_dispatcher_output(transport, bytes, available);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[42/50] [abbrv] qpid-proton git commit: PROTON-1717 [C proactor] Fix
build error in example
Posted by ac...@apache.org.
PROTON-1717 [C proactor] Fix build error in example
Fix build error on older compilers in ssl-send 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/4d16e618
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4d16e618
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4d16e618
Branch: refs/heads/go1
Commit: 4d16e6183d4d0eb39e2a29d2a3a289fef2327201
Parents: 5e4242c
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 19 14:20:22 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 19 14:45:41 2017 -0500
----------------------------------------------------------------------
examples/c/send-ssl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4d16e618/examples/c/send-ssl.c
----------------------------------------------------------------------
diff --git a/examples/c/send-ssl.c b/examples/c/send-ssl.c
index 5d3404c..92bc418 100644
--- a/examples/c/send-ssl.c
+++ b/examples/c/send-ssl.c
@@ -216,7 +216,8 @@ int main(int argc, char **argv) {
struct app_data_t app = {0};
char addr[PN_MAX_ADDR];
pn_transport_t *t = NULL;
-
+ int err;
+
app.container_id = argv[0]; /* Should be unique */
app.host = (argc > 1) ? argv[1] : "";
app.port = (argc > 2) ? argv[2] : "amqp";
@@ -229,7 +230,7 @@ int main(int argc, char **argv) {
/* Configure a transport for SSL. The transport will be freed by the proactor. */
t = pn_transport();
- int err = pn_ssl_init(pn_ssl(t), app.ssl_domain, NULL);
+ err = pn_ssl_init(pn_ssl(t), app.ssl_domain, NULL);
if (err) {
fprintf(stderr, "error initializing SSL: %s\n", pn_code(err));
return 1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[07/50] [abbrv] qpid-proton git commit: PROTON-1081: Add missing call
to pn_error_format
Posted by ac...@apache.org.
PROTON-1081: Add missing call to pn_error_format
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d80a792e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d80a792e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d80a792e
Branch: refs/heads/go1
Commit: d80a792ea06f069060da3df12a50647ef8edb714
Parents: bcd6e0d
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 08:13:15 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 08:13:15 2017 -0800
----------------------------------------------------------------------
proton-c/src/core/message.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d80a792e/proton-c/src/core/message.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c
index e1f235b..548636b 100644
--- a/proton-c/src/core/message.c
+++ b/proton-c/src/core/message.c
@@ -828,7 +828,7 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data)
err = pn_data_append(data, msg->properties);
if (err)
return pn_error_format(msg->error, err, "data error: %s",
- pn_data_error(data));
+ pn_error_text(pn_data_error(data)));
pn_data_exit(data);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[17/50] [abbrv] qpid-proton git commit: PROTON-1654: [C++ binding]
Fix testing examples on VS 2010
Posted by ac...@apache.org.
PROTON-1654: [C++ binding] Fix testing examples on VS 2010
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1c1bfadb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1c1bfadb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1c1bfadb
Branch: refs/heads/go1
Commit: 1c1bfadb4eadcc0f17ca1ad650f4d85d349ccc8c
Parents: 413e093
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Dec 13 16:22:32 2017 +0000
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed Dec 13 16:48:53 2017 +0000
----------------------------------------------------------------------
examples/cpp/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1c1bfadb/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 0019355..662bc72 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -109,7 +109,7 @@ macro(add_cpp_test name)
set(test_path "$<TARGET_FILE_DIR:broker>:$ENV{PATH}")
endif(WIN32)
set(run_env ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/proton-c/env.py ${EXAMPLE_ENV})
- add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} "HAS_CPP11=${HAS_ENOUGH_CPP11}" -- ${ARGN})
+ add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} "HAS_CPP11=$<$<BOOL:${HAS_ENOUGH_CPP11}>:1>" -- ${ARGN})
endmacro()
add_cpp_test(cpp-example-container ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v ContainerExampleTest)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[16/50] [abbrv] qpid-proton git commit: PROTON-1654: [C++ binding]
Fix building examples on VS 2010
Posted by ac...@apache.org.
PROTON-1654: [C++ binding] Fix building examples on VS 2010
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/413e0937
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/413e0937
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/413e0937
Branch: refs/heads/go1
Commit: 413e09375c21b87eab59c1ee31c63d336f89ba49
Parents: 2b03394
Author: Andrew Stitcher <as...@apache.org>
Authored: Sun Dec 10 15:27:29 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Sun Dec 10 16:22:26 2017 -0500
----------------------------------------------------------------------
examples/cpp/CMakeLists.txt | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/413e0937/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 8768f71..0019355 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -28,6 +28,21 @@ include_directories(${ProtonCpp_INCLUDE_DIRS})
link_libraries(${ProtonCpp_LIBRARIES})
add_definitions(${ProtonCpp_DEFINITIONS})
+
+macro (has_cxx_features result)
+set(${result} OFF)
+if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
+ set(${result} ON)
+ foreach(feature ${ARGN})
+ list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_${feature} N)
+ if (N EQUAL -1)
+ set(${result} OFF)
+ break()
+ endif()
+ endforeach()
+endif()
+endmacro()
+
set (BUILD_CPP_03 OFF CACHE BOOL "Compile as C++03 even when C++11 is available")
# This effectively checks for cmake version 3.1 or later
if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
@@ -35,7 +50,8 @@ if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
set(STD 98)
else ()
set(STD 11)
- set(HAS_CPP11 ON)
+ has_cxx_features(HAS_ENOUGH_CPP11 lambdas variadic_templates)
+ message(STATUS "Compiling C++11 examples: ${HAS_ENOUGH_CPP11}")
endif ()
set(CMAKE_CXX_STANDARD ${STD})
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -66,7 +82,7 @@ foreach(example
add_executable(${example} ${example}.cpp)
endforeach()
-if(HAS_CPP11)
+if(HAS_ENOUGH_CPP11)
# Examples that require C++11
foreach(example
scheduled_send
@@ -93,7 +109,7 @@ macro(add_cpp_test name)
set(test_path "$<TARGET_FILE_DIR:broker>:$ENV{PATH}")
endif(WIN32)
set(run_env ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/proton-c/env.py ${EXAMPLE_ENV})
- add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} "HAS_CPP11=${HAS_CPP11}" -- ${ARGN})
+ add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} "HAS_CPP11=${HAS_ENOUGH_CPP11}" -- ${ARGN})
endmacro()
add_cpp_test(cpp-example-container ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v ContainerExampleTest)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[44/50] [abbrv] qpid-proton git commit: PROTON-1722,
PROTON-1669: update versions for 0.20.0-SNAPSHOT
Posted by ac...@apache.org.
PROTON-1722, PROTON-1669: update versions for 0.20.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f3054e39
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f3054e39
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f3054e39
Branch: refs/heads/go1
Commit: f3054e391218a20c88ecd803f39e325388f45d82
Parents: 01917c7
Author: Robbie Gemmell <ro...@apache.org>
Authored: Tue Dec 19 19:43:16 2017 +0000
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Tue Dec 19 19:57:42 2017 +0000
----------------------------------------------------------------------
proton-c/bindings/python/docs/conf.py | 4 ++--
version.txt | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f3054e39/proton-c/bindings/python/docs/conf.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/conf.py b/proton-c/bindings/python/docs/conf.py
index a4497f5..3bdf701 100644
--- a/proton-c/bindings/python/docs/conf.py
+++ b/proton-c/bindings/python/docs/conf.py
@@ -48,9 +48,9 @@ copyright = u'2015, Apache Qpid'
# built documents.
#
# The short X.Y version.
-version = '0.19.0'
+version = '0.20.0'
# The full version, including alpha/beta/rc tags.
-release = '0.19.0'
+release = '0.20.0-SNAPSHOT'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f3054e39/version.txt
----------------------------------------------------------------------
diff --git a/version.txt b/version.txt
index 1cf0537..8bec379 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.19.0
+0.20.0-SNAPSHOT
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[39/50] [abbrv] qpid-proton git commit: Revert PROTON-1703: [cpp]
Remove auto_settle from receiver_options
Posted by ac...@apache.org.
Revert PROTON-1703: [cpp] Remove auto_settle from receiver_options
Reverted the change for binary compatibility but deprecated auto_settle
since it is a no-op on receiver. To remove at next major revision.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b9f94025
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b9f94025
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b9f94025
Branch: refs/heads/go1
Commit: b9f9402598171602ed7d3c6f7dd410906d1d0684
Parents: 38afef9
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 19 13:43:25 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 19 13:50:00 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/cpp/include/proton/receiver_options.hpp | 3 +++
proton-c/bindings/cpp/src/receiver_options.cpp | 7 +++++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b9f94025/proton-c/bindings/cpp/include/proton/receiver_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/receiver_options.hpp b/proton-c/bindings/cpp/include/proton/receiver_options.hpp
index 049fe86..2213f88 100644
--- a/proton-c/bindings/cpp/include/proton/receiver_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/receiver_options.hpp
@@ -83,6 +83,9 @@ class receiver_options {
/// default.
PN_CPP_EXTERN receiver_options& auto_accept(bool);
+ /// @deprecated not applicable to receiver, only to sender
+ PN_CPP_EXTERN receiver_options& auto_settle(bool);
+
/// Options for the source node of the receiver.
PN_CPP_EXTERN receiver_options& source(source_options&);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b9f94025/proton-c/bindings/cpp/src/receiver_options.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/receiver_options.cpp b/proton-c/bindings/cpp/src/receiver_options.cpp
index 96e2ffa..cb4ac05 100644
--- a/proton-c/bindings/cpp/src/receiver_options.cpp
+++ b/proton-c/bindings/cpp/src/receiver_options.cpp
@@ -65,6 +65,7 @@ class receiver_options::impl {
option<messaging_handler*> handler;
option<proton::delivery_mode> delivery_mode;
option<bool> auto_accept;
+ option<bool> auto_settle;
option<int> credit_window;
option<bool> dynamic_address;
option<source_options> source;
@@ -76,6 +77,7 @@ class receiver_options::impl {
if (r.uninitialized()) {
if (delivery_mode.set) set_delivery_mode(r, delivery_mode.value);
if (handler.set && handler.value) container::impl::set_handler(r, handler.value);
+ if (auto_settle.set) get_context(r).auto_settle = auto_settle.value;
if (auto_accept.set) get_context(r).auto_accept = auto_accept.value;
if (credit_window.set) get_context(r).credit_window = credit_window.value;
@@ -94,6 +96,7 @@ class receiver_options::impl {
handler.update(x.handler);
delivery_mode.update(x.delivery_mode);
auto_accept.update(x.auto_accept);
+ auto_settle.update(x.auto_settle);
credit_window.update(x.credit_window);
dynamic_address.update(x.dynamic_address);
source.update(x.source);
@@ -128,4 +131,8 @@ void receiver_options::apply(receiver& r) const { impl_->apply(r); }
const std::string* receiver_options::get_name() const {
return impl_->name.set ? &impl_->name.value : 0;
}
+
+// No-op, kept for binary compat but auto_settle is not relevant to receiver only sender.
+receiver_options& receiver_options::auto_settle(bool b) { return *this; }
+
} // namespace proton
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[47/50] [abbrv] qpid-proton git commit: PROTON-1722,
PROTON-1669: restore versions for 0.19.0-rc2
Posted by ac...@apache.org.
PROTON-1722, PROTON-1669: restore versions for 0.19.0-rc2
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fe3c38cc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fe3c38cc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fe3c38cc
Branch: refs/heads/go1
Commit: fe3c38ccf1cfb27a23793f414755befa146e7c01
Parents: 45bd573
Author: Robbie Gemmell <ro...@apache.org>
Authored: Wed Dec 20 17:44:33 2017 +0000
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Wed Dec 20 17:44:33 2017 +0000
----------------------------------------------------------------------
proton-c/bindings/python/docs/conf.py | 4 ++--
version.txt | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fe3c38cc/proton-c/bindings/python/docs/conf.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/conf.py b/proton-c/bindings/python/docs/conf.py
index 3bdf701..a4497f5 100644
--- a/proton-c/bindings/python/docs/conf.py
+++ b/proton-c/bindings/python/docs/conf.py
@@ -48,9 +48,9 @@ copyright = u'2015, Apache Qpid'
# built documents.
#
# The short X.Y version.
-version = '0.20.0'
+version = '0.19.0'
# The full version, including alpha/beta/rc tags.
-release = '0.20.0-SNAPSHOT'
+release = '0.19.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fe3c38cc/version.txt
----------------------------------------------------------------------
diff --git a/version.txt b/version.txt
index 8bec379..1cf0537 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.20.0-SNAPSHOT
+0.19.0
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[50/50] [abbrv] qpid-proton git commit: Merge tag '0.19.0' into go1
Posted by ac...@apache.org.
Merge tag '0.19.0' into go1
Update `go get` branch to release 0.19.0
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b25d21e6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b25d21e6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b25d21e6
Branch: refs/heads/go1
Commit: b25d21e6779a011e972a5f00e433e2034b793da1
Parents: 6c48527 fe3c38c
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Jan 5 11:32:52 2018 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Jan 5 11:32:52 2018 -0500
----------------------------------------------------------------------
README.md | 2 +-
amqp/interop_test.go | 11 +-
amqp/marshal.go | 201 +++++++++----
amqp/marshal_test.go | 113 +++++++
amqp/message.go | 48 ++-
amqp/message_test.go | 12 +-
amqp/types.go | 53 +++-
amqp/types_test.go | 68 +++--
amqp/unmarshal.go | 669 +++++++++++++++++++++++------------------
amqp/url_test.go | 2 +-
electron/auth_test.go | 8 +-
electron/connection.go | 2 +-
electron/electron_test.go | 10 +-
electron/receiver.go | 2 +-
electron/time.go | 2 +-
proton/engine.go | 6 +-
proton/handlers.go | 2 +-
proton/message.go | 4 +-
proton/wrappers.go | 4 +-
19 files changed, 793 insertions(+), 426 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/README.md
----------------------------------------------------------------------
diff --cc README.md
index 0977787,b1bca51..5292454
--- a/README.md
+++ b/README.md
@@@ -1,116 -1,43 +1,116 @@@
-Qpid Proton - AMQP messaging toolkit
-====================================
+# Qpid Go packages for AMQP
-Linux/OSX Build | Windows Build
-----------------|---------------
-[](https://travis-ci.org/apache/qpid-proton) | [](https://ci.appveyor.com/project/ke4qqq/qpid-proton/branch/master)
+These packages provide [Go](http://golang.org) support for sending and receiving
+AMQP messages in client or server applications. Reference documentation is
+available at: <http://godoc.org/?q=qpid.apache.org>
-Qpid Proton is a high-performance, lightweight messaging library. It can be
-used in the widest range of messaging applications, including brokers, client
-libraries, routers, bridges, proxies, and more. Proton makes it trivial to
-integrate with the AMQP 1.0 ecosystem from any platform, environment, or
-language
+They require the
+[proton-C library and header files](http://qpid.apache.org/proton) to be
- installed. On many platforms it is avaialable pre-packaged, for example on
++installed. On many platforms it is available pre-packaged, for example on
+Fedora
-Features
---------
+ dnf install qpid-proton-c-devel
- - A flexible and capable reactive messaging API
- - Full control of AMQP 1.0 protocol semantics
- - Portable C implementation with bindings to popular languages
- - Peer-to-peer and brokered messaging
- - Secure communication via SSL and SASL
+If you built proton from source, you can set environment variables to find the
+built libraries and headers as follows:
-Universal - Proton is designed to scale both up and down. Equally suitable for
-simple clients or high-powered servers, it can be deployed in simple
-peer-to-peer configurations or as part of a global federated messaging network.
+ source <build-directory>/config.sh
-Embeddable - Proton is carefully written to be portable and cross platform. It
-has minimal dependencies, and it is architected to be usable with any threading
-model, as well as with non-threaded applications. These features make it
-uniquely suited for embedding messaging capabilities into existing software.
+If you have installed the library and headers in non-standard directories, then
+add them to the following environment variables:
-Standard - Built around the AMQP 1.0 messaging standard, Proton is not only
-ideal for building out your own messaging applications but also for connecting
-them to the broader ecosystem of AMQP 1.0-based messaging applications.
+ LD_LIBRARY_PATH # directory containing the library
+ LIBRARY_PATH # directory containing the library
+ C_INCLUDE_PATH # directory containing the proton/ subdirectory with header files
-Getting Started
----------------
+There are 3 packages:
-See the included INSTALL.md file for build and install instructions and the
-DEVELOPERS file for information on how to modify and test the library code
-itself.
+[qpid.apache.org/amqp](http://godoc.org/qpid.apache.org/amqp) provides functions
+to convert AMQP messages and data types to and from Go data types. Used by both
+the proton and electron packages to manage AMQP data.
-Please see http://qpid.apache.org/proton for a more info.
+[qpid.apache.org/electron](http://godoc.org/qpid.apache.org/electron) is a
+simple, concurrent-safe API for sending and receiving messages. It can be used
+with goroutines and channels to build concurrent AMQP clients and servers.
+
+[qpid.apache.org/proton](http://godoc.org/qpid.apache.org/proton) is an
+event-driven, concurrent-unsafe package that closely follows the proton C
+API. Most Go programmers will find the
+[electron](http://godoc.org/qpid.apache.org/electron) package easier to use.
+
+See the [examples](https://github.com/apache/qpid-proton/blob/master/examples/go/README.md)
+to help you get started.
+
+Feedback is encouraged at:
+
+- Email <pr...@qpid.apache.org>
+- Create issues <https://issues.apache.org/jira/browse/PROTON>, attach patches to an issue.
+
+### Why two APIs?
+
+The `proton` API is a direct mapping of the proton C library into Go. It is
+usable but not very natural for a Go programmer because it takes an
+*event-driven* approach and has no built-in support for concurrent
+use. `electron` uses `proton` internally but provides a more Go-like API that is
+safe to use from multiple concurrent goroutines.
+
+Go encourages programs to be structured as concurrent *goroutines* that
+communicate via *channels*. Go literature distinguishes between:
+
+- *concurrency*: "keeping track of things that could be done in parallel"
+- *parallelism*: "actually doing things in parallel on multiple CPUs or cores"
+
+A Go program expresses concurrency by starting goroutines for potentially
+concurrent tasks. The Go runtime schedules the activity of goroutines onto a
+small number (possibly one) of actual parallel executions.
+
+Even with no hardware parallelism, goroutine concurrency lets the Go runtime
+order unpredictable events like file descriptors being readable/writable,
+channels having data, timers firing etc. Go automatically takes care of
+switching out goroutines that block or sleep so it is normal to write code in
+terms of blocking calls.
+
+By contrast, event-driven programming is based on polling mechanisms like
+`select`, `poll` or `epoll`. These also dispatch unpredictably ordered events to
+a single thread or a small thread pool. However this requires a different style
+of programming: "event-driven" or "reactive" programming. Go developers call it
+"inside-out" programming. In an event-driven program blocking is a big problem
+as it consumes a scarce thread of execution, so actions that take time to
+complete have to be re-structured in terms of multiple events.
+
+The promise of Go is that you can express your program in concurrent, sequential
+terms and the Go runtime will turn it inside-out for you. You can start
+goroutines for all concurrent activities. They can loop forever or block for as
+long as they need waiting for timers, IO or any unpredictable event. Go will
+interleave and schedule them efficiently onto the available parallel hardware.
+
+For example: in the `electron` API, you can send a message and wait for it to be
+acknowledged in a single function. All the information about the message, why
+you sent it, and what to do when it is acknowledged can be held in local
+variables, all the code is in a simple sequence. Other goroutines in your
+program can be sending and receiving messages concurrently, they are not
+blocked.
+
+In the `proton` API, an event handler that sends a message must return
+*immediately*, it cannot block the event loop to wait for
+acknowledgement. Acknowledgement is a separate event, so the code for handling
+it is in a different event handler. Context information about the message has to
+be stored in some non-local variable that both functions can find. This makes
+the code harder to follow.
+
+The `proton` API is important because it is the foundation for the `electron`
+API, and may be useful for programs that need to be close to the original C
+library for some reason. However the `electron` API hides the event-driven
+details behind simple, sequential, concurrent-safe methods that can be called
+from arbitrary goroutines. Under the covers, data is passed through channels to
+dedicated `proton` goroutines so user goroutines can work concurrently with the
+proton event-loop.
+
+## New to Go?
+
+If you are new to Go then these are a good place to start:
+
+- [A Tour of Go](http://tour.golang.org)
+- [Effective Go](http://golang.org/doc/effective_go.html)
+
+Then look at the tools and docs at <http://golang.org> as you need them.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/interop_test.go
----------------------------------------------------------------------
diff --cc amqp/interop_test.go
index a5fb92e,0000000..8ec6734
mode 100644,000000..100644
--- a/amqp/interop_test.go
+++ b/amqp/interop_test.go
@@@ -1,377 -1,0 +1,384 @@@
+/*
+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.
+*/
+
+// Test that conversion of Go type to/from AMQP is compatible with other
+// bindings.
+//
+package amqp
+
+import (
+ "bytes"
+ "io"
+ "io/ioutil"
+ "os"
+ "reflect"
+ "strings"
+ "testing"
+)
+
++var skipped = false
++
+func getReader(t *testing.T, name string) (r io.Reader) {
+ dir := os.Getenv("PN_INTEROP_DIR")
+ if dir == "" {
- t.Skip("no PN_INTEROP_DIR in environment")
++ if !skipped {
++ skipped = true // Don't keep repeating
++ t.Skip("no PN_INTEROP_DIR in environment")
++ } else {
++ t.SkipNow()
++ }
+ }
+ r, err := os.Open(dir + "/" + name + ".amqp")
+ if err != nil {
+ t.Fatalf("can't open %#v: %v", name, err)
+ }
+ return
+}
+
+func remaining(d *Decoder) string {
+ remainder, _ := ioutil.ReadAll(io.MultiReader(d.Buffered(), d.reader))
+ return string(remainder)
+}
+
+// checkDecode: want is the expected value, gotPtr is a pointer to a
+// instance of the same type for Decode.
+func checkDecode(d *Decoder, want interface{}, gotPtr interface{}, t *testing.T) {
+
+ if err := d.Decode(gotPtr); err != nil {
+ t.Error("Decode failed", err)
+ return
+ }
+ got := reflect.ValueOf(gotPtr).Elem().Interface()
+ if err := checkEqual(want, got); err != nil {
+ t.Error("Decode bad value:", err)
+ return
+ }
+
+ // Try round trip encoding
+ bytes, err := Marshal(want, nil)
+ if err != nil {
+ t.Error("Marshal failed", err)
+ return
+ }
+ n, err := Unmarshal(bytes, gotPtr)
+ if err != nil {
+ t.Error("Unmarshal failed", err)
+ return
+ }
+ if err := checkEqual(n, len(bytes)); err != nil {
+ t.Error("Bad unmarshal length", err)
+ return
+ }
+ got = reflect.ValueOf(gotPtr).Elem().Interface()
+ if err = checkEqual(want, got); err != nil {
+ t.Error("Bad unmarshal value", err)
+ return
+ }
+}
+
+func TestUnmarshal(t *testing.T) {
+ bytes, err := ioutil.ReadAll(getReader(t, "strings"))
+ if err != nil {
+ t.Error(err)
+ }
+ for _, want := range []string{"abc\000defg", "abcdefg", "abcdefg", "", "", ""} {
+ var got string
+ n, err := Unmarshal(bytes, &got)
+ if err != nil {
+ t.Error(err)
+ }
+ if want != got {
+ t.Errorf("%#v != %#v", want, got)
+ }
+ bytes = bytes[n:]
+ }
+}
+
+func TestPrimitivesExact(t *testing.T) {
+ d := NewDecoder(getReader(t, "primitives"))
+ // Decoding into exact types
+ var b bool
+ checkDecode(d, true, &b, t)
+ checkDecode(d, false, &b, t)
+ var u8 uint8
+ checkDecode(d, uint8(42), &u8, t)
+ var u16 uint16
+ checkDecode(d, uint16(42), &u16, t)
+ var i16 int16
+ checkDecode(d, int16(-42), &i16, t)
+ var u32 uint32
+ checkDecode(d, uint32(12345), &u32, t)
+ var i32 int32
+ checkDecode(d, int32(-12345), &i32, t)
+ var u64 uint64
+ checkDecode(d, uint64(12345), &u64, t)
+ var i64 int64
+ checkDecode(d, int64(-12345), &i64, t)
+ var f32 float32
+ checkDecode(d, float32(0.125), &f32, t)
+ var f64 float64
+ checkDecode(d, float64(0.125), &f64, t)
+}
+
+func TestPrimitivesCompatible(t *testing.T) {
+ d := NewDecoder(getReader(t, "primitives"))
+ // Decoding into compatible types
+ var b bool
+ var i int
+ var u uint
+ var f float64
+ checkDecode(d, true, &b, t)
+ checkDecode(d, false, &b, t)
+ checkDecode(d, uint(42), &u, t)
+ checkDecode(d, uint(42), &u, t)
+ checkDecode(d, -42, &i, t)
+ checkDecode(d, uint(12345), &u, t)
+ checkDecode(d, -12345, &i, t)
+ checkDecode(d, uint(12345), &u, t)
+ checkDecode(d, -12345, &i, t)
+ checkDecode(d, 0.125, &f, t)
+ checkDecode(d, 0.125, &f, t)
+}
+
+// checkDecodeValue: want is the expected value, decode into a reflect.Value
+func checkDecodeInterface(d *Decoder, want interface{}, t *testing.T) {
+
+ var got, got2 interface{}
+ if err := d.Decode(&got); err != nil {
+ t.Error("Decode failed", err)
+ return
+ }
+ if err := checkEqual(want, got); err != nil {
+ t.Error(err)
+ return
+ }
+ // Try round trip encoding
+ bytes, err := Marshal(got, nil)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ n, err := Unmarshal(bytes, &got2)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ if err := checkEqual(n, len(bytes)); err != nil {
+ t.Error(err)
+ return
+ }
+ if err := checkEqual(want, got2); err != nil {
+ t.Error(err)
+ return
+ }
+}
+
+func TestPrimitivesInterface(t *testing.T) {
+ d := NewDecoder(getReader(t, "primitives"))
+ checkDecodeInterface(d, true, t)
+ checkDecodeInterface(d, false, t)
+ checkDecodeInterface(d, uint8(42), t)
+ checkDecodeInterface(d, uint16(42), t)
+ checkDecodeInterface(d, int16(-42), t)
+ checkDecodeInterface(d, uint32(12345), t)
+ checkDecodeInterface(d, int32(-12345), t)
+ checkDecodeInterface(d, uint64(12345), t)
+ checkDecodeInterface(d, int64(-12345), t)
+ checkDecodeInterface(d, float32(0.125), t)
+ checkDecodeInterface(d, float64(0.125), t)
+}
+
+func TestStrings(t *testing.T) {
+ d := NewDecoder(getReader(t, "strings"))
+ // Test decoding as plain Go strings
+ for _, want := range []string{"abc\000defg", "abcdefg", "abcdefg", "", "", ""} {
+ var got string
+ checkDecode(d, want, &got, t)
+ }
+ remains := remaining(d)
+ if remains != "" {
+ t.Errorf("leftover: %s", remains)
+ }
+
+ // Test decoding as specific string types
+ d = NewDecoder(getReader(t, "strings"))
+ var bytes []byte
+ var str, sym string
+ checkDecode(d, []byte("abc\000defg"), &bytes, t)
+ checkDecode(d, "abcdefg", &str, t)
+ checkDecode(d, "abcdefg", &sym, t)
+ checkDecode(d, make([]byte, 0), &bytes, t)
+ checkDecode(d, "", &str, t)
+ checkDecode(d, "", &sym, t)
+ remains = remaining(d)
+ if remains != "" {
+ t.Fatalf("leftover: %s", remains)
+ }
+
+ // Test some error handling
+ d = NewDecoder(getReader(t, "strings"))
+ var s string
+ err := d.Decode(s)
+ if err == nil {
+ t.Fatal("Expected error")
+ }
+ if !strings.Contains(err.Error(), "not a pointer") {
+ t.Error(err)
+ }
+ var i int
+ err = d.Decode(&i)
+ if !strings.Contains(err.Error(), "cannot unmarshal") {
+ t.Error(err)
+ }
+ _, err = Unmarshal([]byte{}, nil)
- if !strings.Contains(err.Error(), "not enough data") {
++ if err := checkEqual(err, EndOfData); err != nil {
+ t.Error(err)
+ }
+ _, err = Unmarshal([]byte("foobar"), nil)
+ if !strings.Contains(err.Error(), "invalid-argument") {
+ t.Error(err)
+ }
+}
+
+func TestEncodeDecode(t *testing.T) {
+ type data struct {
+ s string
+ i int
+ u8 uint8
+ b bool
+ f float32
+ v interface{}
+ }
+
+ in := data{"foo", 42, 9, true, 1.234, "thing"}
+
+ buf := bytes.Buffer{}
+ e := NewEncoder(&buf)
+ if err := e.Encode(in.s); err != nil {
+ t.Error(err)
+ }
+ if err := e.Encode(in.i); err != nil {
+ t.Error(err)
+ }
+ if err := e.Encode(in.u8); err != nil {
+ t.Error(err)
+ }
+ if err := e.Encode(in.b); err != nil {
+ t.Error(err)
+ }
+ if err := e.Encode(in.f); err != nil {
+ t.Error(err)
+ }
+ if err := e.Encode(in.v); err != nil {
+ t.Error(err)
+ }
+
+ var out data
+ d := NewDecoder(&buf)
+ if err := d.Decode(&out.s); err != nil {
+ t.Error(err)
+ }
+ if err := d.Decode(&out.i); err != nil {
+ t.Error(err)
+ }
+ if err := d.Decode(&out.u8); err != nil {
+ t.Error(err)
+ }
+ if err := d.Decode(&out.b); err != nil {
+ t.Error(err)
+ }
+ if err := d.Decode(&out.f); err != nil {
+ t.Error(err)
+ }
+ if err := d.Decode(&out.v); err != nil {
+ t.Error(err)
+ }
+
+ if err := checkEqual(in, out); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestMap(t *testing.T) {
+ d := NewDecoder(getReader(t, "maps"))
+
+ // Generic map
+ var m Map
+ checkDecode(d, Map{"one": int32(1), "two": int32(2), "three": int32(3)}, &m, t)
+
+ // Interface as map
+ var i interface{}
+ checkDecode(d, Map{int32(1): "one", int32(2): "two", int32(3): "three"}, &i, t)
+
+ d = NewDecoder(getReader(t, "maps"))
+ // Specific typed map
+ var m2 map[string]int
+ checkDecode(d, map[string]int{"one": 1, "two": 2, "three": 3}, &m2, t)
+
+ // Nested map
+ m = Map{int64(1): "one", "two": int32(2), true: Map{uint8(1): true, uint8(2): false}}
+ bytes, err := Marshal(m, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = Unmarshal(bytes, &i)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = checkEqual(m, i); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestList(t *testing.T) {
+ d := NewDecoder(getReader(t, "lists"))
+ var l List
+ checkDecode(d, List{int32(32), "foo", true}, &l, t)
+ checkDecode(d, List{}, &l, t)
+}
+
+// TODO aconway 2015-09-08: the message.amqp file seems to be incorrectly coded as
+// as an AMQP string *inside* an AMQP binary?? Skip the test for now.
+func TODO_TestMessage(t *testing.T) {
+ bytes, err := ioutil.ReadAll(getReader(t, "message"))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ m, err := DecodeMessage(bytes)
+ if err != nil {
+ t.Fatal(err)
+ } else {
+ if err := checkEqual(m.Body(), "hello"); err != nil {
+ t.Error(err)
+ }
+ }
+
+ m2 := NewMessageWith("hello")
+ bytes2, err := m2.Encode(nil)
+ if err != nil {
+ t.Error(err)
+ } else {
+ if err = checkEqual(bytes, bytes2); err != nil {
+ t.Error(err)
+ }
+ }
+}
+
+// TODO aconway 2015-03-13: finish the full interop test
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/marshal.go
----------------------------------------------------------------------
diff --cc amqp/marshal.go
index ca5e380,0000000..33b30a8
mode 100644,000000..100644
--- a/amqp/marshal.go
+++ b/amqp/marshal.go
@@@ -1,281 -1,0 +1,360 @@@
+/*
+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.
+*/
+
+package amqp
+
+// #include <proton/codec.h>
+import "C"
+
+import (
+ "fmt"
+ "io"
+ "reflect"
++ "time"
+ "unsafe"
+)
+
+// Error returned if Go data cannot be marshaled as an AMQP type.
+type MarshalError struct {
+ // The Go type.
+ GoType reflect.Type
+ s string
+}
+
+func (e MarshalError) Error() string { return e.s }
+
+func newMarshalError(v interface{}, s string) *MarshalError {
+ t := reflect.TypeOf(v)
+ return &MarshalError{GoType: t, s: fmt.Sprintf("cannot marshal %s: %s", t, s)}
+}
+
+func dataMarshalError(v interface{}, data *C.pn_data_t) error {
+ if pe := PnError(C.pn_data_error(data)); pe != nil {
+ return newMarshalError(v, pe.Error())
+ }
+ return nil
+}
+
- func recoverMarshal(err *error) {
- if r := recover(); r != nil {
- if merr, ok := r.(*MarshalError); ok {
- *err = merr
- } else {
- panic(r)
- }
- }
- }
-
+/*
+Marshal encodes a Go value as AMQP data in buffer.
+If buffer is nil, or is not large enough, a new buffer is created.
+
+Returns the buffer used for encoding with len() adjusted to the actual size of data.
+
+Go types are encoded as follows
+
+ +-------------------------------------+--------------------------------------------+
+ |Go type |AMQP type |
+ +-------------------------------------+--------------------------------------------+
+ |bool |bool |
+ +-------------------------------------+--------------------------------------------+
+ |int8, int16, int32, int64 (int) |byte, short, int, long (int or long) |
+ +-------------------------------------+--------------------------------------------+
+ |uint8, uint16, uint32, uint64 (uint) |ubyte, ushort, uint, ulong (uint or ulong) |
+ +-------------------------------------+--------------------------------------------+
+ |float32, float64 |float, double. |
+ +-------------------------------------+--------------------------------------------+
+ |string |string |
+ +-------------------------------------+--------------------------------------------+
+ |[]byte, Binary |binary |
+ +-------------------------------------+--------------------------------------------+
+ |Symbol |symbol |
+ +-------------------------------------+--------------------------------------------+
++ |Char |char |
++ +-------------------------------------+--------------------------------------------+
+ |interface{} |the contained type |
+ +-------------------------------------+--------------------------------------------+
+ |nil |null |
+ +-------------------------------------+--------------------------------------------+
+ |map[K]T |map with K and T converted as above |
+ +-------------------------------------+--------------------------------------------+
+ |Map |map, may have mixed types for keys, values |
+ +-------------------------------------+--------------------------------------------+
- |[]T |list with T converted as above |
++ |AnyMap |map (See AnyMap) |
++ +-------------------------------------+--------------------------------------------+
++ |List, []interface{} |list, may have mixed-type values |
+ +-------------------------------------+--------------------------------------------+
- |List |list, may have mixed types values |
++ |[]T, [N]T |array, T is mapped as per this table |
+ +-------------------------------------+--------------------------------------------+
+ |Described |described type |
+ +-------------------------------------+--------------------------------------------+
++ |time.Time |timestamp |
++ +-------------------------------------+--------------------------------------------+
++ |UUID |uuid |
++ +-------------------------------------+--------------------------------------------+
+
- The following Go types cannot be marshaled: uintptr, function, channel, array (use slice), struct
-
- TODO: Not yet implemented:
-
- Go types: struct, complex64/128.
++The following Go types cannot be marshaled: uintptr, function, channel, struct, complex64/128
+
- AMQP types: decimal32/64/128, char, timestamp, uuid, array.
++AMQP types not yet supported:
++- decimal32/64/128,
+*/
++
+func Marshal(v interface{}, buffer []byte) (outbuf []byte, err error) {
- defer recoverMarshal(&err)
+ data := C.pn_data(0)
+ defer C.pn_data_free(data)
- marshal(v, data)
++ if err = recoverMarshal(v, data); err != nil {
++ return buffer, err
++ }
+ encode := func(buf []byte) ([]byte, error) {
+ n := int(C.pn_data_encode(data, cPtr(buf), cLen(buf)))
+ switch {
+ case n == int(C.PN_OVERFLOW):
+ return buf, overflow
+ case n < 0:
+ return buf, dataMarshalError(v, data)
+ default:
+ return buf[:n], nil
+ }
+ }
+ return encodeGrow(buffer, encode)
+}
+
- // Internal
- func MarshalUnsafe(v interface{}, pn_data unsafe.Pointer) (err error) {
- defer recoverMarshal(&err)
- marshal(v, (*C.pn_data_t)(pn_data))
++// Internal use only
++func MarshalUnsafe(v interface{}, pnData unsafe.Pointer) (err error) {
++ return recoverMarshal(v, (*C.pn_data_t)(pnData))
++}
++
++func recoverMarshal(v interface{}, data *C.pn_data_t) (err error) {
++ defer func() { // Convert panic to error return
++ if r := recover(); r != nil {
++ if err2, ok := r.(*MarshalError); ok {
++ err = err2 // Convert internal panic to error
++ } else {
++ panic(r) // Unrecognized error, continue to panic
++ }
++ }
++ }()
++ marshal(v, data) // Panics on error
+ return
+}
+
+const minEncode = 256
+
+// overflow is returned when an encoding function can't fit data in the buffer.
+var overflow = fmt.Errorf("buffer too small")
+
+// encodeFn encodes into buffer[0:len(buffer)].
+// Returns buffer with length adjusted for data encoded.
+// If buffer too small, returns overflow as error.
+type encodeFn func(buffer []byte) ([]byte, error)
+
+// encodeGrow calls encode() into buffer, if it returns overflow grows the buffer.
+// Returns the final buffer.
+func encodeGrow(buffer []byte, encode encodeFn) ([]byte, error) {
+ if buffer == nil || len(buffer) == 0 {
+ buffer = make([]byte, minEncode)
+ }
+ var err error
+ for buffer, err = encode(buffer); err == overflow; buffer, err = encode(buffer) {
+ buffer = make([]byte, 2*len(buffer))
+ }
+ return buffer, err
+}
+
- func marshal(v interface{}, data *C.pn_data_t) {
- switch v := v.(type) {
++// Marshal v to data
++func marshal(i interface{}, data *C.pn_data_t) {
++ switch v := i.(type) {
+ case nil:
+ C.pn_data_put_null(data)
+ case bool:
+ C.pn_data_put_bool(data, C.bool(v))
++
++ // Signed integers
+ case int8:
+ C.pn_data_put_byte(data, C.int8_t(v))
+ case int16:
+ C.pn_data_put_short(data, C.int16_t(v))
+ case int32:
+ C.pn_data_put_int(data, C.int32_t(v))
+ case int64:
+ C.pn_data_put_long(data, C.int64_t(v))
+ case int:
- if unsafe.Sizeof(int(0)) == 8 {
++ if intIs64 {
+ C.pn_data_put_long(data, C.int64_t(v))
+ } else {
+ C.pn_data_put_int(data, C.int32_t(v))
+ }
++
++ // Unsigned integers
+ case uint8:
+ C.pn_data_put_ubyte(data, C.uint8_t(v))
+ case uint16:
+ C.pn_data_put_ushort(data, C.uint16_t(v))
+ case uint32:
+ C.pn_data_put_uint(data, C.uint32_t(v))
+ case uint64:
+ C.pn_data_put_ulong(data, C.uint64_t(v))
+ case uint:
- if unsafe.Sizeof(int(0)) == 8 {
++ if intIs64 {
+ C.pn_data_put_ulong(data, C.uint64_t(v))
+ } else {
+ C.pn_data_put_uint(data, C.uint32_t(v))
+ }
++
++ // Floating point
+ case float32:
+ C.pn_data_put_float(data, C.float(v))
+ case float64:
+ C.pn_data_put_double(data, C.double(v))
++
++ // String-like (string, binary, symbol)
+ case string:
+ C.pn_data_put_string(data, pnBytes([]byte(v)))
+ case []byte:
+ C.pn_data_put_binary(data, pnBytes(v))
+ case Binary:
+ C.pn_data_put_binary(data, pnBytes([]byte(v)))
+ case Symbol:
+ C.pn_data_put_symbol(data, pnBytes([]byte(v)))
- case Map: // Special map type
- C.pn_data_put_map(data)
- C.pn_data_enter(data)
- for key, val := range v {
- marshal(key, data)
- marshal(val, data)
- }
- C.pn_data_exit(data)
++
++ // Other simple types
++ case time.Time:
++ C.pn_data_put_timestamp(data, C.pn_timestamp_t(v.UnixNano()/1000))
++ case UUID:
++ C.pn_data_put_uuid(data, *(*C.pn_uuid_t)(unsafe.Pointer(&v[0])))
++ case Char:
++ C.pn_data_put_char(data, (C.pn_char_t)(v))
++
++ // Described types
+ case Described:
+ C.pn_data_put_described(data)
+ C.pn_data_enter(data)
+ marshal(v.Descriptor, data)
+ marshal(v.Value, data)
+ C.pn_data_exit(data)
++
++ // Restricted type annotation-key, marshals as contained value
+ case AnnotationKey:
+ marshal(v.Get(), data)
++
++ // Special type to represent AMQP maps with keys that are illegal in Go
++ case AnyMap:
++ C.pn_data_put_map(data)
++ C.pn_data_enter(data)
++ defer C.pn_data_exit(data)
++ for _, kv := range v {
++ marshal(kv.Key, data)
++ marshal(kv.Value, data)
++ }
++
+ default:
- switch reflect.TypeOf(v).Kind() {
++ // Examine complex types (Go map, slice, array) by reflected structure
++ switch reflect.TypeOf(i).Kind() {
++
+ case reflect.Map:
- putMap(data, v)
- case reflect.Slice:
- putList(data, v)
++ m := reflect.ValueOf(v)
++ C.pn_data_put_map(data)
++ if C.pn_data_enter(data) {
++ defer C.pn_data_exit(data)
++ } else {
++ panic(dataMarshalError(i, data))
++ }
++ for _, key := range m.MapKeys() {
++ marshal(key.Interface(), data)
++ marshal(m.MapIndex(key).Interface(), data)
++ }
++
++ case reflect.Slice, reflect.Array:
++ // Note: Go array and slice are mapped the same way:
++ // if element type is an interface, map to AMQP list (mixed type)
++ // if element type is a non-interface type map to AMQP array (single type)
++ s := reflect.ValueOf(v)
++ if pnType, ok := arrayTypeMap[s.Type().Elem()]; ok {
++ C.pn_data_put_array(data, false, pnType)
++ } else {
++ C.pn_data_put_list(data)
++ }
++ C.pn_data_enter(data)
++ defer C.pn_data_exit(data)
++ for j := 0; j < s.Len(); j++ {
++ marshal(s.Index(j).Interface(), data)
++ }
++
+ default:
+ panic(newMarshalError(v, "no conversion"))
+ }
+ }
- if err := dataMarshalError(v, data); err != nil {
++ if err := dataMarshalError(i, data); err != nil {
+ panic(err)
+ }
- return
+}
+
- func clearMarshal(v interface{}, data *C.pn_data_t) {
- C.pn_data_clear(data)
- marshal(v, data)
++// Mapping froo Go element type to AMQP array type for types that can go in an AMQP array
++// NOTE: this must be kept consistent with marshal() which does the actual marshalling.
++var arrayTypeMap = map[reflect.Type]C.pn_type_t{
++ nil: C.PN_NULL,
++ reflect.TypeOf(true): C.PN_BOOL,
++
++ reflect.TypeOf(int8(0)): C.PN_BYTE,
++ reflect.TypeOf(int16(0)): C.PN_INT,
++ reflect.TypeOf(int32(0)): C.PN_SHORT,
++ reflect.TypeOf(int64(0)): C.PN_LONG,
++
++ reflect.TypeOf(uint8(0)): C.PN_UBYTE,
++ reflect.TypeOf(uint16(0)): C.PN_UINT,
++ reflect.TypeOf(uint32(0)): C.PN_USHORT,
++ reflect.TypeOf(uint64(0)): C.PN_ULONG,
++
++ reflect.TypeOf(float32(0)): C.PN_FLOAT,
++ reflect.TypeOf(float64(0)): C.PN_DOUBLE,
++
++ reflect.TypeOf(""): C.PN_STRING,
++ reflect.TypeOf((*Symbol)(nil)).Elem(): C.PN_SYMBOL,
++ reflect.TypeOf((*Binary)(nil)).Elem(): C.PN_BINARY,
++ reflect.TypeOf([]byte{}): C.PN_BINARY,
++
++ reflect.TypeOf((*time.Time)(nil)).Elem(): C.PN_TIMESTAMP,
++ reflect.TypeOf((*UUID)(nil)).Elem(): C.PN_UUID,
++ reflect.TypeOf((*Char)(nil)).Elem(): C.PN_CHAR,
+}
+
- func putMap(data *C.pn_data_t, v interface{}) {
- mapValue := reflect.ValueOf(v)
- C.pn_data_put_map(data)
- C.pn_data_enter(data)
- for _, key := range mapValue.MapKeys() {
- marshal(key.Interface(), data)
- marshal(mapValue.MapIndex(key).Interface(), data)
++// Compute mapping of int/uint at runtime as they depend on execution environment.
++func init() {
++ if intIs64 {
++ arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_LONG
++ arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_ULONG
++ } else {
++ arrayTypeMap[reflect.TypeOf(int(0))] = C.PN_INT
++ arrayTypeMap[reflect.TypeOf(uint(0))] = C.PN_UINT
+ }
- C.pn_data_exit(data)
+}
+
- func putList(data *C.pn_data_t, v interface{}) {
- listValue := reflect.ValueOf(v)
- C.pn_data_put_list(data)
- C.pn_data_enter(data)
- for i := 0; i < listValue.Len(); i++ {
- marshal(listValue.Index(i).Interface(), data)
- }
- C.pn_data_exit(data)
++func clearMarshal(v interface{}, data *C.pn_data_t) {
++ C.pn_data_clear(data)
++ marshal(v, data)
+}
+
+// Encoder encodes AMQP values to an io.Writer
+type Encoder struct {
+ writer io.Writer
+ buffer []byte
+}
+
+// New encoder returns a new encoder that writes to w.
+func NewEncoder(w io.Writer) *Encoder {
+ return &Encoder{w, make([]byte, minEncode)}
+}
+
+func (e *Encoder) Encode(v interface{}) (err error) {
+ e.buffer, err = Marshal(v, e.buffer)
+ if err == nil {
+ _, err = e.writer.Write(e.buffer)
+ }
+ return err
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/marshal_test.go
----------------------------------------------------------------------
diff --cc amqp/marshal_test.go
index d8e0711,0000000..e679cc3
mode 100644,000000..100644
--- a/amqp/marshal_test.go
+++ b/amqp/marshal_test.go
@@@ -1,90 -1,0 +1,203 @@@
+/*
+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.
+*/
+
+package amqp
+
+import (
++ "strings"
+ "testing"
+)
+
+func TestSymbolKey(t *testing.T) {
+ bytes, err := Marshal(AnnotationKeySymbol("foo"), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var k AnnotationKey
+ if _, err := Unmarshal(bytes, &k); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual("foo", string(k.Get().(Symbol))); err != nil {
+ t.Error(err)
+ }
+ var sym Symbol
+ if _, err := Unmarshal(bytes, &sym); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual("foo", sym.String()); err != nil {
+ t.Error(err)
+ }
+
+}
+
+func TestStringKey(t *testing.T) {
+ bytes, err := Marshal(AnnotationKeyString("foo"), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var k AnnotationKey
+ if _, err := Unmarshal(bytes, &k); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual("foo", string(k.Get().(Symbol))); err != nil {
+ t.Error(err)
+ }
+ var s string
+ if _, err := Unmarshal(bytes, &s); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual("foo", s); err != nil {
+ t.Error(err)
+ }
+
+}
+
+func TestIntKey(t *testing.T) {
+ bytes, err := Marshal(AnnotationKeyUint64(12345), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var k AnnotationKey
+ if _, err := Unmarshal(bytes, &k); err != nil {
+ t.Error(err)
+ }
+ if 12345 != k.Get().(uint64) {
+ t.Errorf("(%T)%v != (%T)%v", 12345, k.Get().(uint64))
+ }
+ var n uint64
+ if _, err := Unmarshal(bytes, &n); err != nil {
+ t.Error(err)
+ }
+ if 12345 != n {
+ t.Errorf("%v != %v", 12345, k.Get().(uint64))
+ }
+
+}
++
++func TestMapToMap(t *testing.T) {
++ in := Map{"k": "v", "x": "y", true: false, int8(3): uint64(24)}
++ if bytes, err := Marshal(in, nil); err == nil {
++ var out Map
++ if _, err := Unmarshal(bytes, &out); err == nil {
++ if err = checkEqual(in, out); err != nil {
++ t.Error(err)
++ }
++ } else {
++ t.Error(err)
++ }
++ }
++}
++
++func TestMapToInterface(t *testing.T) {
++ in := Map{"k": "v", "x": "y", true: false, int8(3): uint64(24)}
++ if bytes, err := Marshal(in, nil); err == nil {
++ var out interface{}
++ if _, err := Unmarshal(bytes, &out); err == nil {
++ if err = checkEqual(in, out); err != nil {
++ t.Error(err)
++ }
++ } else {
++ t.Error(err)
++ }
++ }
++}
++
++func TestAnyMap(t *testing.T) {
++ // nil
++ bytes, err := Marshal(AnyMap(nil), nil)
++ if err != nil {
++ t.Error(err)
++ }
++ var out AnyMap
++ if _, err := Unmarshal(bytes, &out); err != nil {
++ t.Error(err)
++ }
++ if err = checkEqual(AnyMap(nil), out); err != nil {
++ t.Error(err)
++ }
++
++ // empty
++ bytes, err = Marshal(AnyMap{}, nil)
++ if err != nil {
++ t.Error(err)
++ }
++ if _, err := Unmarshal(bytes, &out); err != nil {
++ t.Error(err)
++ }
++ if err = checkEqual(AnyMap(nil), out); err != nil {
++ t.Error(err)
++ }
++
++ // with data
++ in := AnyMap{{"k", "v"}, {true, false}}
++ bytes, err = Marshal(in, nil)
++ if err != nil {
++ t.Error(err)
++ }
++ if _, err := Unmarshal(bytes, &out); err != nil {
++ t.Error(err)
++ }
++ if err = checkEqual(in, out); err != nil {
++ t.Error(err)
++ }
++}
++
++func TestBadMap(t *testing.T) {
++ // unmarshal map with invalid keys
++ in := AnyMap{{"k", "v"}, {[]string{"x", "y"}, "invalid-key"}}
++ bytes, err := Marshal(in, nil)
++ if err != nil {
++ t.Error(err)
++ }
++ m := Map{}
++ // Should fail to unmarshal to a map
++ if _, err := Unmarshal(bytes, &m); err != nil {
++ if !strings.Contains(err.Error(), "key []string{\"x\", \"y\"} is not comparable") {
++ t.Error(err)
++ }
++ } else {
++ t.Error("expected error")
++ }
++ // Should unmarshal to an AnyMap
++ var out AnyMap
++ if _, err := Unmarshal(bytes, &out); err != nil {
++ t.Error(err)
++ } else if err = checkEqual(in, out); err != nil {
++ t.Error(err)
++ }
++ // Should unmarshal to interface{} as AnyMap
++ var v interface{}
++ if _, err := Unmarshal(bytes, &v); err != nil {
++ t.Error(err)
++ } else if err = checkEqual(in, v); err != nil {
++ t.Error(err)
++ }
++ // Round trip from interface to interface
++ in = AnyMap{{[]int8{1, 2, 3}, "bad-key"}, {int16(1), "duplicate-1"}, {int16(1), "duplicate-2"}}
++ bytes, err = Marshal(interface{}(in), nil)
++ if err != nil {
++ t.Error(err)
++ }
++ v = nil
++ if _, err := Unmarshal(bytes, &v); err != nil {
++ t.Error(err)
++ } else if err = checkEqual(in, v); err != nil {
++ t.Error(err)
++ }
++}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/message.go
----------------------------------------------------------------------
diff --cc amqp/message.go
index d1ad2eb,0000000..389fa37
mode 100644,000000..100644
--- a/amqp/message.go
+++ b/amqp/message.go
@@@ -1,402 -1,0 +1,420 @@@
+/*
+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.
+*/
+
+package amqp
+
+// #include <proton/codec.h>
+// #include <proton/types.h>
+// #include <proton/message.h>
+// #include <stdlib.h>
+//
+// /* Helper for setting message string fields */
+// typedef int (*set_fn)(pn_message_t*, const char*);
+// int msg_set_str(pn_message_t* m, char* s, set_fn set) {
+// int result = set(m, s);
+// free(s);
+// return result;
+// }
+//
+import "C"
+
+import (
+ "fmt"
+ "runtime"
+ "time"
+)
+
+// Message is the interface to an AMQP message.
+type Message interface {
+ // Durable indicates that any parties taking responsibility
+ // for the message must durably store the content.
+ Durable() bool
+ SetDurable(bool)
+
+ // Priority impacts ordering guarantees. Within a
+ // given ordered context, higher priority messages may jump ahead of
+ // lower priority messages.
+ Priority() uint8
+ SetPriority(uint8)
+
+ // TTL or Time To Live, a message it may be dropped after this duration
+ TTL() time.Duration
+ SetTTL(time.Duration)
+
+ // FirstAcquirer indicates
+ // that the recipient of the message is the first recipient to acquire
+ // the message, i.e. there have been no failed delivery attempts to
+ // other acquirers. Note that this does not mean the message has not
+ // been delivered to, but not acquired, by other recipients.
+ FirstAcquirer() bool
+ SetFirstAcquirer(bool)
+
+ // DeliveryCount tracks how many attempts have been made to
+ // delivery a message.
+ DeliveryCount() uint32
+ SetDeliveryCount(uint32)
+
+ // MessageId provides a unique identifier for a message.
+ // it can be an a string, an unsigned long, a uuid or a
+ // binary value.
+ MessageId() interface{}
+ SetMessageId(interface{})
+
+ UserId() string
+ SetUserId(string)
+
+ Address() string
+ SetAddress(string)
+
+ Subject() string
+ SetSubject(string)
+
+ ReplyTo() string
+ SetReplyTo(string)
+
+ // CorrelationId is set on correlated request and response messages. It can be
+ // an a string, an unsigned long, a uuid or a binary value.
+ CorrelationId() interface{}
+ SetCorrelationId(interface{})
+
+ ContentType() string
+ SetContentType(string)
+
+ ContentEncoding() string
+ SetContentEncoding(string)
+
- // ExpiryTime indicates an absoulte time when the message may be dropped.
++ // ExpiryTime indicates an absolute time when the message may be dropped.
+ // A Zero time (i.e. t.isZero() == true) indicates a message never expires.
+ ExpiryTime() time.Time
+ SetExpiryTime(time.Time)
+
+ CreationTime() time.Time
+ SetCreationTime(time.Time)
+
+ GroupId() string
+ SetGroupId(string)
+
+ GroupSequence() int32
+ SetGroupSequence(int32)
+
+ ReplyToGroupId() string
+ SetReplyToGroupId(string)
+
+ // Property map set by the application to be carried with the message.
+ // Values must be simple types (not maps, lists or sequences)
+ ApplicationProperties() map[string]interface{}
+ SetApplicationProperties(map[string]interface{})
+
+ // Per-delivery annotations to provide delivery instructions.
+ // May be added or removed by intermediaries during delivery.
+ DeliveryAnnotations() map[AnnotationKey]interface{}
+ SetDeliveryAnnotations(map[AnnotationKey]interface{})
+
+ // Message annotations added as part of the bare message at creation, usually
+ // by an AMQP library. See ApplicationProperties() for adding application data.
+ MessageAnnotations() map[AnnotationKey]interface{}
+ SetMessageAnnotations(map[AnnotationKey]interface{})
+
+ // Inferred indicates how the message content
+ // is encoded into AMQP sections. If inferred is true then binary and
+ // list values in the body of the message will be encoded as AMQP DATA
+ // and AMQP SEQUENCE sections, respectively. If inferred is false,
+ // then all values in the body of the message will be encoded as AMQP
+ // VALUE sections regardless of their type.
+ Inferred() bool
+ SetInferred(bool)
+
+ // Marshal a Go value into the message body. See amqp.Marshal() for details.
+ Marshal(interface{})
+
+ // Unmarshal the message body into the value pointed to by v. See amqp.Unmarshal() for details.
+ Unmarshal(interface{})
+
- // Body value resulting from the default unmarshalling of message body as interface{}
++ // Body value resulting from the default unmarshaling of message body as interface{}
+ Body() interface{}
+
+ // Encode encodes the message as AMQP data. If buffer is non-nil and is large enough
+ // the message is encoded into it, otherwise a new buffer is created.
+ // Returns the buffer containing the message.
+ Encode(buffer []byte) ([]byte, error)
+
+ // Decode data into this message. Overwrites an existing message content.
+ Decode(buffer []byte) error
+
+ // Clear the message contents.
+ Clear()
+
+ // Copy the contents of another message to this one.
+ Copy(m Message) error
+
+ // Deprecated: use DeliveryAnnotations() for a more type-safe interface
+ Instructions() map[string]interface{}
+ SetInstructions(v map[string]interface{})
+
+ // Deprecated: use MessageAnnotations() for a more type-safe interface
+ Annotations() map[string]interface{}
+ SetAnnotations(v map[string]interface{})
+
+ // Deprecated: use ApplicationProperties() for a more type-safe interface
+ Properties() map[string]interface{}
+ SetProperties(v map[string]interface{})
+}
+
+type message struct{ pn *C.pn_message_t }
+
+func freeMessage(m *message) {
+ C.pn_message_free(m.pn)
+ m.pn = nil
+}
+
+// NewMessage creates a new message instance.
+func NewMessage() Message {
+ m := &message{C.pn_message()}
+ runtime.SetFinalizer(m, freeMessage)
+ return m
+}
+
+// NewMessageWith creates a message with value as the body. Equivalent to
+// m := NewMessage(); m.Marshal(body)
+func NewMessageWith(value interface{}) Message {
+ m := NewMessage()
+ m.Marshal(value)
+ return m
+}
+
+func (m *message) Clear() { C.pn_message_clear(m.pn) }
+
+func (m *message) Copy(x Message) error {
+ if data, err := x.Encode(nil); err == nil {
+ return m.Decode(data)
+ } else {
+ return err
+ }
+}
+
+// ==== message get functions
+
+func rewindGet(data *C.pn_data_t) (v interface{}) {
+ C.pn_data_rewind(data)
+ C.pn_data_next(data)
+ unmarshal(&v, data)
+ return v
+}
+
+func (m *message) Inferred() bool { return bool(C.pn_message_is_inferred(m.pn)) }
+func (m *message) Durable() bool { return bool(C.pn_message_is_durable(m.pn)) }
+func (m *message) Priority() uint8 { return uint8(C.pn_message_get_priority(m.pn)) }
+func (m *message) TTL() time.Duration {
+ return time.Duration(C.pn_message_get_ttl(m.pn)) * time.Millisecond
+}
+func (m *message) FirstAcquirer() bool { return bool(C.pn_message_is_first_acquirer(m.pn)) }
+func (m *message) DeliveryCount() uint32 { return uint32(C.pn_message_get_delivery_count(m.pn)) }
+func (m *message) MessageId() interface{} { return rewindGet(C.pn_message_id(m.pn)) }
+func (m *message) UserId() string { return goString(C.pn_message_get_user_id(m.pn)) }
+func (m *message) Address() string { return C.GoString(C.pn_message_get_address(m.pn)) }
+func (m *message) Subject() string { return C.GoString(C.pn_message_get_subject(m.pn)) }
+func (m *message) ReplyTo() string { return C.GoString(C.pn_message_get_reply_to(m.pn)) }
+func (m *message) CorrelationId() interface{} { return rewindGet(C.pn_message_correlation_id(m.pn)) }
+func (m *message) ContentType() string { return C.GoString(C.pn_message_get_content_type(m.pn)) }
+func (m *message) ContentEncoding() string { return C.GoString(C.pn_message_get_content_encoding(m.pn)) }
+
+func (m *message) ExpiryTime() time.Time {
+ return time.Unix(0, int64(time.Millisecond*time.Duration(C.pn_message_get_expiry_time(m.pn))))
+}
+func (m *message) CreationTime() time.Time {
+ return time.Unix(0, int64(time.Millisecond)*int64(C.pn_message_get_creation_time(m.pn)))
+}
+func (m *message) GroupId() string { return C.GoString(C.pn_message_get_group_id(m.pn)) }
+func (m *message) GroupSequence() int32 { return int32(C.pn_message_get_group_sequence(m.pn)) }
+func (m *message) ReplyToGroupId() string { return C.GoString(C.pn_message_get_reply_to_group_id(m.pn)) }
+
+func getAnnotations(data *C.pn_data_t) (v map[AnnotationKey]interface{}) {
- C.pn_data_rewind(data)
- C.pn_data_next(data)
- unmarshal(&v, data)
++ if C.pn_data_size(data) > 0 {
++ C.pn_data_rewind(data)
++ C.pn_data_next(data)
++ unmarshal(&v, data)
++ }
+ return v
+}
+
+func (m *message) DeliveryAnnotations() map[AnnotationKey]interface{} {
+ return getAnnotations(C.pn_message_instructions(m.pn))
+}
+func (m *message) MessageAnnotations() map[AnnotationKey]interface{} {
+ return getAnnotations(C.pn_message_annotations(m.pn))
+}
+
+func (m *message) ApplicationProperties() map[string]interface{} {
+ var v map[string]interface{}
+ data := C.pn_message_properties(m.pn)
- C.pn_data_rewind(data)
- C.pn_data_next(data)
- unmarshal(&v, data)
++ if C.pn_data_size(data) > 0 {
++ C.pn_data_rewind(data)
++ C.pn_data_next(data)
++ unmarshal(&v, data)
++ }
+ return v
+}
+
+// ==== message set methods
+
+func setData(v interface{}, data *C.pn_data_t) {
+ C.pn_data_clear(data)
+ marshal(v, data)
+}
+
+func (m *message) SetInferred(b bool) { C.pn_message_set_inferred(m.pn, C.bool(b)) }
+func (m *message) SetDurable(b bool) { C.pn_message_set_durable(m.pn, C.bool(b)) }
+func (m *message) SetPriority(b uint8) { C.pn_message_set_priority(m.pn, C.uint8_t(b)) }
+func (m *message) SetTTL(d time.Duration) {
+ C.pn_message_set_ttl(m.pn, C.pn_millis_t(d/time.Millisecond))
+}
+func (m *message) SetFirstAcquirer(b bool) { C.pn_message_set_first_acquirer(m.pn, C.bool(b)) }
+func (m *message) SetDeliveryCount(c uint32) { C.pn_message_set_delivery_count(m.pn, C.uint32_t(c)) }
+func (m *message) SetMessageId(id interface{}) { setData(id, C.pn_message_id(m.pn)) }
+func (m *message) SetUserId(s string) { C.pn_message_set_user_id(m.pn, pnBytes(([]byte)(s))) }
+func (m *message) SetAddress(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_address))
+}
+func (m *message) SetSubject(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_subject))
+}
+func (m *message) SetReplyTo(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_reply_to))
+}
+func (m *message) SetCorrelationId(c interface{}) { setData(c, C.pn_message_correlation_id(m.pn)) }
+func (m *message) SetContentType(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_content_type))
+}
+func (m *message) SetContentEncoding(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_content_encoding))
+}
+func (m *message) SetExpiryTime(t time.Time) { C.pn_message_set_expiry_time(m.pn, pnTime(t)) }
+func (m *message) SetCreationTime(t time.Time) { C.pn_message_set_creation_time(m.pn, pnTime(t)) }
+func (m *message) SetGroupId(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_group_id))
+}
+func (m *message) SetGroupSequence(s int32) {
+ C.pn_message_set_group_sequence(m.pn, C.pn_sequence_t(s))
+}
+func (m *message) SetReplyToGroupId(s string) {
+ C.msg_set_str(m.pn, C.CString(s), C.set_fn(C.pn_message_set_reply_to_group_id))
+}
+
+func (m *message) SetDeliveryAnnotations(v map[AnnotationKey]interface{}) {
+ setData(v, C.pn_message_instructions(m.pn))
+}
+func (m *message) SetMessageAnnotations(v map[AnnotationKey]interface{}) {
+ setData(v, C.pn_message_annotations(m.pn))
+}
+func (m *message) SetApplicationProperties(v map[string]interface{}) {
+ setData(v, C.pn_message_properties(m.pn))
+}
+
- // Marshal/Unmarshal body
- func (m *message) Marshal(v interface{}) { clearMarshal(v, C.pn_message_body(m.pn)) }
- func (m *message) Unmarshal(v interface{}) { rewindUnmarshal(v, C.pn_message_body(m.pn)) }
- func (m *message) Body() (v interface{}) { m.Unmarshal(&v); return }
++// Marshal body from v
++func (m *message) Marshal(v interface{}) { clearMarshal(v, C.pn_message_body(m.pn)) }
++
++// Unmarshal body to v, which must be a pointer to a value. See amqp.Unmarshal
++func (m *message) Unmarshal(v interface{}) {
++ data := C.pn_message_body(m.pn)
++ if C.pn_data_size(data) > 0 {
++ C.pn_data_rewind(data)
++ C.pn_data_next(data)
++ unmarshal(v, data)
++ }
++ return
++}
++
++// Return the body value as an interface
++func (m *message) Body() (v interface{}) { m.Unmarshal(&v); return }
+
+func (m *message) Decode(data []byte) error {
+ m.Clear()
+ if len(data) == 0 {
+ return fmt.Errorf("empty buffer for decode")
+ }
+ if C.pn_message_decode(m.pn, cPtr(data), cLen(data)) < 0 {
+ return fmt.Errorf("decoding message: %s", PnError(C.pn_message_error(m.pn)))
+ }
+ return nil
+}
+
+func DecodeMessage(data []byte) (m Message, err error) {
+ m = NewMessage()
+ err = m.Decode(data)
+ return
+}
+
+func (m *message) Encode(buffer []byte) ([]byte, error) {
+ encode := func(buf []byte) ([]byte, error) {
+ len := cLen(buf)
+ result := C.pn_message_encode(m.pn, cPtr(buf), &len)
+ switch {
+ case result == C.PN_OVERFLOW:
+ return buf, overflow
+ case result < 0:
+ return buf, fmt.Errorf("cannot encode message: %s", PnErrorCode(result))
+ default:
+ return buf[:len], nil
+ }
+ }
+ return encodeGrow(buffer, encode)
+}
+
+// TODO aconway 2015-09-14: Multi-section messages.
+
+// TODO aconway 2016-09-09: Message.String() use inspect.
+
+// ==== Deprecated functions
+func oldGetAnnotations(data *C.pn_data_t) (v map[string]interface{}) {
- C.pn_data_rewind(data)
- C.pn_data_next(data)
- unmarshal(&v, data)
++ if C.pn_data_size(data) > 0 {
++ C.pn_data_rewind(data)
++ C.pn_data_next(data)
++ unmarshal(&v, data)
++ }
+ return v
+}
+
+func (m *message) Instructions() map[string]interface{} {
+ return oldGetAnnotations(C.pn_message_instructions(m.pn))
+}
+func (m *message) Annotations() map[string]interface{} {
+ return oldGetAnnotations(C.pn_message_annotations(m.pn))
+}
+func (m *message) Properties() map[string]interface{} {
+ return oldGetAnnotations(C.pn_message_properties(m.pn))
+}
+
+// Convert old string-keyed annotations to an AnnotationKey map
+func fixAnnotations(old map[string]interface{}) (annotations map[AnnotationKey]interface{}) {
+ annotations = make(map[AnnotationKey]interface{})
+ for k, v := range old {
+ annotations[AnnotationKeyString(k)] = v
+ }
+ return
+}
+
+func (m *message) SetInstructions(v map[string]interface{}) {
+ setData(fixAnnotations(v), C.pn_message_instructions(m.pn))
+}
+func (m *message) SetAnnotations(v map[string]interface{}) {
+ setData(fixAnnotations(v), C.pn_message_annotations(m.pn))
+}
+func (m *message) SetProperties(v map[string]interface{}) {
+ setData(fixAnnotations(v), C.pn_message_properties(m.pn))
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/message_test.go
----------------------------------------------------------------------
diff --cc amqp/message_test.go
index bfebfa1,0000000..3585dd8
mode 100644,000000..100644
--- a/amqp/message_test.go
+++ b/amqp/message_test.go
@@@ -1,201 -1,0 +1,201 @@@
+/*
+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.
+*/
+
+package amqp
+
+import (
+ "testing"
+ "time"
+)
+
+func roundTrip(m Message) error {
+ buffer, err := m.Encode(nil)
+ if err != nil {
+ return err
+ }
+ m2, err := DecodeMessage(buffer)
+ if err != nil {
+ return err
+ }
+ return checkEqual(m, m2)
+}
+
+func TestDefaultMessage(t *testing.T) {
+ m := NewMessage()
+ // Check defaults
+ for _, data := range [][]interface{}{
+ {m.Inferred(), false},
+ {m.Durable(), false},
+ {m.Priority(), uint8(4)},
+ {m.TTL(), time.Duration(0)},
+ {m.UserId(), ""},
+ {m.Address(), ""},
+ {m.Subject(), ""},
+ {m.ReplyTo(), ""},
+ {m.ContentType(), ""},
+ {m.ContentEncoding(), ""},
+ {m.GroupId(), ""},
+ {m.GroupSequence(), int32(0)},
+ {m.ReplyToGroupId(), ""},
+ {m.MessageId(), nil},
+ {m.CorrelationId(), nil},
- {m.DeliveryAnnotations(), map[AnnotationKey]interface{}{}},
- {m.MessageAnnotations(), map[AnnotationKey]interface{}{}},
- {m.ApplicationProperties(), map[string]interface{}{}},
++ {m.DeliveryAnnotations(), map[AnnotationKey]interface{}(nil)},
++ {m.MessageAnnotations(), map[AnnotationKey]interface{}(nil)},
++ {m.ApplicationProperties(), map[string]interface{}(nil)},
+
+ // Deprecated
- {m.Instructions(), map[string]interface{}{}},
- {m.Annotations(), map[string]interface{}{}},
- {m.Properties(), map[string]interface{}{}},
++ {m.Instructions(), map[string]interface{}(nil)},
++ {m.Annotations(), map[string]interface{}(nil)},
++ {m.Properties(), map[string]interface{}(nil)},
+ {m.Body(), nil},
+ } {
+ if err := checkEqual(data[0], data[1]); err != nil {
+ t.Error(err)
+ }
+ }
+ if err := roundTrip(m); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestMessageRoundTrip(t *testing.T) {
+ m := NewMessage()
+ m.SetInferred(false)
+ m.SetDurable(true)
+ m.SetPriority(42)
+ m.SetTTL(0)
+ m.SetUserId("user")
+ m.SetAddress("address")
+ m.SetSubject("subject")
+ m.SetReplyTo("replyto")
+ m.SetContentType("content")
+ m.SetContentEncoding("encoding")
+ m.SetGroupId("group")
+ m.SetGroupSequence(42)
+ m.SetReplyToGroupId("replytogroup")
+ m.SetMessageId("id")
+ m.SetCorrelationId("correlation")
+ m.SetDeliveryAnnotations(map[AnnotationKey]interface{}{AnnotationKeySymbol("instructions"): "foo"})
+ m.SetMessageAnnotations(map[AnnotationKey]interface{}{AnnotationKeySymbol("annotations"): "bar"})
+ m.SetApplicationProperties(map[string]interface{}{"int": int32(32), "bool": true})
+ m.Marshal("hello")
+
+ for _, data := range [][]interface{}{
+ {m.Inferred(), false},
+ {m.Durable(), true},
+ {m.Priority(), uint8(42)},
+ {m.TTL(), time.Duration(0)},
+ {m.UserId(), "user"},
+ {m.Address(), "address"},
+ {m.Subject(), "subject"},
+ {m.ReplyTo(), "replyto"},
+ {m.ContentType(), "content"},
+ {m.ContentEncoding(), "encoding"},
+ {m.GroupId(), "group"},
+ {m.GroupSequence(), int32(42)},
+ {m.ReplyToGroupId(), "replytogroup"},
+ {m.MessageId(), "id"},
+ {m.CorrelationId(), "correlation"},
+
+ {m.DeliveryAnnotations(), map[AnnotationKey]interface{}{AnnotationKeySymbol("instructions"): "foo"}},
+ {m.MessageAnnotations(), map[AnnotationKey]interface{}{AnnotationKeySymbol("annotations"): "bar"}},
+ {m.ApplicationProperties(), map[string]interface{}{"int": int32(32), "bool": true}},
+ {m.Body(), "hello"},
+
+ // Deprecated
+ {m.Instructions(), map[string]interface{}{"instructions": "foo"}},
+ {m.Annotations(), map[string]interface{}{"annotations": "bar"}},
+ } {
+ if err := checkEqual(data[0], data[1]); err != nil {
+ t.Error(err)
+ }
+ }
+ if err := roundTrip(m); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestDeprecated(t *testing.T) {
+ m := NewMessage()
+
+ m.SetInstructions(map[string]interface{}{"instructions": "foo"})
+ m.SetAnnotations(map[string]interface{}{"annotations": "bar"})
+ m.SetProperties(map[string]interface{}{"int": int32(32), "bool": true})
+
+ for _, data := range [][]interface{}{
+ {m.DeliveryAnnotations(), map[AnnotationKey]interface{}{AnnotationKeySymbol("instructions"): "foo"}},
+ {m.MessageAnnotations(), map[AnnotationKey]interface{}{AnnotationKeySymbol("annotations"): "bar"}},
+ {m.ApplicationProperties(), map[string]interface{}{"int": int32(32), "bool": true}},
+
+ {m.Instructions(), map[string]interface{}{"instructions": "foo"}},
+ {m.Annotations(), map[string]interface{}{"annotations": "bar"}},
+ {m.Properties(), map[string]interface{}{"int": int32(32), "bool": true}},
+ } {
+ if err := checkEqual(data[0], data[1]); err != nil {
+ t.Error(err)
+ }
+ }
+ if err := roundTrip(m); err != nil {
+ t.Error(err)
+ }
+}
+
+func TestMessageBodyTypes(t *testing.T) {
+ var s string
+ var body interface{}
+ var i int64
+
+ m := NewMessageWith(int64(42))
+ m.Unmarshal(&body)
+ m.Unmarshal(&i)
+ if err := checkEqual(body.(int64), int64(42)); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(i, int64(42)); err != nil {
+ t.Error(err)
+ }
+
+ m = NewMessageWith("hello")
+ m.Unmarshal(&s)
+ m.Unmarshal(&body)
+ if err := checkEqual(s, "hello"); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(body.(string), "hello"); err != nil {
+ t.Error(err)
+ }
+ if err := roundTrip(m); err != nil {
+ t.Error(err)
+ }
+
+ m = NewMessageWith(Binary("bin"))
+ m.Unmarshal(&s)
+ m.Unmarshal(&body)
+ if err := checkEqual(body.(Binary), Binary("bin")); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(s, "bin"); err != nil {
+ t.Error(err)
+ }
+ if err := roundTrip(m); err != nil {
+ t.Error(err)
+ }
+
+ // TODO aconway 2015-09-08: array etc.
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/types.go
----------------------------------------------------------------------
diff --cc amqp/types.go
index 9d41de6,0000000..a1fe2ac
mode 100644,000000..100644
--- a/amqp/types.go
+++ b/amqp/types.go
@@@ -1,221 -1,0 +1,250 @@@
+/*
+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.
+*/
+
+package amqp
+
+// #include <proton/codec.h>
+import "C"
+
+import (
+ "bytes"
+ "fmt"
- "reflect"
+ "time"
+ "unsafe"
+)
+
+func (t C.pn_type_t) String() string {
+ switch C.pn_type_t(t) {
+ case C.PN_NULL:
+ return "null"
+ case C.PN_BOOL:
+ return "bool"
+ case C.PN_UBYTE:
+ return "ubyte"
+ case C.PN_BYTE:
+ return "byte"
+ case C.PN_USHORT:
+ return "ushort"
+ case C.PN_SHORT:
+ return "short"
+ case C.PN_CHAR:
+ return "char"
+ case C.PN_UINT:
+ return "uint"
+ case C.PN_INT:
+ return "int"
+ case C.PN_ULONG:
+ return "ulong"
+ case C.PN_LONG:
+ return "long"
+ case C.PN_TIMESTAMP:
+ return "timestamp"
+ case C.PN_FLOAT:
+ return "float"
+ case C.PN_DOUBLE:
+ return "double"
+ case C.PN_DECIMAL32:
+ return "decimal32"
+ case C.PN_DECIMAL64:
+ return "decimal64"
+ case C.PN_DECIMAL128:
+ return "decimal128"
+ case C.PN_UUID:
+ return "uuid"
+ case C.PN_BINARY:
+ return "binary"
+ case C.PN_STRING:
+ return "string"
+ case C.PN_SYMBOL:
+ return "symbol"
+ case C.PN_DESCRIBED:
+ return "described"
+ case C.PN_ARRAY:
+ return "array"
+ case C.PN_LIST:
+ return "list"
+ case C.PN_MAP:
+ return "map"
+ default:
+ return fmt.Sprintf("<bad-type %v>", int(t))
+ }
+}
+
- // Go types
- var (
- bytesType = reflect.TypeOf([]byte{})
- valueType = reflect.TypeOf(reflect.Value{})
- )
-
- // TODO aconway 2015-04-08: can't handle AMQP maps with key types that are not valid Go map keys.
-
- // Map is a generic map that can have mixed key and value types and so can represent any AMQP map
++// The AMQP map type. A generic map that can have mixed-type keys and values.
+type Map map[interface{}]interface{}
+
- // List is a generic list that can hold mixed values and can represent any AMQP list.
++// The most general AMQP map type, for unusual interoperability cases.
++//
++// This is not a Go Map but a sequence of {key, value} pairs.
+//
++// An AnyMap lets you control or examine the encoded ordering of key,value pairs
++// and use key values that are not legal as Go map keys.
++//
++// The amqp.Map, or plain Go map types are easier to use for most cases.
++type AnyMap []KeyValue
++
++// Return a Map constructed from an AnyMap.
++// Panic if the AnyMap has key values that are not valid Go map keys (e.g. maps, slices)
++func (a AnyMap) Map() (m Map) {
++ for _, kv := range a {
++ m[kv.Key] = kv.Value
++ }
++ return
++}
++
++// KeyValue pair, used by AnyMap
++type KeyValue struct{ Key, Value interface{} }
++
++// The AMQP list type. A generic list that can hold mixed-type values.
+type List []interface{}
+
++// The generic AMQP array type, used to unmarshal an array with nested array,
++// map or list elements. Arrays of simple type T unmarshal to []T
++type Array []interface{}
++
+// Symbol is a string that is encoded as an AMQP symbol
+type Symbol string
+
+func (s Symbol) String() string { return string(s) }
+func (s Symbol) GoString() string { return fmt.Sprintf("s\"%s\"", s) }
+
+// Binary is a string that is encoded as an AMQP binary.
+// It is a string rather than a byte[] because byte[] is not hashable and can't be used as
+// a map key, AMQP frequently uses binary types as map keys. It can convert to and from []byte
+type Binary string
+
+func (b Binary) String() string { return string(b) }
+func (b Binary) GoString() string { return fmt.Sprintf("b\"%s\"", b) }
+
+// GoString for Map prints values with their types, useful for debugging.
+func (m Map) GoString() string {
+ out := &bytes.Buffer{}
+ fmt.Fprintf(out, "%T{", m)
+ i := len(m)
+ for k, v := range m {
+ fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
+ i--
+ if i > 0 {
+ fmt.Fprint(out, ", ")
+ }
+ }
+ fmt.Fprint(out, "}")
+ return out.String()
+}
+
+// GoString for List prints values with their types, useful for debugging.
+func (l List) GoString() string {
+ out := &bytes.Buffer{}
+ fmt.Fprintf(out, "%T{", l)
+ for i := 0; i < len(l); i++ {
+ fmt.Fprintf(out, "%T(%#v)", l[i], l[i])
+ if i == len(l)-1 {
+ fmt.Fprint(out, ", ")
+ }
+ }
+ fmt.Fprint(out, "}")
+ return out.String()
+}
+
+// pnTime converts Go time.Time to Proton millisecond Unix time.
+func pnTime(t time.Time) C.pn_timestamp_t {
+ secs := t.Unix()
- // Note: sub-second accuracy is not guaraunteed if the Unix time in
++ // Note: sub-second accuracy is not guaranteed if the Unix time in
+ // nanoseconds cannot be represented by an int64 (sometime around year 2260)
+ msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
+ return C.pn_timestamp_t(secs*1000 + msecs)
+}
+
+// goTime converts a pn_timestamp_t to a Go time.Time.
+func goTime(t C.pn_timestamp_t) time.Time {
+ secs := int64(t) / 1000
+ nsecs := (int64(t) % 1000) * int64(time.Millisecond)
+ return time.Unix(secs, nsecs)
+}
+
+func goBytes(cBytes C.pn_bytes_t) (bytes []byte) {
+ if cBytes.start != nil {
+ bytes = C.GoBytes(unsafe.Pointer(cBytes.start), C.int(cBytes.size))
+ }
+ return
+}
+
+func goString(cBytes C.pn_bytes_t) (str string) {
+ if cBytes.start != nil {
+ str = C.GoStringN(cBytes.start, C.int(cBytes.size))
+ }
+ return
+}
+
+func pnBytes(b []byte) C.pn_bytes_t {
+ if len(b) == 0 {
+ return C.pn_bytes_t{0, nil}
+ } else {
+ return C.pn_bytes_t{C.size_t(len(b)), (*C.char)(unsafe.Pointer(&b[0]))}
+ }
+}
+
+func cPtr(b []byte) *C.char {
+ if len(b) == 0 {
+ return nil
+ }
+ return (*C.char)(unsafe.Pointer(&b[0]))
+}
+
+func cLen(b []byte) C.size_t {
+ return C.size_t(len(b))
+}
+
+// AnnotationKey is used as a map key for AMQP annotation maps which are
+// allowed to have keys that are either symbol or ulong but no other type.
+//
+type AnnotationKey struct {
+ value interface{}
+}
+
+func AnnotationKeySymbol(v Symbol) AnnotationKey { return AnnotationKey{v} }
+func AnnotationKeyUint64(v uint64) AnnotationKey { return AnnotationKey{v} }
+func AnnotationKeyString(v string) AnnotationKey { return AnnotationKey{Symbol(v)} }
+
+// Returns the value which must be Symbol, uint64 or nil
+func (k AnnotationKey) Get() interface{} { return k.value }
+
+func (k AnnotationKey) String() string { return fmt.Sprintf("%v", k.Get()) }
+
+// Described represents an AMQP described type, which is really
+// just a pair of AMQP values - the first is treated as a "descriptor",
+// and is normally a string or ulong providing information about the type.
+// The second is the "value" and can be any AMQP value.
+type Described struct {
+ Descriptor interface{}
+ Value interface{}
+}
++
++// UUID is an AMQP 128-bit Universally Unique Identifier, as defined by RFC-4122 section 4.1.2
++type UUID [16]byte
++
++func (u UUID) String() string {
++ return fmt.Sprintf("UUID(%x-%x-%x-%x-%x)", u[0:4], u[4:6], u[6:8], u[8:10], u[10:])
++}
++
++// Char is an AMQP unicode character, equivalent to a Go rune.
++// It is defined as a distinct type so it can be distinguished from an AMQP int
++type Char rune
++
++const intIs64 = unsafe.Sizeof(int(0)) == 8
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/amqp/types_test.go
----------------------------------------------------------------------
diff --cc amqp/types_test.go
index 959a558,0000000..efa6e59
mode 100644,000000..100644
--- a/amqp/types_test.go
+++ b/amqp/types_test.go
@@@ -1,197 -1,0 +1,219 @@@
+/*
+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.
+*/
+
+package amqp
+
+import (
+ "fmt"
+ "reflect"
+ "testing"
++ "time"
+)
+
+func checkEqual(want interface{}, got interface{}) error {
+ if !reflect.DeepEqual(want, got) {
+ return fmt.Errorf("%#v != %#v", want, got)
+ }
+ return nil
+}
+
- func checkUnmarshal(marshalled []byte, v interface{}) error {
- got, err := Unmarshal(marshalled, v)
++func checkUnmarshal(marshaled []byte, v interface{}) error {
++ got, err := Unmarshal(marshaled, v)
+ if err != nil {
+ return err
+ }
- if got != len(marshalled) {
- return fmt.Errorf("Wanted to Unmarshal %v bytes, got %v", len(marshalled), got)
++ if got != len(marshaled) {
++ return fmt.Errorf("Wanted to Unmarshal %v bytes, got %v", len(marshaled), got)
+ }
+ return nil
+}
+
+func ExampleKey() {
+ var k AnnotationKey = AnnotationKeySymbol(Symbol("foo"))
+ fmt.Println(k.Get().(Symbol))
+ k = AnnotationKeyUint64(42)
+ fmt.Println(k.Get().(uint64))
+ // Output:
+ // foo
+ // 42
+}
+
++var timeValue = time.Now().Round(time.Millisecond)
++
+// Values that are unchanged by a marshal/unmarshal round-trip from interface{}
+// to interface{}
+var rtValues = []interface{}{
+ true,
+ int8(-8), int16(-16), int32(-32), int64(-64),
+ uint8(8), uint16(16), uint32(32), uint64(64),
+ float32(0.32), float64(0.64),
+ "string", Binary("Binary"), Symbol("symbol"),
+ nil,
++ Described{"D", "V"},
++ timeValue,
++ UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
++ Char('a'),
+ Map{"V": "X"},
++ Map{},
+ List{"V", int32(1)},
- Described{"D", "V"},
++ List{},
++ []string{"a", "b", "c"},
++ []int8{},
++ AnyMap{{[]int8{1, 2, 3}, "bad-key"}, {int16(1), "duplicate-1"}, {int16(1), "duplicate-2"}},
+}
+
- // Go values that unmarshal as an equivalent value but a different type
- // if unmarshalled to interface{}.
++// Go values that round-trip if unmarshalled back to the same type they were
++// marshalled from, but unmarshal to interface{} as a different default type.
+var oddValues = []interface{}{
- int(-99), uint(99), // [u]int32|64
++ int(-99), // int32|64 depending on platform
++ uint(99), // int32|64 depending on platform
+ []byte("byte"), // amqp.Binary
+ map[string]int{"str": 99}, // amqp.Map
- []string{"a", "b"}, // amqp.List
++ []Map{Map{}}, // amqp.Array - the generic array
++ AnyMap(nil), // Map
+}
+
+var allValues = append(rtValues, oddValues...)
+
+// %v formatted representation of allValues
+var vstrings = []string{
+ // for rtValues
+ "true",
+ "-8", "-16", "-32", "-64",
+ "8", "16", "32", "64",
+ "0.32", "0.64",
+ "string", "Binary", "symbol",
+ "<nil>",
++ "{D V}",
++ fmt.Sprintf("%v", timeValue),
++ "UUID(01020304-0506-0708-090a-0b0c0d0e0f10)",
++ fmt.Sprintf("%v", 'a'),
+ "map[V:X]",
++ "map[]",
+ "[V 1]",
- "{D V}",
++ "[]",
++ "[a b c]",
++ "[]",
++ "[{[1 2 3] bad-key} {1 duplicate-1} {1 duplicate-2}]",
+ // for oddValues
+ "-99", "99",
+ "[98 121 116 101]", /*"byte"*/
+ "map[str:99]",
- "[a b]",
++ "[map[]]",
++ "[]",
+}
+
+// Round-trip encoding test
+func TestTypesRoundTrip(t *testing.T) {
+ for _, x := range rtValues {
+ marshalled, err := Marshal(x, nil)
+ if err != nil {
+ t.Error(err)
+ }
+ var v interface{}
+ if err := checkUnmarshal(marshalled, &v); err != nil {
+ t.Error(err)
+ }
- if err := checkEqual(v, x); err != nil {
- t.Error(t, err)
++ if err := checkEqual(x, v); err != nil {
++ t.Error(err)
+ }
+ }
+}
+
+// Round trip from T to T where T is the type of the value.
+func TestTypesRoundTripAll(t *testing.T) {
+ for _, x := range allValues {
- marshalled, err := Marshal(x, nil)
++ marshaled, err := Marshal(x, nil)
+ if err != nil {
+ t.Error(err)
+ }
+ if x == nil { // We can't create an instance of nil to unmarshal to.
+ continue
+ }
+ vp := reflect.New(reflect.TypeOf(x)) // v points to a Zero of the same type as x
- if err := checkUnmarshal(marshalled, vp.Interface()); err != nil {
++ if err := checkUnmarshal(marshaled, vp.Interface()); err != nil {
+ t.Error(err)
+ }
+ v := vp.Elem().Interface()
- if err := checkEqual(v, x); err != nil {
++ if err := checkEqual(x, v); err != nil {
+ t.Error(err)
+ }
+ }
+}
+
+func TestTypesPrint(t *testing.T) {
+ // Default %v representations of rtValues and oddValues
+ for i, x := range allValues {
+ if s := fmt.Sprintf("%v", x); vstrings[i] != s {
+ t.Errorf("printing %T: want %v, got %v", x, vstrings[i], s)
+ }
+ }
+}
+
+func TestDescribed(t *testing.T) {
+ want := Described{"D", "V"}
- marshalled, _ := Marshal(want, nil)
++ marshaled, _ := Marshal(want, nil)
+
+ // Unmarshal to Described type
+ var d Described
- if err := checkUnmarshal(marshalled, &d); err != nil {
++ if err := checkUnmarshal(marshaled, &d); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(want, d); err != nil {
+ t.Error(err)
+ }
+
+ // Unmarshal to interface{}
+ var i interface{}
- if err := checkUnmarshal(marshalled, &i); err != nil {
++ if err := checkUnmarshal(marshaled, &i); err != nil {
+ t.Error(err)
+ }
+ if _, ok := i.(Described); !ok {
+ t.Errorf("Expected Described, got %T(%v)", i, i)
+ }
+ if err := checkEqual(want, i); err != nil {
+ t.Error(err)
+ }
+
+ // Unmarshal value only (drop descriptor) to the value type
+ var s string
- if err := checkUnmarshal(marshalled, &s); err != nil {
++ if err := checkUnmarshal(marshaled, &s); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(want.Value, s); err != nil {
+ t.Error(err)
+ }
+
+ // Nested described types
+ want = Described{Described{int64(123), true}, "foo"}
- marshalled, _ = Marshal(want, nil)
- if err := checkUnmarshal(marshalled, &d); err != nil {
++ marshaled, _ = Marshal(want, nil)
++ if err := checkUnmarshal(marshaled, &d); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(want, d); err != nil {
+ t.Error(err)
+ }
+ // Nested to interface
- if err := checkUnmarshal(marshalled, &i); err != nil {
++ if err := checkUnmarshal(marshaled, &i); err != nil {
+ t.Error(err)
+ }
+ if err := checkEqual(want, i); err != nil {
+ t.Error(err)
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[04/50] [abbrv] qpid-proton git commit: PROTON-1711: Make build/test
work without any SSL implementation - Added missing stub function - Skip ssl
test if there is no ssl impl.
Posted by ac...@apache.org.
PROTON-1711: Make build/test work without any SSL implementation
- Added missing stub function
- Skip ssl test if there is no ssl impl.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b57acda8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b57acda8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b57acda8
Branch: refs/heads/go1
Commit: b57acda836c2cb91ad948171d3f5e117e3f67a06
Parents: 7c004d3
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Dec 7 16:56:06 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu Dec 7 16:56:06 2017 -0500
----------------------------------------------------------------------
proton-c/src/ssl/ssl_stub.c | 5 +++++
proton-c/src/tests/ssl.c | 5 +++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b57acda8/proton-c/src/ssl/ssl_stub.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/ssl_stub.c b/proton-c/src/ssl/ssl_stub.c
index 8607b88..0a6a13f 100644
--- a/proton-c/src/ssl/ssl_stub.c
+++ b/proton-c/src/ssl/ssl_stub.c
@@ -125,6 +125,11 @@ int pn_ssl_domain_set_ciphers(pn_ssl_domain_t *domain, const char *ciphers)
return -1;
}
+int pn_ssl_domain_set_protocols(pn_ssl_domain_t* domain, const char* protocols)
+{
+ return -1;
+}
+
bool pn_ssl_allow_unsecured(pn_ssl_t *ssl)
{
return true;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b57acda8/proton-c/src/tests/ssl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/ssl.c b/proton-c/src/tests/ssl.c
index 8b8616a..9acb362 100644
--- a/proton-c/src/tests/ssl.c
+++ b/proton-c/src/tests/ssl.c
@@ -59,6 +59,11 @@ static void test_ssl_protocols(test_t *t)
int main(int argc, char **argv) {
int failed = 0;
+ // Don't run these tests if ssl functionality wasn't compiled
+ if (!pn_ssl_present()) {
+ fprintf(stderr, "No SSL implementation to test\n");
+ return failed;
+ }
#if !defined(_WIN32)
RUN_ARGV_TEST(failed, t, test_ssl_protocols(&t));
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[20/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] idle
time-out conversion
Posted by ac...@apache.org.
PROTON-1537: [ruby] idle time-out conversion
Idiomatic ruby expresses intervals in seconds, which can be Float or Rational
for sub-second intervals.
Use seconds in the :idle_timeout connection options and Connection#idle_timeout.
Transport remains in milliseconds but is no longer a user-facing API.
Conversion is done using Rational to preserve millisecond accuracy, although
the user is free to use Float if rounding is not a concern.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/4678e74b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4678e74b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4678e74b
Branch: refs/heads/go1
Commit: 4678e74bce48ea7b2457ba801128365c7be8b5bd
Parents: cf4a3f6
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 11 11:24:43 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:48 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 16 +++++
.../bindings/ruby/lib/core/connection_driver.rb | 20 ++++---
proton-c/bindings/ruby/lib/core/transport.rb | 18 +++++-
proton-c/bindings/ruby/tests/test_adapter.rb | 3 +-
.../ruby/tests/test_connection_driver.rb | 62 ++++++++++----------
proton-c/bindings/ruby/tests/test_tools.rb | 33 +++++++++--
6 files changed, 103 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/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 ed82dc8..55873dd 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -133,6 +133,17 @@ module Qpid::Proton
Codec::Data.from_object(Cproton.pn_connection_properties(@impl), opts[:properties])
end
+ # Idle-timeout advertised by the remote peer, in seconds.
+ # Set by {Connection#open} with the +:idle_timeout+ option.
+ # @return [Numeric] Idle-timeout advertised by the remote peer, in seconds.
+ # @return [nil] if The peer does not advertise an idle time-out
+ # @option :idle_timeout (see {#open})
+ def idle_timeout()
+ if transport && (t = transport.remote_idle_timeout)
+ Rational(t, 1000) # More precise than Float
+ end
+ end
+
# @private Generate a unique link name, internal use only.
def link_name()
@link_prefix + "/" + (@link_count += 1).to_s(16)
@@ -259,6 +270,11 @@ module Qpid::Proton
Cproton.pn_error_code(Cproton.pn_connection_error(@impl))
end
+ # @private Generate a unique link name, internal use only.
+ def link_name()
+ @link_prefix + "/" + (@link_count += 1).to_s(16)
+ end
+
protected
def _local_condition
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index 29bd299..b796d4d 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -97,7 +97,9 @@ module Qpid::Proton
# Non-blocking write to {#io}
# IO errors are returned as transport errors by {#event}, not raised
def write
- n = @io.write_nonblock(Cproton.pn_connection_driver_write_buffer(@impl))
+ data = Cproton.pn_connection_driver_write_buffer(@impl)
+ return unless data && data.size > 0
+ n = @io.write_nonblock(data)
Cproton.pn_connection_driver_write_done(@impl, n) if n > 0
rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
# Try again later.
@@ -175,8 +177,13 @@ module Qpid::Proton
attr_reader :handler
# Dispatch all events available from {#event} to {#handler}
- def dispatch() each_event do |e|
- e.dispatch self # See private on_transport_ methods below
+ def dispatch()
+ each_event do |e|
+ case e.method # Events that affect the driver
+ when :on_transport_tail_closed then close_read
+ when :on_transport_head_closed then close_write
+ when :on_transport_authenticated then connection.user = transport.user
+ end
e.dispatch @adapter
end
end
@@ -190,13 +197,8 @@ module Qpid::Proton
next_tick = tick(now)
dispatch # Generate data for write
write
- dispatch # Consume all events
+ dispatch # Consume events generated by write
return next_tick
end
-
- private
- def on_transport_tail_closed(event) close_read; end
- def on_transport_head_closed(event) close_write; end
- def on_transport_authenticated(event) connection.user = transport.user; end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/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 c1593a0..f840f3f 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -103,11 +103,19 @@ module Qpid::Proton
# @!attribute idle_timeout
#
- # @return [Integer] The idle timeout.
+ # @deprecated use {Connection#open} with the +:idle_timeout+ option to set
+ # the timeout, and {Connection#idle_timeout} to query the remote timeout.
+ #
+ # The Connection timeout values are in *seconds* and are automatically
+ # converted.
+ #
+ # @return [Integer] The idle timeout in *milliseconds*.
#
proton_set_get :idle_timeout
- # @!attribute [r] remote_idle_timeout
+ # @!attribute [r] remote_idle_timeout in milliseconds
+ #
+ # @deprecated Use {Connection#idle_timeout} to query the remote timeout.
#
# @return [Integer] The idle timeout for the transport's remote peer.
#
@@ -397,7 +405,11 @@ module Qpid::Proton
end
self.channel_max= opts[:channel_max] if opts.include? :channel_max
self.max_frame_size= opts[:max_frame_size] if opts.include? :max_frame_size
- self.idle_timeout= opts[:idle_timeout] if opts.include? :idle_timeout
+ # NOTE: The idle_timeout option is in Numeric *seconds*, can be Integer, Float or Rational.
+ # This is consistent with idiomatic ruby.
+ # The transport #idle_timeout property is in *milliseconds* passed direct to C.
+ # Direct use of the transport is deprecated.
+ self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? :idle_timeout
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/proton-c/bindings/ruby/tests/test_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_adapter.rb b/proton-c/bindings/ruby/tests/test_adapter.rb
index 50f46c3..62ef109 100644
--- a/proton-c/bindings/ruby/tests/test_adapter.rb
+++ b/proton-c/bindings/ruby/tests/test_adapter.rb
@@ -77,7 +77,8 @@ class TestOldHandler < Minitest::Test
assert_equal [:on_session_opening], @sh.names
assert_equal [], @ch.names
clear
- @d.client.connection.close; @d.run
+ @d.client.connection.close;
+ 3.times { @d.process }
assert_equal [:on_connection_closing], @sh.names
assert_equal [], @ch.names
@d.server.connection.close; @d.run
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/proton-c/bindings/ruby/tests/test_connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_connection_driver.rb b/proton-c/bindings/ruby/tests/test_connection_driver.rb
index 3617dce..a9982b5 100644
--- a/proton-c/bindings/ruby/tests/test_connection_driver.rb
+++ b/proton-c/bindings/ruby/tests/test_connection_driver.rb
@@ -21,10 +21,6 @@ include Qpid::Proton
class HandlerDriverTest < Minitest::Test
- def setup
- @sockets = Socket.pair(:LOCAL, :STREAM, 0)
- end
-
def test_send_recv
send_class = Class.new(MessagingHandler) do
attr_reader :accepted
@@ -38,35 +34,39 @@ class HandlerDriverTest < Minitest::Test
def on_message(event) @message = event.message; event.connection.close; end
end
- sender = HandlerDriver.new(@sockets[0], send_class.new)
- sender.connection.open(:container_id => "sender");
- sender.connection.open_sender()
- receiver = HandlerDriver.new(@sockets[1], recv_class.new)
- drivers = [sender, receiver]
-
- until drivers.all? { |d| d.finished? }
- rd = drivers.select {|d| d.can_read? }
- wr = drivers.select {|d| d.can_write? }
- IO.select(rd, wr)
- drivers.each do |d|
- d.process
- end
- end
- assert_equal(receiver.handler.message.body, "foo")
- assert(sender.handler.accepted)
+ d = DriverPair.new(send_class.new, recv_class.new)
+ d.client.connection.open(:container_id => "sender");
+ d.client.connection.open_sender()
+ d.run
+ assert_equal(d.server.handler.message.body, "foo")
+ assert(d.client.handler.accepted)
end
def test_idle
- drivers = [HandlerDriver.new(@sockets[0], nil), HandlerDriver.new(@sockets[1], nil)]
- opts = {:idle_timeout=>10}
- drivers[0].transport.apply(opts)
- assert_equal 10, drivers[0].transport.idle_timeout
- drivers[0].connection.open(opts)
- drivers[1].transport.set_server
- now = Time.now
- drivers.each { |d| d.process(now) } until drivers[0].connection.open?
- assert_equal(10, drivers[0].transport.idle_timeout)
- assert_equal(5, drivers[1].transport.remote_idle_timeout) # proton changes the value
- assert_in_delta(10, (drivers[0].tick(now) - now)*1000, 1)
+
+ d = DriverPair.new(UnhandledHandler.new, UnhandledHandler.new)
+ ms = 444
+ secs = Rational(ms, 1000) # Use rationals to keep it accurate
+ opts = {:idle_timeout => secs}
+ d.client.transport.apply(opts)
+ assert_equal(ms, d.client.transport.idle_timeout) # Transport converts to ms
+ d.server.transport.set_server
+ d.client.connection.open(opts)
+
+ start = Time.at(1) # Dummy timeline
+ tick = d.run start # Process all IO events
+ assert_equal(secs/4, tick - start)
+ assert_equal [:on_connection_opened], d.client.handler.calls
+ assert_equal [:on_connection_opening, :on_connection_opened], d.server.handler.calls
+ assert_equal (ms), d.client.transport.idle_timeout
+ assert_equal (ms/2), d.server.transport.remote_idle_timeout # proton changes the value
+ assert_equal (secs/2), d.server.connection.idle_timeout
+
+ # Now update the time till we get connections closing
+ d.each { |x| x.handler.calls.clear }
+ d.run(start + secs - 0.001) # Should nothing, timeout not reached
+ assert_equal [[],[]], d.collect { |x| x.handler.calls }
+ d.run(start + secs*2) # After 2x timeout, connections should close
+ assert_equal [[:on_transport_error, :on_transport_closed], [:on_connection_error, :on_connection_closed, :on_transport_closed]], d.collect { |x| x.handler.calls }
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4678e74b/proton-c/bindings/ruby/tests/test_tools.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_tools.rb b/proton-c/bindings/ruby/tests/test_tools.rb
index bc9c1d9..ad4a7cb 100644
--- a/proton-c/bindings/ruby/tests/test_tools.rb
+++ b/proton-c/bindings/ruby/tests/test_tools.rb
@@ -108,13 +108,20 @@ class DriverPair < Array
alias client first
alias server last
- # Run till there is nothing to do
- def run
- begin
- each { |d| d.process }
- end while (IO.select(self, [], [], 0) rescue nil)
+ # Process each driver once, return time of next timed event
+ def process(now = Time.now, max_time=nil)
+ t = collect { |d| d.process(now) }.compact.min
+ t = max_time if max_time && t > max_time
+ t
end
+ # Run till there is no IO activity - does not handle waiting for timed events
+ # but does pass +now+ to process and returns the min returned timed event time
+ def run(now=Time.now)
+ t = process(now) # Generate initial IO activity and get initial next-time
+ t = process(now, t) while (IO.select(self, [], [], 0) rescue nil)
+ t = process(now, t) # Final gulp to finish off events
+ end
end
# Container that listens on a random port for a single connection
@@ -129,3 +136,19 @@ class TestContainer < Container
def port() @server.addr[1]; end
def url() "amqp://:#{port}"; end
end
+
+# Raw handler to record on_xxx calls via on_unhandled.
+# Handy as a base for raw test handlers
+class UnhandledHandler
+ def initialize() @calls =[]; end
+ def on_unhandled(name, args) @calls << name; end
+ attr_reader :calls
+
+ # Ruby mechanics to capture on_xxx calls
+
+ def method_missing(name, *args)
+ if respond_to_missing?(name) then on_unhandled(name, *args) else super end;
+ end
+ def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[38/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fix typo
in messaging_adapter.rb code
Posted by ac...@apache.org.
PROTON-1537: [ruby] Fix typo in messaging_adapter.rb 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/38afef9d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/38afef9d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/38afef9d
Branch: refs/heads/go1
Commit: 38afef9d2d6a09d15a489d3223190fedb8bb09c0
Parents: bf8d90e
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 19 10:08:46 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 19 10:10:45 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/handler/messaging_adapter.rb | 2 +-
proton-c/bindings/ruby/tests/test_delivery.rb | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38afef9d/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
index 92f92e1..acd08e9 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
@@ -91,7 +91,7 @@ module Qpid::Proton
rescue Reject
d.reject unless d.settled?
rescue Release
- d.release unless d.settled
+ d.release unless d.settled?
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/38afef9d/proton-c/bindings/ruby/tests/test_delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_delivery.rb b/proton-c/bindings/ruby/tests/test_delivery.rb
index 266ccd6..5f20b58 100644
--- a/proton-c/bindings/ruby/tests/test_delivery.rb
+++ b/proton-c/bindings/ruby/tests/test_delivery.rb
@@ -78,6 +78,8 @@ class TestDelivery < Minitest::Test
when "modify" then delivery.release({:undeliverable => true, :annotations => {:x => 42 }})
when "modify-empty" then delivery.release({:failed => false, :undeliverable => false, :annotations => {}})
when "modify-nil" then delivery.release({:failed => false, :undeliverable => false, :annotations => nil})
+ when "reject-raise" then raise Reject
+ when "release-raise" then raise Release
else raise inspect
end
end
@@ -85,7 +87,7 @@ class TestDelivery < Minitest::Test
def test_outcomes
rh = ReceiveHandler.new
- sh = SendHandler.new(["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"])
+ sh = SendHandler.new(["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil", "reject-raise", "release-raise"])
c = Container.new(nil, __method__)
l = c.listen_io(TCPServer.new(0), ListenOnceHandler.new({ :handler => rh }))
c.connect(l.url, {:handler => sh})
@@ -98,8 +100,10 @@ class TestDelivery < Minitest::Test
assert_equal ["modify", :on_tracker_modify, "5", Transfer::MODIFIED, {:failed=>true, :undeliverable=>true, :annotations=>{:x => 42}}], o.shift
assert_equal ["modify-empty", :on_tracker_release, "6", Transfer::RELEASED, nil], o.shift
assert_equal ["modify-nil", :on_tracker_release, "7", Transfer::RELEASED, nil], o.shift
+ assert_equal ["reject-raise", :on_tracker_reject, "8", Transfer::REJECTED, nil], o.shift
+ assert_equal ["release-raise", :on_tracker_modify, "9", Transfer::MODIFIED, {:failed=>true, :undeliverable=>false, :annotations=>nil}], o.shift
assert_empty o
- assert_equal ["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"], rh.received
+ assert_equal ["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil", "reject-raise", "release-raise"], rh.received
assert_empty sh.unsettled
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[14/50] [abbrv] qpid-proton git commit: PROTON-1522: Define Url repr
to exclude user and password; use repr in logging
Posted by ac...@apache.org.
PROTON-1522: Define Url repr to exclude user and password; use repr in logging
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5c746ceb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5c746ceb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5c746ceb
Branch: refs/heads/go1
Commit: 5c746ceb00b567c6345c3b4da26dc334480b3f6f
Parents: 85755ac
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 12:26:53 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 12:59:19 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/python/proton/__init__.py | 3 ++-
proton-c/bindings/python/proton/reactor.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c746ceb/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 21076ee..0dda550 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -4258,7 +4258,8 @@ class Url(object):
def __str__(self): return pn_url_str(self._url)
- def __repr__(self): return "Url(%r)" % str(self)
+ def __repr__(self):
+ return "Url(%s://%s/%s)" % (self.scheme, self.host, self.path)
def __eq__(self, x): return str(self) == str(x)
def __ne__(self, x): return not self == x
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c746ceb/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index e9ede47..b8bd96f 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -554,7 +554,7 @@ class Connector(Handler):
# if virtual-host not set, use host from address as default
if self.virtual_host is None:
connection.hostname = url.host
- log.debug("connecting to %s..." % url)
+ log.debug("connecting to %r..." % url)
transport = Transport()
if self.sasl_enabled:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[28/50] [abbrv] qpid-proton git commit: NO-JIRA: [go] add -prefetch
option to receive.go example
Posted by ac...@apache.org.
NO-JIRA: [go] add -prefetch option to receive.go 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/d6e5360d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d6e5360d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d6e5360d
Branch: refs/heads/go1
Commit: d6e5360dcf4ea60633a291dad54040e73174cf57
Parents: cd056f3
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Dec 13 17:13:19 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 17:13:19 2017 -0500
----------------------------------------------------------------------
examples/go/electron/receive.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d6e5360d/examples/go/electron/receive.go
----------------------------------------------------------------------
diff --git a/examples/go/electron/receive.go b/examples/go/electron/receive.go
index 568fcc9..9cab2eb 100644
--- a/examples/go/electron/receive.go
+++ b/examples/go/electron/receive.go
@@ -40,6 +40,7 @@ URLs are of the form "amqp://<host>:<port>/<amqp-address>"
}
var count = flag.Uint64("count", 1, "Stop after receiving this many messages in total")
+var prefetch = flag.Int("prefetch", 0, "enable a pre-fetch window to improve throughput")
var debug = flag.Bool("debug", false, "Print detailed debug output")
var debugf = func(format string, data ...interface{}) {} // Default no debugging output
@@ -78,7 +79,11 @@ func main() {
fatalIf(err)
connections <- c // Save connection so we can Close() when main() ends
addr := strings.TrimPrefix(url.Path, "/")
- r, err := c.Receiver(electron.Source(addr))
+ opts := []electron.LinkOption{electron.Source(addr)}
+ if *prefetch > 0 {
+ opts = append(opts, electron.Capacity(*prefetch), electron.Prefetch(true))
+ }
+ r, err := c.Receiver(opts...)
fatalIf(err)
// Loop receiving messages and sending them to the main() goroutine
for {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[24/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Update
tests to new API, many fixes
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_delivery.rb b/proton-c/bindings/ruby/tests/test_delivery.rb
index 334450a..db15321 100644
--- a/proton-c/bindings/ruby/tests/test_delivery.rb
+++ b/proton-c/bindings/ruby/tests/test_delivery.rb
@@ -24,8 +24,7 @@ include Qpid::Proton
# Test Delivery and Tracker
class TestDelivery < Minitest::Test
- # Duck-typed handler
- class NoAutoHandler
+ class NoAutoHandler < MessagingHandler
@@options = {:auto_settle=>false, :auto_accept=>false}
def options() @@options; end
end
@@ -35,32 +34,32 @@ class TestDelivery < Minitest::Test
@unsent = to_send
end
- def on_connection_opened(event)
+ def on_connection_open(connection)
@outcomes = []
- @sender = event.connection.open_sender("x")
+ @sender = connection.open_sender("x")
@unsettled = {} # Awaiting remote settlement
end
attr_reader :outcomes, :unsent, :unsettled
- def on_sendable(event)
+ def on_sendable(sender)
return if @unsent.empty?
m = Message.new(@unsent.shift)
- tracker = event.sender.send(m)
+ tracker = sender.send(m)
@unsettled[tracker] = m
end
- def outcome(event)
- t = event.tracker
+ def outcome(method, tracker)
+ t = tracker
m = @unsettled.delete(t)
- @outcomes << [m.body, event.method, t.id, t.state, t.modifications]
- event.connection.close if @unsettled.empty?
+ @outcomes << [m.body, method, t.id, t.state, t.modifications]
+ tracker.connection.close if @unsettled.empty?
end
- def on_accepted(event) outcome(event); end
- def on_rejected(event) outcome(event); end
- def on_released(event) outcome(event); end
- def on_modified(event) outcome(event); end
+ def on_tracker_accept(tracker) outcome(__method__, tracker); end
+ def on_tracker_reject(tracker) outcome(__method__, tracker); end
+ def on_tracker_release(tracker) outcome(__method__, tracker); end
+ def on_tracker_modify(tracker) outcome(__method__, tracker); end
end
class ReceiveHandler < NoAutoHandler
@@ -70,17 +69,17 @@ class TestDelivery < Minitest::Test
attr_reader :received
- def on_message(event)
- @received << event.message.body
- case event.message.body
- when "accept" then event.delivery.accept
- when "reject" then event.delivery.reject
- when "release-really" then event.delivery.release({:failed=>false}) # AMQP RELEASED
- when "release" then event.delivery.release # AMQP MODIFIED{ :failed => true }
- when "modify" then event.delivery.release({:undeliverable => true, :annotations => {:x => 42 }})
- when "modify-empty" then event.delivery.release({:failed => false, :undeliverable => false, :annotations => {}})
- when "modify-nil" then event.delivery.release({:failed => false, :undeliverable => false, :annotations => nil})
- else raise event.inspect
+ def on_message(delivery, message)
+ @received << message.body
+ case message.body
+ when "accept" then delivery.accept
+ when "reject" then delivery.reject
+ when "release-really" then delivery.release({:failed=>false}) # AMQP RELEASED
+ when "release" then delivery.release # AMQP MODIFIED{ :failed => true }
+ when "modify" then delivery.release({:undeliverable => true, :annotations => {:x => 42 }})
+ when "modify-empty" then delivery.release({:failed => false, :undeliverable => false, :annotations => {}})
+ when "modify-nil" then delivery.release({:failed => false, :undeliverable => false, :annotations => nil})
+ else raise inspect
end
end
end
@@ -88,17 +87,18 @@ class TestDelivery < Minitest::Test
def test_outcomes
rh = ReceiveHandler.new
sh = SendHandler.new(["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"])
- c = TestContainer.new(nil, { :handler => rh }, __method__)
- c.connect(c.url, {:handler => sh})
+ c = Container.new(nil, __method__)
+ l = c.listen_io(TCPServer.new(0), ListenOnceHandler.new({ :handler => rh }))
+ c.connect(l.url, {:handler => sh})
c.run
o = sh.outcomes
- assert_equal ["accept", :on_accepted, "1", Transfer::ACCEPTED, nil], o.shift
- assert_equal ["reject", :on_rejected, "2", Transfer::REJECTED, nil], o.shift
- assert_equal ["release-really", :on_released, "3", Transfer::RELEASED, nil], o.shift
- assert_equal ["release", :on_modified, "4", Transfer::MODIFIED, {:failed=>true, :undeliverable=>false, :annotations=>nil}], o.shift
- assert_equal ["modify", :on_modified, "5", Transfer::MODIFIED, {:failed=>true, :undeliverable=>true, :annotations=>{:x => 42}}], o.shift
- assert_equal ["modify-empty", :on_released, "6", Transfer::RELEASED, nil], o.shift
- assert_equal ["modify-nil", :on_released, "7", Transfer::RELEASED, nil], o.shift
+ assert_equal ["accept", :on_tracker_accept, "1", Transfer::ACCEPTED, nil], o.shift
+ assert_equal ["reject", :on_tracker_reject, "2", Transfer::REJECTED, nil], o.shift
+ assert_equal ["release-really", :on_tracker_release, "3", Transfer::RELEASED, nil], o.shift
+ assert_equal ["release", :on_tracker_modify, "4", Transfer::MODIFIED, {:failed=>true, :undeliverable=>false, :annotations=>nil}], o.shift
+ assert_equal ["modify", :on_tracker_modify, "5", Transfer::MODIFIED, {:failed=>true, :undeliverable=>true, :annotations=>{:x => 42}}], o.shift
+ assert_equal ["modify-empty", :on_tracker_release, "6", Transfer::RELEASED, nil], o.shift
+ assert_equal ["modify-nil", :on_tracker_release, "7", Transfer::RELEASED, nil], o.shift
assert_empty o
assert_equal ["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"], rh.received
assert_empty sh.unsettled
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_messaging_adapter.rb b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
new file mode 100644
index 0000000..200b68c
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_messaging_adapter.rb
@@ -0,0 +1,232 @@
+# 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 'minitest/autorun'
+require 'qpid_proton'
+require 'test_tools'
+include Qpid::Proton
+
+# Records every call, never provokes "on_unhandled"
+class RecordingHandler < Qpid::Proton::MessagingHandler
+
+ def initialize(*args) super(*args); @calls = []; end
+
+ attr_accessor :calls
+
+ def names() @calls.collect { |c| c[0] }; end
+
+ def clear() @calls.clear; end
+
+ def method_missing(name, *args)
+ respond_to_missing?(name) ? (@calls << [name, *args]) : super;
+ end
+ def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
+end
+
+# Extra methods for driver pairs of RecordingHandler
+class DriverPair
+ def names() collect { |x| x.handler.names }; end
+ def clear() each { |x| x.handler.clear; } end
+end
+
+class TestMessagingHandler < Minitest::Test
+
+ def test_handler_defaults
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
+ want = { :prefetch => 10, :auto_settle => true, :auto_accept => true, :auto_open => true, :auto_close => true }
+ assert_equal want, d.client.handler.options
+ assert_equal want, d.server.handler.options
+ end
+
+ def test_auto_open_close
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
+ d.client.connection.open; d.client.connection.open_sender; d.run
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open, :on_sendable], d.client.handler.names
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open], d.server.handler.names
+ d.clear
+ d.client.connection.close; d.run
+ assert_equal [:on_connection_close, :on_transport_close], d.server.handler.names
+ assert_equal [:on_connection_close, :on_transport_close], d.client.handler.names
+ end
+
+ def test_no_auto_open_close
+ opts = { :auto_close => false, :auto_open => false }
+ d = DriverPair.new(RecordingHandler.new(opts), RecordingHandler.new(opts))
+
+ d.client.connection.open; d.run
+ assert_equal [:on_connection_open], d.server.handler.names
+ assert_equal [], d.client.handler.names
+ d.server.connection.open; d.run
+ assert_equal [:on_connection_open], d.client.handler.names
+ assert_equal [:on_connection_open], d.server.handler.names
+ d.clear
+ d.client.connection.session.open; d.run
+ assert_equal [:on_session_open], d.server.handler.names
+ assert_equal [], d.client.handler.names
+ d.clear
+ d.client.connection.close;
+ 3.times { d.process }
+ assert_equal [:on_connection_close], d.server.handler.names
+ assert_equal [], d.client.handler.names
+ d.server.connection.close; d.run
+ assert_equal [:on_connection_close, :on_transport_close], d.client.handler.names
+ assert_equal [:on_connection_close, :on_transport_close], d.server.handler.names
+ end
+
+ def test_transport_error
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
+ d.client.connection.open; d.run
+ d.clear
+ d.client.close "stop that"; d.run
+ assert_equal [:on_transport_close], d.client.handler.names
+ assert_equal [:on_transport_error, :on_transport_close], d.server.handler.names
+ assert_equal Condition.new("proton:io", "stop that (connection aborted)"), d.client.transport.condition
+ assert_equal Condition.new("amqp:connection:framing-error", "connection aborted"), d.server.transport.condition
+ end
+
+ # Close on half-open
+ def test_connection_error
+ opts = { :auto_open => false }
+ d = DriverPair.new(RecordingHandler.new(opts), RecordingHandler.new(opts))
+ d.client.connection.open; d.run
+ d.server.connection.close "bad dog"; d.run
+ assert_equal [:on_connection_open, :on_connection_error, :on_connection_close, :on_transport_close], d.client.handler.names
+ assert_equal "bad dog", d.client.handler.calls[1][1].condition.description
+ assert_equal [:on_connection_open, :on_connection_error, :on_connection_close, :on_transport_close], d.server.handler.names
+ end
+
+ def test_session_error
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
+ d.client.connection.open
+ s = d.client.connection.session; s.open; d.run
+ assert_equal [:on_connection_open, :on_session_open], d.client.handler.names
+ assert_equal [:on_connection_open, :on_session_open], d.server.handler.names
+ d.clear
+ s.close "bad dog"; d.run
+ assert_equal [:on_session_error, :on_session_close], d.client.handler.names
+ assert_equal [:on_session_error, :on_session_close], d.server.handler.names
+ assert_equal "bad dog", d.server.handler.calls[0][1].condition.description
+ end
+
+ def test_link_error
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
+ d.client.connection.open
+ s = d.client.connection.open_sender; d.run
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open, :on_sendable], d.client.handler.names
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open], d.server.handler.names
+ d.clear
+ s.close "bad dog"; d.run
+ assert_equal [:on_link_error, :on_link_close], d.client.handler.names
+ assert_equal [:on_link_error, :on_link_close], d.server.handler.names
+ assert_equal "bad dog", d.server.handler.calls[0][1].condition.description
+ end
+
+ def test_options_off
+ handler_class = Class.new(RecordingHandler) do
+ def on_link_open(l) super; @link = l; end
+ def on_session_open(s) super; @session = s; end
+ attr_reader :link, :session
+ end
+
+ off = {:prefetch => nil, :auto_settle => false, :auto_accept => false, :auto_open => false, :auto_close => false}
+ d = DriverPair.new(handler_class.new(off), handler_class.new(off))
+ d.client.connection.open; d.run
+ assert_equal [[], [:on_connection_open]], d.names
+ d.server.connection.open; d.run
+ assert_equal [[:on_connection_open], [:on_connection_open]], d.names
+ d.clear
+ s = d.client.connection.open_sender; d.run
+ assert_equal [[], [:on_session_open, :on_link_open]], d.names
+ d.server.handler.session.open
+ d.server.handler.link.open # Return the opens
+ d.run
+ assert_equal [[:on_session_open, :on_link_open], [:on_session_open, :on_link_open]], d.names
+ d.clear
+ d.server.handler.link.flow(1); d.run
+ assert_equal [[:on_sendable], []], d.names
+ assert_equal 1, s.credit
+ d.clear
+ s.send Message.new("foo"); d.run
+ assert_equal [[], [:on_message]], d.names
+ end
+
+
+ def test_message
+ handler_class = Class.new(MessagingHandler) do
+ def on_message(delivery, message) @message = message; end
+ def on_tracker_accept(event) @accepted = true; end
+ attr_accessor :message, :accepted
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open;
+ s = d.client.connection.open_sender; d.run
+ assert_equal 10, s.credit # Default prefetch
+ s.send(Message.new("foo")); d.run
+ assert_equal "foo", d.server.handler.message.body
+ assert d.client.handler.accepted
+ end
+
+ # Verify on_unhandled is called
+ def test_unhandled
+ handler_class = Class.new(MessagingHandler) do
+ def initialize() super; @unhandled = []; end
+ def on_unhandled(method, *args) @unhandled << method; end
+ attr_accessor :unhandled
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open; d.run
+ assert_equal [:on_connection_open], d.client.handler.unhandled
+ assert_equal [:on_connection_open], d.server.handler.unhandled
+ end
+
+ # Verify on_error is called
+ def test_on_error
+ handler_class = Class.new(MessagingHandler) do
+ def initialize() super; @error = []; @unhandled = []; end
+ def on_error(condition) @error << condition; end
+ def on_unhandled(method, *args) @unhandled << method; end
+ attr_accessor :error, :unhandled
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open
+ r = d.client.connection.open_receiver; d.run
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open], d.client.handler.unhandled
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open, :on_sendable], d.server.handler.unhandled
+ r.close Condition.new("goof", "oops"); d.run
+
+ assert_equal [Condition.new("goof", "oops")], d.client.handler.error
+ assert_equal [:on_connection_open, :on_session_open, :on_link_open, :on_sendable, :on_link_close], d.server.handler.unhandled
+ assert_equal [Condition.new("goof", "oops")], d.server.handler.error
+
+ end
+
+ # Verify on_unhandled is called for errors if there is no on_error
+ def test_unhandled_error
+ handler_class = Class.new(MessagingHandler) do
+ def on_unhandled(method, *args)
+ @error = args[0].condition if method == :on_connection_error;
+ end
+ attr_accessor :error
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open; d.run
+ d.client.connection.close "oops"; d.run
+ assert_equal [Condition.new("error", "oops")]*2, d.collect { |x| x.handler.error }
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_old_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_old_adapter.rb b/proton-c/bindings/ruby/tests/test_old_adapter.rb
new file mode 100644
index 0000000..103efc1
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_old_adapter.rb
@@ -0,0 +1,228 @@
+# 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 'minitest/autorun'
+require 'qpid_proton'
+require 'test_tools'
+include Qpid::Proton
+
+OldMessagingHandler = Qpid::Proton::Handler::MessagingHandler #Use the old handler.
+
+# Records every call
+class AllHandler < OldMessagingHandler
+ def initialize(*args)
+ super(*args)
+ @calls = []
+ end
+
+ attr_accessor :calls
+
+ def names; @calls.map { |c| c[0] }; end
+ def events; @calls.map { |c| c[1] }; end
+
+ def method_missing(name, *args) (/^on_/ =~ name) ? (@calls << [name] + args) : super; end
+ def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
+end
+
+# Tests with Mock handler that handles all methods, expect both old and new calls
+class TestOldHandler < Minitest::Test
+ def setup
+ @h = [AllHandler.new, AllHandler.new]
+ @ch, @sh = *@h
+ @d = DriverPair.new(*@h)
+ end
+
+ def clear; @d.each { |d| h = d.handler; h.calls.clear }; end
+
+ def test_handler_defaults
+ want = { :prefetch => 10, :auto_settle => true, :auto_accept => true, :auto_open => true, :auto_close => true, :peer_close_is_error => false }
+ assert_equal want, @ch.options
+ assert_equal want, @sh.options
+ end
+
+ def test_auto_open_close
+ @d.client.connection.open; @d.client.connection.open_sender; @d.run
+ assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable], @ch.names
+ assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening, :on_connection_opened, :on_session_opened, :on_link_opened], @sh.names
+ clear
+ @d.client.connection.close; @d.run
+ assert_equal [:on_connection_closed, :on_transport_closed], @ch.names
+ assert_equal [:on_connection_closing, :on_connection_closed, :on_transport_closed], @sh.names
+ end
+
+ def test_no_auto_open_close
+ [:auto_close, :auto_open].each { |k| @ch.options[k] = @sh.options[k] = false }
+ @d.client.connection.open; @d.run
+ assert_equal [:on_connection_opening], @sh.names
+ assert_equal [], @ch.names
+ @d.server.connection.open; @d.run
+ assert_equal [:on_connection_opened], @ch.names
+ assert_equal [:on_connection_opening, :on_connection_opened], @sh.names
+ clear
+ @d.client.connection.session.open; @d.run
+ assert_equal [:on_session_opening], @sh.names
+ assert_equal [], @ch.names
+ clear
+ @d.client.connection.close;
+ 3.times { @d.process }
+ assert_equal [:on_connection_closing], @sh.names
+ assert_equal [], @ch.names
+ @d.server.connection.close; @d.run
+ assert_equal [:on_connection_closed, :on_transport_closed], @ch.names
+ assert_equal [:on_connection_closing, :on_connection_closed, :on_transport_closed], @sh.names
+ end
+
+ def test_transport_error
+ @d.client.connection.open; @d.run
+ clear
+ @d.client.close "stop that"; @d.run
+ assert_equal [:on_transport_closed], @ch.names
+ assert_equal [:on_transport_error, :on_transport_closed], @sh.names
+ assert_equal Condition.new("proton:io", "stop that (connection aborted)"), @d.client.transport.condition
+ assert_equal Condition.new("amqp:connection:framing-error", "connection aborted"), @d.server.transport.condition
+ end
+
+ def test_connection_error
+ @ch.options[:auto_open] = @sh.options[:auto_open] = false
+ @d.client.connection.open; @d.run
+ @d.server.connection.close "bad dog"; @d.run
+ assert_equal [:on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], @ch.names
+ assert_equal "bad dog", @ch.calls[2][1].condition.description
+ assert_equal [:on_connection_opening, :on_connection_closed, :on_transport_closed], @sh.names
+ end
+
+ def test_session_error
+ @d.client.connection.open
+ s = @d.client.connection.session; s.open; @d.run
+ s.close "bad dog"; @d.run
+ assert_equal [:on_connection_opened, :on_session_opened, :on_session_closed], @ch.names
+ assert_equal [:on_connection_opening, :on_session_opening, :on_connection_opened, :on_session_opened, :on_session_error, :on_session_closed], @sh.names
+ assert_equal "bad dog", @sh.calls[-3][1].condition.description
+ end
+
+ def test_link_error
+ @d.client.connection.open
+ s = @d.client.connection.open_sender; @d.run
+ s.close "bad dog"; @d.run
+ assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable, :on_link_closed], @ch.names
+ assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening,
+ :on_connection_opened, :on_session_opened, :on_link_opened,
+ :on_link_error, :on_link_closed], @sh.names
+ assert_equal "bad dog", @sh.calls[-3][1].condition.description
+ end
+
+ def test_options_off
+ off = {:prefetch => 0, :auto_settle => false, :auto_accept => false, :auto_open => false, :auto_close => false}
+ @ch.options.replace(off)
+ @sh.options.replace(off)
+ @d.client.connection.open; @d.run
+ assert_equal [[], [:on_connection_opening]], [@ch.names, @sh.names]
+ @d.server.connection.open; @d.run
+ assert_equal [[:on_connection_opened], [:on_connection_opening, :on_connection_opened]], [@ch.names, @sh.names]
+ clear
+ s = @d.client.connection.open_sender; @d.run
+ assert_equal [[], [:on_session_opening, :on_link_opening]], [@ch.names, @sh.names]
+ @sh.events[1].session.open
+ r = @sh.events[1].link
+ r.open; @d.run
+ assert_equal [[:on_session_opened, :on_link_opened], [:on_session_opening, :on_link_opening, :on_session_opened, :on_link_opened]], [@ch.names, @sh.names]
+ clear
+ r.flow(1); @d.run
+ assert_equal [[:on_sendable], []], [@ch.names, @sh.names]
+ assert_equal 1, s.credit
+ clear
+ s.send Message.new("foo"); @d.run
+ assert_equal [[], [:on_message]], [@ch.names, @sh.names]
+ end
+
+ def test_peer_close_is_error
+ @ch.options[:peer_close_is_error] = true
+ @d.client.connection.open; @d.run
+ @d.server.connection.close; @d.run
+ assert_equal [:on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], @ch.names
+ assert_equal [:on_connection_opening, :on_connection_opened, :on_connection_closed, :on_transport_closed], @sh.names
+ end
+end
+
+# Test with real handlers that implement a few methods
+class TestOldUnhandled < Minitest::Test
+
+ def test_message
+ handler_class = Class.new(OldMessagingHandler) do
+ def on_message(event) @message = event.message; end
+ def on_accepted(event) @accepted = true; end
+ attr_accessor :message, :accepted, :sender
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open;
+ s = d.client.connection.open_sender; d.run
+ assert_equal 10, s.credit # Default prefetch
+ s.send(Message.new("foo")); d.run
+ assert_equal "foo", d.server.handler.message.body
+ assert d.client.handler.accepted
+ end
+
+ # Verify on_unhandled is called
+ def test_unhandled
+ handler_class = Class.new(OldMessagingHandler) do
+ def initialize() super; @unhandled = []; end
+ def on_unhandled(event) @unhandled << event.method; end
+ attr_accessor :unhandled
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open; d.run
+ assert_equal [:on_connection_opened], d.client.handler.unhandled
+ assert_equal [:on_connection_opening, :on_connection_opened], d.server.handler.unhandled
+ end
+
+ # Verify on_error is called
+ def test_on_error
+ handler_class = Class.new(OldMessagingHandler) do
+ def initialize() super; @error = []; @unhandled = []; end
+ def on_error(event) @error << event.method; end
+ def on_unhandled(event) @unhandled << event.method; end
+ attr_accessor :error, :unhandled
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open
+ r = d.client.connection.open_receiver; d.run
+ r.close "oops"; d.run
+ assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened,
+ :on_link_closed], d.client.handler.unhandled
+ assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening,
+ :on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable,
+ :on_link_closed], d.server.handler.unhandled
+ assert_equal [:on_link_error], d.server.handler.error
+
+ end
+
+ # Verify on_unhandled is called even for errors if there is no on_error
+ def test_unhandled_error
+ handler_class = Class.new(OldMessagingHandler) do
+ def initialize() super; @unhandled = []; end
+ def on_unhandled(event) @unhandled << event.method; end
+ attr_accessor :unhandled
+ end
+ d = DriverPair.new(handler_class.new, handler_class.new)
+ d.client.connection.open; d.run
+ d.client.connection.close "oops"; d.run
+ assert_equal [:on_connection_opened, :on_connection_closed, :on_transport_closed], d.client.handler.unhandled
+ assert_equal [:on_connection_opening, :on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], d.server.handler.unhandled
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_tools.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_tools.rb b/proton-c/bindings/ruby/tests/test_tools.rb
index ad4a7cb..a5b3b75 100644
--- a/proton-c/bindings/ruby/tests/test_tools.rb
+++ b/proton-c/bindings/ruby/tests/test_tools.rb
@@ -23,10 +23,6 @@ require 'qpid_proton'
require 'thread'
require 'socket'
-Container = Qpid::Proton::Container
-ListenHandler = Qpid::Proton::Listener::Handler
-MessagingHandler = Qpid::Proton::Handler::MessagingHandler
-
class TestError < Exception; end
def wait_port(port, timeout=5)
@@ -43,7 +39,7 @@ def wait_port(port, timeout=5)
end
# Handler that records some common events that are checked by tests
-class TestHandler < MessagingHandler
+class TestHandler < Qpid::Proton::MessagingHandler
attr_reader :errors, :connections, :sessions, :links, :messages
# Pass optional extra handlers and options to the Container
@@ -64,50 +60,54 @@ class TestHandler < MessagingHandler
raise TestError.new("TestHandler has errors:\n #{text}")
end
- def on_error(event)
- @errors.push "#{event.type}: #{event.condition.inspect}"
+ def on_error(condition)
+ @errors.push "#{condition}"
raise_errors if @raise_errors
end
- def endpoint_opened(queue, endpoint)
+ def endpoint_open(queue, endpoint)
queue.push(endpoint)
end
- def on_connection_opened(event)
- endpoint_opened(@connections, event.connection)
+ def on_connection_open(c)
+ endpoint_open(@connections, c)
end
- def on_session_opened(event)
- endpoint_opened(@sessions, event.session)
+ def on_session_open(s)
+ endpoint_open(@sessions, s)
end
- def on_link_opened(event)
- endpoint_opened(@links, event.link)
+ def on_link_open(l)
+ endpoint_open(@links, l)
end
- def on_message(event)
- @messages.push(event.message)
+ def on_message(d, m)
+ @messages.push(m)
end
end
# ListenHandler that closes the Listener after first accept
-class ListenOnceHandler < ListenHandler
+class ListenOnceHandler < Qpid::Proton::Listener::Handler
def on_error(l, e) raise TestError, e.inspect; end
def on_accept(l) l.close; super; end
end
+# Add port/url to Listener, assuming a TCP socket
+class Qpid::Proton::Listener
+ def port() to_io.addr[1]; end
+ def url() "amqp://:#{port}"; end
+end
+
# A client/server pair of ConnectionDrivers linked by a socket pair
-class DriverPair < Array
+DriverPair = Struct.new(:client, :server) do
def initialize(client_handler, server_handler)
- handlers = [client_handler, server_handler]
- self[0..-1] = Socket.pair(:LOCAL, :STREAM, 0).map { |s| HandlerDriver.new(s, handlers.shift) }
+ s = Socket.pair(:LOCAL, :STREAM, 0)
+ self.client = HandlerDriver.new(s[0], client_handler)
+ self.server = HandlerDriver.new(s[1], server_handler)
server.transport.set_server
end
- alias client first
- alias server last
-
# Process each driver once, return time of next timed event
def process(now = Time.now, max_time=nil)
t = collect { |d| d.process(now) }.compact.min
@@ -115,40 +115,20 @@ class DriverPair < Array
t
end
- # Run till there is no IO activity - does not handle waiting for timed events
- # but does pass +now+ to process and returns the min returned timed event time
- def run(now=Time.now)
- t = process(now) # Generate initial IO activity and get initial next-time
- t = process(now, t) while (IO.select(self, [], [], 0) rescue nil)
- t = process(now, t) # Final gulp to finish off events
+ def active()
+ can_read = self.select { |d| d.can_read? }
+ can_write = self.select {|d| d.can_write? }
+ IO.select(can_read, can_write, [], 0)
end
-end
-
-# Container that listens on a random port for a single connection
-class TestContainer < Container
- def initialize(handler, lopts=nil, id=nil)
- super handler, id
- @server = TCPServer.open(0)
- @listener = listen_io(@server, ListenOnceHandler.new(lopts))
+ # Run till there is nothing else to do - not handle waiting for timed events
+ # but does pass +now+ to process and returns the min returned timed event time
+ def run(now=Time.now)
+ t = nil
+ begin
+ t = process(now, t)
+ end while active
+ t
end
-
- def port() @server.addr[1]; end
- def url() "amqp://:#{port}"; end
end
-# Raw handler to record on_xxx calls via on_unhandled.
-# Handy as a base for raw test handlers
-class UnhandledHandler
- def initialize() @calls =[]; end
- def on_unhandled(name, args) @calls << name; end
- attr_reader :calls
-
- # Ruby mechanics to capture on_xxx calls
-
- def method_missing(name, *args)
- if respond_to_missing?(name) then on_unhandled(name, *args) else super end;
- end
- def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
- def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
-end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[25/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Update
tests to new API, many fixes
Posted by ac...@apache.org.
PROTON-1537: [ruby] Update tests to new API, many fixes
Both the old and new APIs are supported fornow, old APIs causes [DEPRECATION]
warnings (disable with `ruby -W0`)
Old: Qpid::Proton::Reactor::Container, Qpid::Proton::Handler::MessagingHandler
New: Qpid::Proton::Container, Qpid::Proton::MessagingHandler
Both are implemented in terms of the new Container and ConnectionDriver.
Both styles of handler are implemented by Adapter classes that translate raw
proton events to API handler calls.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a13bc2b9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a13bc2b9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a13bc2b9
Branch: refs/heads/go1
Commit: a13bc2b9fa08fd8ab068abdf8645d334cde1161c
Parents: 4678e74
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Dec 11 15:36:07 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 14:09:26 2017 -0500
----------------------------------------------------------------------
examples/ruby/README.md | 10 +-
examples/ruby/broker.rb | 50 ++--
examples/ruby/client.rb | 22 +-
examples/ruby/direct_recv.rb | 12 +-
examples/ruby/direct_send.rb | 16 +-
examples/ruby/helloworld.rb | 24 +-
examples/ruby/server.rb | 35 +--
examples/ruby/simple_recv.rb | 12 +-
examples/ruby/simple_send.rb | 16 +-
proton-c/bindings/ruby/CMakeLists.txt | 13 +-
proton-c/bindings/ruby/lib/core/connection.rb | 1 +
.../bindings/ruby/lib/core/connection_driver.rb | 9 +-
proton-c/bindings/ruby/lib/core/container.rb | 38 +--
proton-c/bindings/ruby/lib/core/delivery.rb | 12 +-
proton-c/bindings/ruby/lib/core/event.rb | 2 +-
proton-c/bindings/ruby/lib/core/exceptions.rb | 4 +-
.../bindings/ruby/lib/core/messaging_handler.rb | 14 +-
proton-c/bindings/ruby/lib/core/transfer.rb | 6 +-
proton-c/bindings/ruby/lib/handler/adapter.rb | 61 ++---
.../ruby/lib/handler/messaging_adapter.rb | 125 ++++++++++
.../ruby/lib/handler/messaging_handler.rb | 5 +
.../ruby/lib/handler/old_messaging_adapter.rb | 151 ------------
.../lib/handler/reactor_messaging_adapter.rb | 158 +++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 25 +-
proton-c/bindings/ruby/lib/reactor/container.rb | 86 +++----
proton-c/bindings/ruby/lib/types/array.rb | 7 +-
proton-c/bindings/ruby/spec/array_spec.rb | 42 +---
proton-c/bindings/ruby/spec/spec_helper.rb | 28 +--
.../ruby/tests/old_examples/old_example_test.rb | 4 +-
proton-c/bindings/ruby/tests/test_adapter.rb | 227 ------------------
.../ruby/tests/test_connection_driver.rb | 45 ++--
proton-c/bindings/ruby/tests/test_container.rb | 100 ++++----
proton-c/bindings/ruby/tests/test_delivery.rb | 68 +++---
.../ruby/tests/test_messaging_adapter.rb | 232 +++++++++++++++++++
.../bindings/ruby/tests/test_old_adapter.rb | 228 ++++++++++++++++++
proton-c/bindings/ruby/tests/test_tools.rb | 90 +++----
36 files changed, 1163 insertions(+), 815 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/README.md
----------------------------------------------------------------------
diff --git a/examples/ruby/README.md b/examples/ruby/README.md
index 938ef17..66f6b31 100644
--- a/examples/ruby/README.md
+++ b/examples/ruby/README.md
@@ -54,7 +54,7 @@ For example if you start `direct_recv.rb`, you can connect to it directly with
In this set of examples we see the following event occurring, in addition to what we've seen before:
- * **on_disconnected** - Fired when the transport is closed.
+ * **on_transport_close** - Fired when the network transport is closed.
## Now About That Broker example
@@ -70,7 +70,7 @@ The Broker manages a map connecting a queue address to the instance of Exchange
The broker application demonstrates a new set of events:
- * **on_link_opening** - Fired when a remote link is opened but the local end is not yet open. From this event the broker grabs the address and subscribes the link to an exchange for that address.
- * **on_link_closing** - Fired when a remote link is closed but the local end is still open. From this event the broker grabs the address and unsubscribes the link from that exchange.
- * **on_connection_closing** - Fired when a remote connection is closed but the local end is still open.
- * **on_disconnected** - Fired when the protocol transport has closed. The broker removes all links for the disconnected connection, avoiding workign with endpoints that are now gone.
+ * **on_link_open** - Fired when a remote link is opened. From this event the broker grabs the address and subscribes the link to an exchange for that address.
+ * **on_link_close** - Fired when a remote link is closed. From this event the broker grabs the address and unsubscribes the link from that exchange.
+ * **on_connection_close** - Fired when a remote connection is closed but the local end is still open.
+ * **on_transport_close** - Fired when the protocol transport has closed. The broker removes all links for the disconnected connection, avoiding workign with endpoints that are now gone.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/broker.rb b/examples/ruby/broker.rb
index 111d41b..aad32a9 100644
--- a/examples/ruby/broker.rb
+++ b/examples/ruby/broker.rb
@@ -69,7 +69,7 @@ class MessageQueue
end
-class Broker < Qpid::Proton::Handler::MessagingHandler
+class Broker < Qpid::Proton::MessagingHandler
def initialize(url)
super()
@@ -77,8 +77,8 @@ class Broker < Qpid::Proton::Handler::MessagingHandler
@queues = {}
end
- def on_start(event)
- @listener = event.container.listen(@url)
+ def on_container_start(container)
+ @listener = container.listen(@url)
STDOUT.puts "Listening on #{@url}"; STDOUT.flush
end
@@ -89,20 +89,20 @@ class Broker < Qpid::Proton::Handler::MessagingHandler
@queues[address]
end
- def on_link_opening(event)
- if event.link.sender?
- if event.link.remote_source.dynamic?
+ def on_link_open(link)
+ if link.sender?
+ if link.remote_source.dynamic?
address = SecureRandom.uuid
- event.link.source.address = address
+ link.source.address = address
q = MessageQueue.new(true)
@queues[address] = q
- q.subscribe(event.link)
- elsif event.link.remote_source.address
- event.link.source.address = event.link.remote_source.address
- self.queue(event.link.source.address).subscribe(event.link)
+ q.subscribe(link)
+ elsif link.remote_source.address
+ link.source.address = link.remote_source.address
+ self.queue(link.source.address).subscribe(link)
end
- elsif event.link.remote_target.address
- event.link.target.address = event.link.remote_target.address
+ elsif link.remote_target.address
+ link.target.address = link.remote_target.address
end
end
@@ -114,16 +114,16 @@ class Broker < Qpid::Proton::Handler::MessagingHandler
end
end
- def on_link_closing(event)
- self.unsubscribe(event.link) if event.link.sender?
+ def on_link_close(link)
+ self.unsubscribe(link) if link.sender?
end
- def on_connection_closing(event)
- self.remove_stale_consumers(event.connection)
+ def on_connection_close(connection)
+ self.remove_stale_consumers(connection)
end
- def on_disconnected(event)
- self.remove_stale_consumers(event.connection)
+ def on_transport_close(transport)
+ self.remove_stale_consumers(transport.connection)
end
def remove_stale_consumers(connection)
@@ -134,14 +134,14 @@ class Broker < Qpid::Proton::Handler::MessagingHandler
end
end
- def on_sendable(event)
- q = self.queue(event.link.source.address)
- q.dispatch(event.link)
+ def on_sendable(sender)
+ q = self.queue(sender.source.address)
+ q.dispatch(sender)
end
- def on_message(event)
- q = self.queue(event.link.target.address)
- q.publish(event.message)
+ def on_message(delivery, message)
+ q = self.queue(delivery.link.target.address)
+ q.publish(message)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/client.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/client.rb b/examples/ruby/client.rb
index 46c1251..1439169 100644
--- a/examples/ruby/client.rb
+++ b/examples/ruby/client.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class Client < Qpid::Proton::Handler::MessagingHandler
+class Client < Qpid::Proton::MessagingHandler
def initialize(url, address, requests)
super()
@@ -29,8 +29,8 @@ class Client < Qpid::Proton::Handler::MessagingHandler
@requests = requests
end
- def on_start(event)
- c = event.container.connect(@url)
+ def on_container_start(container)
+ c = container.connect(@url)
@sender = c.open_sender(@address)
@receiver = c.open_receiver({:dynamic => true})
end
@@ -45,24 +45,22 @@ class Client < Qpid::Proton::Handler::MessagingHandler
end
end
- def on_link_opened(event)
- if event.receiver == @receiver
- next_request
- end
+ def on_link_open(link)
+ next_request if link.receiver?
end
- def on_message(event)
- puts "<- #{event.message.body}"
+ def on_message(delivery, message)
+ puts "<- #{message.body}"
@requests.delete_at(0)
if !@requests.empty?
next_request
else
- event.connection.close
+ delivery.connection.close
end
end
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
+ def on_transport_error(transport)
+ raise "Connection error: #{transport.condition}"
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/direct_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/direct_recv.rb b/examples/ruby/direct_recv.rb
index 2e3295f..327d8d0 100644
--- a/examples/ruby/direct_recv.rb
+++ b/examples/ruby/direct_recv.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class DirectReceive < Qpid::Proton::Handler::MessagingHandler
+class DirectReceive < Qpid::Proton::MessagingHandler
def initialize(url, address, count)
super()
@@ -35,16 +35,16 @@ class DirectReceive < Qpid::Proton::Handler::MessagingHandler
def on_accept(l) l.close; end
end
- def on_start(event)
- event.container.listen(@url, ListenOnce.new)
+ def on_container_start(container)
+ container.listen(@url, ListenOnce.new)
end
- def on_message(event)
+ def on_message(delivery, message)
if @expected.zero? || (@received < @expected)
- puts "Received: #{event.message.body}"
+ puts "Received: #{message.body}"
@received = @received + 1
if @received == @expected
- event.connection.close
+ delivery.connection.close
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/direct_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/direct_send.rb b/examples/ruby/direct_send.rb
index 0ccfe38..6ea5fd3 100644
--- a/examples/ruby/direct_send.rb
+++ b/examples/ruby/direct_send.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class DirectSend < Qpid::Proton::Handler::MessagingHandler
+class DirectSend < Qpid::Proton::MessagingHandler
def initialize(url, address, expected)
super()
@@ -36,23 +36,23 @@ class DirectSend < Qpid::Proton::Handler::MessagingHandler
def on_accept(l) l.close; end
end
- def on_start(event)
- event.container.listen(@url, ListenOnce.new)
+ def on_container_start(container)
+ container.listen(@url, ListenOnce.new)
end
- def on_sendable(event)
- while event.sender.credit > 0 && @sent < @expected
+ def on_sendable(sender)
+ while sender.credit > 0 && @sent < @expected
msg = Qpid::Proton::Message.new("sequence #{@sent}", { :id => @sent } )
- event.sender.send(msg)
+ sender.send(msg)
@sent = @sent + 1
end
end
- def on_accepted(event)
+ def on_tracker_accept(tracker)
@confirmed = @confirmed + 1
if @confirmed == @expected
puts "All #{@expected} messages confirmed!"
- event.connection.close
+ tracker.connection.close
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/helloworld.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/helloworld.rb b/examples/ruby/helloworld.rb
index 2b2d4f5..a03060c 100644
--- a/examples/ruby/helloworld.rb
+++ b/examples/ruby/helloworld.rb
@@ -20,33 +20,31 @@
require 'qpid_proton'
require 'optparse'
-class HelloWorld < Qpid::Proton::Handler::MessagingHandler
+class HelloWorld < Qpid::Proton::MessagingHandler
def initialize(url, address)
super()
@url, @address = url, address
end
- def on_start(event)
- conn = event.container.connect(@url)
+ def on_container_start(container)
+ conn = container.connect(@url)
conn.open_sender(@address)
conn.open_receiver(@address)
end
- def on_sendable(event)
- msg = Qpid::Proton::Message.new
- msg.body = "Hello world!"
- event.sender.send(msg)
- event.sender.close
+ def on_sendable(sender)
+ sender.send(Qpid::Proton::Message.new("Hello world!"))
+ sender.close
end
- def on_message(event)
- puts event.message.body
- event.connection.close
+ def on_message(delivery, message)
+ puts message.body
+ delivery.connection.close
end
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
+ def on_transport_error(transport)
+ raise "Connection error: #{transport.condition}"
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/server.rb b/examples/ruby/server.rb
index 87eba99..7a4832b 100644
--- a/examples/ruby/server.rb
+++ b/examples/ruby/server.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class Server < Qpid::Proton::Handler::MessagingHandler
+class Server < Qpid::Proton::MessagingHandler
def initialize(url, address)
super()
@@ -29,34 +29,35 @@ class Server < Qpid::Proton::Handler::MessagingHandler
@senders = {}
end
- def on_start(event)
- c = event.container.connect(@url)
+ def on_container_start(container)
+ c = container.connect(@url)
c.open_receiver(@address)
@relay = nil
end
- def on_connection_opened(event)
- if event.connection.remote_offered_capabilities &&
- event.connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
- @relay = event.connection.open_sender({:target => nil})
+ def on_connection_open(connection)
+ if connection.remote_offered_capabilities &&
+ connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
+ @relay = connection.open_sender({:target => nil})
end
end
- def on_message(event)
- msg = event.message
- return unless msg.reply_to # Not a request message
- puts "<- #{msg.body}"
- sender = @relay || (@senders[msg.reply_to] ||= event.connection.open_sender(msg.reply_to))
+ def on_message(delivery, message)
+ return unless message.reply_to # Not a request message
+ puts "<- #{message.body}"
+ unless (sender = @relay)
+ sender = (@senders[message.reply_to] ||= delivery.connection.open_sender(message.reply_to))
+ end
reply = Qpid::Proton::Message.new
- reply.address = msg.reply_to
- reply.body = msg.body.upcase
+ reply.address = message.reply_to
+ reply.body = message.body.upcase
puts "-> #{reply.body}"
- reply.correlation_id = msg.correlation_id
+ reply.correlation_id = message.correlation_id
sender.send(reply)
end
- def on_transport_error(event)
- raise "Connection error: #{event.transport.condition}"
+ def on_transport_error(transport)
+ raise "Connection error: #{transport.condition}"
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/simple_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/simple_recv.rb b/examples/ruby/simple_recv.rb
index 446d7da..8c8bf50 100644
--- a/examples/ruby/simple_recv.rb
+++ b/examples/ruby/simple_recv.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class SimpleReceive < Qpid::Proton::Handler::MessagingHandler
+class SimpleReceive < Qpid::Proton::MessagingHandler
def initialize(url, address, count)
super()
@@ -30,17 +30,17 @@ class SimpleReceive < Qpid::Proton::Handler::MessagingHandler
@received = 0
end
- def on_start(event)
- c = event.container.connect(@url)
+ def on_container_start(container)
+ c = container.connect(@url)
c.open_receiver(@address)
end
- def on_message(event)
+ def on_message(delivery, message)
if @expected.zero? || (@received < @expected)
- puts "Received: #{event.message.body}"
+ puts "Received: #{message.body}"
@received = @received + 1
if @received == @expected
- event.connection.close
+ delivery.connection.close
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/examples/ruby/simple_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/simple_send.rb b/examples/ruby/simple_send.rb
index be919d5..1a65cd5 100644
--- a/examples/ruby/simple_send.rb
+++ b/examples/ruby/simple_send.rb
@@ -20,7 +20,7 @@
require 'qpid_proton'
require 'optparse'
-class SimpleSend < Qpid::Proton::Handler::MessagingHandler
+class SimpleSend < Qpid::Proton::MessagingHandler
def initialize(url, address, expected)
super()
@@ -31,24 +31,24 @@ class SimpleSend < Qpid::Proton::Handler::MessagingHandler
@expected = expected
end
- def on_start(event)
- c = event.container.connect(@url)
+ def on_container_start(container)
+ c = container.connect(@url)
c.open_sender(@address)
end
- def on_sendable(event)
- while event.sender.credit > 0 && @sent < @expected
+ def on_sendable(sender)
+ while sender.credit > 0 && @sent < @expected
msg = Qpid::Proton::Message.new("sequence #{@sent}", { :id => @sent } )
- event.sender.send(msg)
+ sender.send(msg)
@sent = @sent + 1
end
end
- def on_accepted(event)
+ def on_tracker_accept(tracker)
@confirmed = @confirmed + 1
if @confirmed == @expected
puts "All #{@expected} messages confirmed!"
- event.connection.close
+ tracker.connection.close
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
index 8ff1323..e41b49f 100644
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ b/proton-c/bindings/ruby/CMakeLists.txt
@@ -103,18 +103,21 @@ execute_process(COMMAND ${RUBY_EXECUTABLE} -r minitest -e ""
RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET)
if (result EQUAL 0) # Have minitest
set(test_env ${env_py} -- "PATH=${PATH}" "RUBYLIB=${RUBYLIB}" "SASLPASSWD=${SASLPASSWD_EXE}")
- macro(add_ruby_test file)
- get_filename_component(name ${file} NAME_WE)
+
+ macro(add_ruby_test script)
+ if(${script} MATCHES "old")
+ set(opt "RUBYOPT=-W0") # Suppress deprecation warnings
+ endif()
+ get_filename_component(name ${script} NAME_WE)
string(REPLACE "_" "-" name "ruby-${name}")
add_test(
NAME ${name}
- COMMAND ${test_env} ${RUBY_EXECUTABLE} ${file} -v
+ COMMAND ${test_env} ${opt} ${RUBY_EXECUTABLE} ${script} -v
${ARGN})
+
endmacro()
add_ruby_test(example_test.rb WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/examples/ruby)
- # Old examples for backwards compatibility testing.
add_ruby_test(old_example_test.rb WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/old_examples)
-
file(GLOB TESTS tests/test_*.rb)
file(GLOB SPECS spec/*_spec.rb)
foreach(t ${TESTS} ${SPECS})
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 55873dd..dcbae1f 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -124,6 +124,7 @@ module Qpid::Proton
# on_connection_bound if not using a connection_driver)
@container = opts[:container]
cid = opts[:container_id] || (@container && @container.id) || SecureRandom.uuid
+ cid = cid.to_s if cid.is_a? Symbol # Allow symbols as container name
Cproton.pn_connection_set_container(@impl, cid)
Cproton.pn_connection_set_user(@impl, opts[:user]) if opts[:user]
Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password]
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index b796d4d..2ce132e 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -159,14 +159,13 @@ module Qpid::Proton
end
end
- # A {ConnectionDriver} that feeds events to a {Handler::MessagingHandler}
+ # A {ConnectionDriver} that feeds raw proton events to a handler.
class HandlerDriver < ConnectionDriver
- # Combine an {IO} with a {Handler::MessagingHandler} and provide
+ # Combine an {IO} with a handler and provide
# a simplified way to run the driver via {#process}
#
# @param io [IO]
- # @param handler [Handler::MessagingHandler] to receive events in
- # {#dispatch} and {#process}
+ # @param handler [Handler::MessagingHandler] to receive raw events in {#dispatch} and {#process}
def initialize(io, handler)
super(io)
@handler = handler
@@ -176,7 +175,7 @@ module Qpid::Proton
# @return [MessagingHandler] The handler dispatched to by {#process}
attr_reader :handler
- # Dispatch all events available from {#event} to {#handler}
+ # Dispatch all available raw proton events from {#event} to {#handler}
def dispatch()
each_event do |e|
case e.method # Events that affect the driver
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 fff32e6..f8c8c16 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -91,10 +91,10 @@ module Qpid::Proton
# Create a new Container
# @overload initialize(id=nil)
- # @param id [String] A unique ID for this container, use random UUID if nil.
+ # @param id [String,Symbol] A unique ID for this container, use random UUID if nil.
#
# @overload initialize(handler=nil, id=nil)
- # @param id [String] A unique ID for this container, use random UUID if nil.
+ # @param id [String,Symbol] A unique ID for this container, use random UUID if nil.
# @param handler [MessagingHandler] Optional default handler for connections
# that do not have their own handler (see {#connect} and {#listen})
#
@@ -102,12 +102,16 @@ module Qpid::Proton
# handler instance for each connection, as a shared handler may be called
# concurrently.
#
- def initialize(handler = nil, id = nil)
- # Allow ID as sole argument
- (handler, id = nil, handler.to_str) if (id.nil? && handler.respond_to?(:to_str))
- # Allow multiple handlers ofor backwards compatibility
- @handler = handler
- @id = ((id && id.to_s) || SecureRandom.uuid).freeze
+ def initialize(*args)
+ case args.size
+ when 2 then @handler, @id = args
+ when 1 then
+ @id = String.try_convert(args[0]) || (args[0].to_s if args[0].is_a? Symbol)
+ @handler = args[0] unless @id
+ else raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..2"
+ end
+ @adapter = Handler::Adapter.adapt(@handler)
+ @id = (@id || SecureRandom.uuid).freeze
# Implementation note:
#
@@ -117,7 +121,7 @@ module Qpid::Proton
# - nil on the @work queue makes a #run thread exit
@work = Queue.new
- @work << :on_start << self # Issue on_start and start start selecting
+ @work << :start << self # Issue start and start start selecting
@wake = IO.pipe # Wakes #run thread in IO.select
@auto_stop = true # Stop when @active drops to 0
@@ -224,9 +228,8 @@ module Qpid::Proton
while task = @work.pop
case task
- when :on_start
- event = Event.new(nil, :on_start, self)
- @handler.on_start(event) if @handler.respond_to? :on_start
+ when :start
+ @adapter.on_container_start(self) if @adapter.respond_to? :on_container_start
when Container
r, w = [@wake[0]], []
@@ -264,8 +267,11 @@ module Qpid::Proton
end
ensure
@lock.synchronize do
- @running -= 1
- work_wake nil if @running > 0 # Tell the next thread to exit
+ if (@running -= 1) > 0
+ work_wake nil # Signal the next thread
+ else
+ @adapter.on_container_stop(self) if @adapter.respond_to? :on_container_stop
+ end
end
end
@@ -296,7 +302,7 @@ module Qpid::Proton
wake
end
- private
+ protected
def wake; @wake[1].write_nonblock('x') rescue nil; end
@@ -314,7 +320,7 @@ module Qpid::Proton
def connection_driver(io, opts=nil, server=false)
opts ||= {}
opts[:container] = self
- opts[:handler] ||= @handler
+ opts[:handler] ||= @adapter
ConnectionTask.new(self, io, opts, server)
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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
index ba89097..e86a06e 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -75,13 +75,15 @@ module Qpid::Proton
def complete?() readable? && !aborted? && !partial?; end
# Get the message from the delivery.
- # @raise [ProtonError] if the message is not {#complete?} or there is an
- # error decoding the message.
+ # @return [Message] The message
+ # @raise [AbortedError] if the message has been aborted (check with {#aborted?}
+ # @raise [UnderflowError] if the message is incomplete (check with {#complete?}
+ # @raise [::ArgumentError] if the delivery is not the current delivery on a receiving link.
def message
return @message if @message
- raise ProtonError("message aborted by sender") if aborted?
- raise ProtonError("incoming message incomplete") if partial?
- raise ProtonError("no incoming message") unless readable?
+ raise AbortedError, "message aborted by sender" if aborted?
+ raise UnderflowError, "incoming message incomplete" if partial?
+ raise ArgumentError, "no incoming message" unless readable?
@message = Message.new
@message.decode(link.receive(pending))
link.advance
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index 88fdbaf..079d1bd 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -130,7 +130,7 @@ module Qpid::Proton
case context
when Delivery then @delivery = @context
# deprecated: for backwards compat allow a Tracker to be treated as a Delivery
- when Tracker then @delivery = Delivery.new(Tracker.impl)
+ when Tracker then @delivery = Delivery.new(context.impl)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 34a3e60..66af5fc 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -117,9 +117,9 @@ module Qpid::Proton
class Release < ProtonError
end
- # Raised when a message is aborted.
+ # Raised when a message is aborted by the sender.
#
- class Aborted < ProtonError
+ class AbortedError < ProtonError
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/core/messaging_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/messaging_handler.rb b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
index 785f730..b733d37 100644
--- a/proton-c/bindings/ruby/lib/core/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/core/messaging_handler.rb
@@ -24,6 +24,9 @@ module Qpid::Proton
#
class MessagingHandler
+ # @private
+ def proton_adapter_class() Handler::MessagingAdapter; end
+
# Create a {MessagingHandler}
# @option opts [Integer] :prefetch (10)
# The number of messages to fetch in advance, 0 disables prefetch.
@@ -40,11 +43,8 @@ module Qpid::Proton
# @option opts [Boolean] :auto_close (true)
# If true, respond to a remote close automatically with a local close.
# If false, the application must call {Connection#close} to finish closing connections.
- # @option opts [Boolean] :peer_close_is_error (false)
- # If true, and the remote peer closes the connection without an error condition,
- # the set the local error condition {Condition}("error", "unexpected peer close")
- def initialize(opts=nil)
- @options = opts && opts.clone
+ def initialize(opts={})
+ @options = opts.clone
end
# @return [Hash] handler options, see {#initialize}
@@ -157,6 +157,10 @@ module Qpid::Proton
# The sending end settled a delivery
# @param delivery [Delivery] The delivery.
+ # @!method on_delivery_abort(delivery)
+ # A message was begun but aborted by the sender, so was not received.
+ # @param delivery [Delivery] The delivery.
+
# @!endgroup
# @!group Flow control events
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index cdf3419..f9c67f5 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -22,13 +22,11 @@ module Qpid::Proton
# Common base class for {Tracker} and {Delivery}.
class Transfer
- private
-
+ # @!private
PROTON_METHOD_PREFIX = "pn_delivery"
+ # @!private
include Util::Wrapper
- protected
-
def self.wrap(impl)
return unless impl
self.fetch_instance(impl, :pn_delivery_attachments) ||
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/handler/adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/adapter.rb b/proton-c/bindings/ruby/lib/handler/adapter.rb
index eb712c3..fc89b12 100644
--- a/proton-c/bindings/ruby/lib/handler/adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/adapter.rb
@@ -20,57 +20,60 @@
module Qpid::Proton
module Handler
- class MultiHandler
- def self.maybe(h)
- a = Array(h)
- a.size > 1 ? self.new(h) : h
- end
+ def self.handler_method?(method) /^on_/ =~ name; end
+
+ # Handler for an array of handlers of uniform type, with non-conflicting options
+ class ArrayHandler
+
+ def initialize(handlers)
+ raise "empty handler array" if handlers.empty?
+ adapters = handlers.map do |h|
+ h.__send__(proton_adapter_class) if h.respond_to? :proton_adapter_class
+ end.uniq
+ raise "handler array not uniform, adapters requested: #{adapters}" if adapters.size > 1
+ @proton_adapter_class = htypes[0]
- def initialize(a)
- @a = a;
@options = {}
@methods = Set.new
- @a.each do |h|
- @methods.merge(h.methods.select { |m| m.to_s.start_with?("on_") })
- @options.merge(h.options) do |k, a, b|
- raise ArgumentError, "handlers have conflicting option #{k} => #{a} != #{b}"
+ handlers.each do |h|
+ if h.respond_to?(:options)
+ @options.merge(h.options) do |k, a, b|
+ raise ArgumentError, "handler array has conflicting options for [#{k}]: #{a} != #{b}"
+ end
end
+ @methods.merge(h.methods.select { |m| handler_method? m }) # Event handler methods
end
end
- attr_reader :options
+ attr_reader :options, :proton_adapter_class
def method_missing(name, *args)
if respond_to_missing?(name)
- @a.each { |h| h.__send__(name, *args) if h.respond_to? name}
+ @adapters.each { |a| a.__send__(name, *args) if a.respond_to? name}
else
super
end
end
+
def respond_to_missing?(name, private=false); @methods.include?(name); end
def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
end
- # Base adapter
+ # Base adapter for raw proton events
class Adapter
- def initialize(h)
- @handler = MultiHandler.maybe h
- end
+ def initialize(h) @handler = h; end
- def self.adapt(h)
- if h.respond_to? :proton_event_adapter
- a = h.proton_event_adapter
- a = a.new(h) if a.is_a? Class
- a
- else
- OldMessagingAdapter.new h
- end
- end
+ def adapter_class(h) nil; end # Adapters don't need adapting
- # Adapter is already an adapter
- def proton_event_adapter() self; end
+ # Create and return an adapter for handler, or return h if it does not need adapting.
+ def self.adapt(handler)
+ return unless handler
+ a = Array(handler)
+ h = (a.size == 1) ? a[0] : ArrayHandler.new(a)
+ a = h.respond_to?(:proton_adapter_class) ? h.proton_adapter_class.new(handler) : h
+ end
- def dispatch(method, *args)
+ def forward(method, *args)
(@handler.__send__(method, *args); true) if @handler.respond_to? method
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
new file mode 100644
index 0000000..4f24d09
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/messaging_adapter.rb
@@ -0,0 +1,125 @@
+# 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.
+
+
+# @private
+module Qpid::Proton
+ module Handler
+
+ # Adapt raw proton events to {MessagingHandler} events.
+ class MessagingAdapter < Adapter
+ def initialize handler
+ super
+ @opts = { :prefetch => 10, :auto_accept => true, :auto_settle => true,
+ :auto_open => true, :auto_close => true }
+ if handler.respond_to?(:options) && handler.options
+ @opts.update(handler.options)
+ handler.options.replace @opts
+ end
+ end
+
+ def delegate(method, *args)
+ forward(method, *args) or forward(:on_unhandled, method, *args)
+ end
+
+ def delegate_error(method, context)
+ unless forward(method, context) || forward(:on_error, context.condition)
+ forward(:on_unhandled, method, context)
+ # By default close the whole connection on an un-handled error
+ context.connection.close(context.condition) if @opts[:auto_close]
+ end
+ end
+
+ def on_container_start(container) delegate(:on_container_start, container); end
+ def on_container_stop(container) delegate(:on_container_stop, container); end
+
+ # Define repetative on_xxx_open/close methods for each endpoint type
+ def self.open_close(endpoint)
+ Module.new do
+ define_method(:"on_#{endpoint}_remote_open") do |event|
+ delegate(:"on_#{endpoint}_open", event.context)
+ event.context.open if @opts[:auto_open] && event.context.local_uninit?
+ end
+
+ define_method(:"on_#{endpoint}_remote_close") do |event|
+ delegate_error(:"on_#{endpoint}_error", event.context) if event.context.condition
+ delegate(:"on_#{endpoint}_close", event.context)
+ event.context.close if @opts[:auto_close] && event.context.local_active?
+ end
+ end
+ end
+ # Generate and include open_close modules for each endpoint type
+ # Using modules so we can override to extend the behavior later in the handler.
+ [:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
+
+ def on_transport_error(event) delegate_error(:on_transport_error, event.context); end
+ def on_transport_closed(event) delegate(:on_transport_close, event.context); end
+
+ # Add flow control for link opening events
+ def on_link_local_open(event) add_credit(event.receiver); end
+ def on_link_remote_open(event) super; add_credit(event.receiver); end
+
+
+ def on_delivery(event)
+ if event.link.receiver? # Incoming message
+ d = event.delivery
+ if d.aborted?
+ delegate(:on_delivery_abort, d)
+ elsif d.complete?
+ if d.link.local_closed? && @opts[:auto_accept]
+ d.release # Auto release after close
+ else
+ begin
+ delegate(:on_message, d, d.message)
+ d.accept if @opts[:auto_accept] && !d.settled?
+ rescue Reject
+ d.reject unless d.settled?
+ rescue Release
+ d.release unless d.settled
+ end
+ end
+ end
+ delegate(:on_delivery_settle, d) if d.settled?
+ add_credit(event.receiver)
+ else # Outgoing message
+ t = event.tracker
+ case t.remote_state
+ when Delivery::ACCEPTED then delegate(:on_tracker_accept, t)
+ when Delivery::REJECTED then delegate(:on_tracker_reject, t)
+ when Delivery::RELEASED then delegate(:on_tracker_release, t)
+ when Delivery::MODIFIED then delegate(:on_tracker_modify, t)
+ end
+ delegate(:on_tracker_settle, t) if t.settled?
+ t.settle if @opts[:auto_settle]
+ end
+ end
+
+ def on_link_flow(event)
+ add_credit(event.receiver)
+ sender = event.sender
+ delegate(:on_sendable, sender) if sender && sender.open? && sender.credit > 0
+ end
+
+ def add_credit(r)
+ prefetch = @opts[:prefetch]
+ if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
+ r.flow(prefetch - r.credit)
+ end
+ end
+ end
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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
index 0e94c17..e4e5e12 100644
--- a/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
+++ b/proton-c/bindings/ruby/lib/handler/messaging_handler.rb
@@ -22,6 +22,10 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::MessagingHandler}
class MessagingHandler
+ # @private
+ def proton_adapter_class() Handler::ReactorMessagingAdapter; end
+
+
# @overload initialize(opts)
# Create a {MessagingHandler} with options +opts+
# @option opts [Integer] :prefetch (10)
@@ -46,6 +50,7 @@ module Qpid::Proton
# @overload initialize(prefetch=10, auto_accept=true, auto_settle=true, peer_close_is_error=false)
# @deprecated use +initialize(opts)+ overload
def initialize(*args)
+ Qpid.deprecated MessagingHandler, Qpid::Proton::MessagingHandler
@options = {}
if args.size == 1 && args[0].is_a?(Hash)
@options.replace(args[0])
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
deleted file mode 100644
index c43dc8c..0000000
--- a/proton-c/bindings/ruby/lib/handler/old_messaging_adapter.rb
+++ /dev/null
@@ -1,151 +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.
-
-
-# @private
-module Qpid::Proton
- module Handler
-
- # Adapter to convert raw proton events to old {Handler::MessagingHandler} events
- class OldMessagingAdapter < Adapter
- def initialize handler
- super
- @opts = (handler.options if handler.respond_to?(:options)) || {}
- @opts[:prefetch] ||= 10
- @opts[:peer_close_is_error] = false unless @opts.include? :peer_close_is_error
- [:auto_accept, :auto_settle, :auto_open, :auto_close].each do |k|
- @opts[k] = true unless @opts.include? k
- end
- end
-
- def delegate(method, event)
- event.method = method # Update the event with the new method
- event.dispatch(@handler) || dispatch(:on_unhandled, event)
- end
- def delegate_error(method, event)
- event.method = method
- unless event.dispatch(@handler) # Default behaviour if not dispatched
- dispatch(:on_error, event) || dispatch(:on_unhandled, event)
- event.connection.close event.context.condition # Close the connection by default
- end
- end
-
- # Define repetative on_xxx_open/close methods for each endpoint type
- def self.open_close(endpoint)
- on_opening = :"on_#{endpoint}_opening"
- on_opened = :"on_#{endpoint}_opened"
- on_closing = :"on_#{endpoint}_closing"
- on_closed = :"on_#{endpoint}_closed"
- on_error = :"on_#{endpoint}_error"
-
- Module.new do
- define_method(:"on_#{endpoint}_local_open") do |event|
- delegate(on_opened, event) if event.context.remote_open?
- end
-
- define_method(:"on_#{endpoint}_remote_open") do |event|
- if event.context.local_open?
- delegate(on_opened, event)
- elsif event.context.local_uninit?
- delegate(on_opening, event)
- event.context.open if @opts[:auto_open]
- end
- end
-
- define_method(:"on_#{endpoint}_local_close") do |event|
- delegate(on_closed, event) if event.context.remote_closed?
- end
-
- define_method(:"on_#{endpoint}_remote_close") do |event|
- if event.context.remote_condition
- delegate_error(on_error, event)
- elsif event.context.local_closed?
- delegate(on_closed, event)
- elsif @opts[:peer_close_is_error]
- Condition.assign(event.context.__send__(:_remote_condition), "unexpected peer close")
- delegate_error(on_error, event)
- else
- delegate(on_closing, event)
- end
- event.context.close if @opts[:auto_close]
- end
- end
- end
- # Generate and include open_close modules for each endpoint type
- [:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
-
- def on_transport_error(event) delegate_error(:on_transport_error, event); end
- def on_transport_closed(event) delegate(:on_transport_closed, event); end
-
- # Add flow control for link opening events
- def on_link_local_open(event) super; add_credit(event); end
- def on_link_remote_open(event) super; add_credit(event); end
-
-
- def on_delivery(event)
- if event.link.receiver? # Incoming message
- d = event.delivery
- if d.aborted?
- delegate(:on_aborted, event)
- d.settle
- elsif d.complete?
- if d.link.local_closed? && @opts[:auto_accept]
- d.release
- else
- begin
- delegate(:on_message, event)
- d.accept if @opts[:auto_accept]
- rescue Qpid::Proton::Reject
- d.reject
- rescue Qpid::Proton::Release
- d.release(true)
- end
- end
- end
- delegate(:on_settled, event) if d.settled?
- add_credit(event)
- else # Outgoing message
- t = event.tracker
- if t.updated?
- case t.remote_state
- when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
- when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
- when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
- when Qpid::Proton::Delivery::MODIFIED then delegate(:on_modified, event)
- end
- delegate(:on_settled, event) if t.settled?
- t.settle if @opts[:auto_settle]
- end
- end
- end
-
- def on_link_flow(event)
- add_credit(event)
- l = event.link
- delegate(:on_sendable, event) if l.sender? && l.open? && l.credit > 0
- end
-
- def add_credit(event)
- r = event.receiver
- prefetch = @opts[:prefetch]
- if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
- r.flow(prefetch - r.credit)
- end
- end
- end
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.rb
new file mode 100644
index 0000000..7acbbae
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/reactor_messaging_adapter.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.
+
+
+# @private
+module Qpid::Proton
+ module Handler
+
+ # Adapter to convert raw proton events for the old {Handler::MessagingHandler}
+ # used by the Reactor.
+ class ReactorMessagingAdapter < Adapter
+ def initialize handler
+ super
+ @opts = (handler.options if handler.respond_to?(:options)) || {}
+ @opts[:prefetch] ||= 10
+ @opts[:peer_close_is_error] = false unless @opts.include? :peer_close_is_error
+ [:auto_accept, :auto_settle, :auto_open, :auto_close].each do |k|
+ @opts[k] = true unless @opts.include? k
+ end
+ end
+
+ alias dispatch forward
+
+ def delegate(method, event)
+ event.method = method # Update the event with the new method
+ event.dispatch(@handler) or dispatch(:on_unhandled, event)
+ end
+
+ def delegate_error(method, event)
+ event.method = method
+ unless event.dispatch(@handler) || dispatch(:on_error, event)
+ dispatch(:on_unhandled, event)
+ event.connection.close(event.context.condition) if @opts[:auto_close]
+ end
+ end
+
+ def on_container_start(container) delegate(:on_start, Event.new(nil, nil, container)); end
+ def on_container_stop(container) delegate(:on_stop, Event.new(nil, nil, container)); end
+
+ # Define repetative on_xxx_open/close methods for each endpoint type
+ def self.open_close(endpoint)
+ on_opening = :"on_#{endpoint}_opening"
+ on_opened = :"on_#{endpoint}_opened"
+ on_closing = :"on_#{endpoint}_closing"
+ on_closed = :"on_#{endpoint}_closed"
+ on_error = :"on_#{endpoint}_error"
+
+ Module.new do
+ define_method(:"on_#{endpoint}_local_open") do |event|
+ delegate(on_opened, event) if event.context.remote_open?
+ end
+
+ define_method(:"on_#{endpoint}_remote_open") do |event|
+ if event.context.local_open?
+ delegate(on_opened, event)
+ elsif event.context.local_uninit?
+ delegate(on_opening, event)
+ event.context.open if @opts[:auto_open]
+ end
+ end
+
+ define_method(:"on_#{endpoint}_local_close") do |event|
+ delegate(on_closed, event) if event.context.remote_closed?
+ end
+
+ define_method(:"on_#{endpoint}_remote_close") do |event|
+ if event.context.remote_condition
+ delegate_error(on_error, event)
+ elsif event.context.local_closed?
+ delegate(on_closed, event)
+ elsif @opts[:peer_close_is_error]
+ Condition.assign(event.context.__send__(:_remote_condition), "unexpected peer close")
+ delegate_error(on_error, event)
+ else
+ delegate(on_closing, event)
+ end
+ event.context.close if @opts[:auto_close]
+ end
+ end
+ end
+ # Generate and include open_close modules for each endpoint type
+ [:connection, :session, :link].each { |endpoint| include open_close(endpoint) }
+
+ def on_transport_error(event) delegate_error(:on_transport_error, event); end
+ def on_transport_closed(event) delegate(:on_transport_closed, event); end
+
+ # Add flow control for link opening events
+ def on_link_local_open(event) super; add_credit(event); end
+ def on_link_remote_open(event) super; add_credit(event); end
+
+
+ def on_delivery(event)
+ if event.link.receiver? # Incoming message
+ d = event.delivery
+ if d.aborted?
+ delegate(:on_aborted, event)
+ d.settle
+ elsif d.complete?
+ if d.link.local_closed? && @opts[:auto_accept]
+ d.release
+ else
+ begin
+ delegate(:on_message, event)
+ d.accept if @opts[:auto_accept] && !d.settled?
+ rescue Qpid::Proton::Reject
+ d.reject
+ rescue Qpid::Proton::Release
+ d.release(true)
+ end
+ end
+ end
+ delegate(:on_settled, event) if d.settled?
+ add_credit(event)
+ else # Outgoing message
+ t = event.tracker
+ if t.updated?
+ case t.remote_state
+ when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
+ when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
+ when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
+ when Qpid::Proton::Delivery::MODIFIED then delegate(:on_modified, event)
+ end
+ delegate(:on_settled, event) if t.settled?
+ t.settle if @opts[:auto_settle]
+ end
+ end
+ end
+
+ def on_link_flow(event)
+ add_credit(event)
+ l = event.link
+ delegate(:on_sendable, event) if l.sender? && l.open? && l.credit > 0
+ end
+
+ def add_credit(event)
+ r = event.receiver
+ prefetch = @opts[:prefetch]
+ if r && r.open? && (r.drained == 0) && prefetch && (prefetch > r.credit)
+ r.flow(prefetch - r.credit)
+ end
+ end
+ end
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 2d93454..922504f 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -85,21 +85,22 @@ require "core/transport"
require "core/url"
require "core/connection_driver"
-# Messenger API classes
-require "messenger/subscription"
-require "messenger/tracker_status"
-require "messenger/tracker"
-require "messenger/messenger"
-
-# Handler classes
+# Handlers and adapters
require "handler/adapter"
-require "handler/old_messaging_adapter"
-# Core classes that depend on Handler
+require "handler/messaging_adapter"
require "core/messaging_handler"
+
+# Main container class
require "core/container"
-require "core/connection_driver"
-# Backwards compatibility shims
+# DEPRECATED Backwards compatibility shims for Reactor API
+require "handler/reactor_messaging_adapter"
+require "handler/messaging_handler" # Keep original name for compatibility
require "reactor/container"
-require "handler/messaging_handler"
+
+# DEPRECATED Messenger API classes
+require "messenger/subscription"
+require "messenger/tracker_status"
+require "messenger/tracker"
+require "messenger/messenger"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 8ce5ea6..a900d9e 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -16,58 +16,62 @@
# under the License.
-module Qpid::Proton::Reactor
+module Qpid::Proton
+ module Reactor
- # @deprecated use {Qpid::Proton::Container}
- class Container < Qpid::Proton::Container
+ # @deprecated use {Qpid::Proton::Container}
+ class Container < Qpid::Proton::Container
- private
- alias super_connect connect # Access to superclass method
+ private
+ alias super_connect connect # Access to superclass method
- public
+ public
- # @deprecated use {Qpid::Proton::Container}
- def initialize(handlers, opts=nil)
- Qpid.deprecated self.class, "Qpid::Proton::Container"
- super handlers || (opts && opts[:global_handler]), opts && opts[:container_id]
- end
+ # @deprecated use {Qpid::Proton::Container}
+ def initialize(handlers, opts=nil)
+ Qpid.deprecated self.class, "Qpid::Proton::Container"
+ h = handlers || (opts && opts[:global_handler])
+ id = opts && opts[:container_id]
+ super(h, id)
+ end
- alias container_id id
- alias global_handler handler
+ alias container_id id
+ alias global_handler handler
- 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
+ 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 {#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
+ # @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
+ c.open_sender opts
end
- c.open_sender opts
- end
- # @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
+ # @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
+ c.open_receiver opts
end
- c.open_receiver opts
- end
- def listen(url, ssl_domain = nil)
- # TODO aconway 2017-11-29: ssl_domain
- super(url)
+ def listen(url, ssl_domain = nil)
+ # TODO aconway 2017-11-29: ssl_domain
+ super(url)
+ end
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/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 d00a86b..4ea1d70 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -55,9 +55,14 @@ module Qpid::Proton
attr_reader :type
# @return [Object] Optional descriptor.
- def attr_reader() descriptor; end
+ attr_reader :descriptor
def inspect() "#{self.class.name}<#{type}>#{super}"; end
+
+ def <=>(x)
+ ret = [@type, @descriptor] <=> [x.type, x.descriptor]
+ ret == 0 ? super : ret
+ end
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/spec/array_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/array_spec.rb b/proton-c/bindings/ruby/spec/array_spec.rb
index e760877..ce73760 100644
--- a/proton-c/bindings/ruby/spec/array_spec.rb
+++ b/proton-c/bindings/ruby/spec/array_spec.rb
@@ -38,65 +38,41 @@ describe "The extended array type" do
expect(value).respond_to? :proton_described?
end
- it "raises an error when getting from a nil Data object" do
- expect {
- Array.proton_get(nil)
- }.must_raise
- end
-
it "raises an error when the current object is not a list" do
@data.string = random_string(128)
@data.rewind
expect {
- Array.proton_get(@data)
+ @data.list
}.must_raise(TypeError)
end
- it "does not have an array header when it's a simple list" do
- assert !@list.proton_described?
- end
-
it "can be put into a Data object as a list" do
- @list.proton_put(@data)
- result = Array.proton_get(@data)
+ @data.list= @list
+ result = @data.list
expect(result).must_equal(@list)
- expect(result.proton_array_header) == (nil)
- end
-
- it "has an array header when it's an AMQP array" do
- expect(@undescribed.proton_array_header).wont_be_nil
- expect(@described.proton_array_header).wont_be_nil
end
it "raises an error when the elements of an Array are dissimilar and is put into a Data object" do
- value = []
- value.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT)
+ value = Qpid::Proton::Types::UniformArray.new(Qpid::Proton::Codec::INT)
value << random_string(16)
-
expect {
- value.proton_put(@data)
+ @data << value
}.must_raise(TypeError)
end
it "can be put into a Data object as an undescribed array" do
- @undescribed.proton_put(@data)
- result = Array.proton_get(@data)
+ @data << @undescribed
+ result = @data.array
expect(result).is_a? Qpid::Proton::Types::UniformArray
expect(@undescribed).must_equal(result)
- expect(result.proton_array_header).wont_be_nil
- expect(result.proton_array_header).must_equal(@undescribed.proton_array_header)
- assert !result.proton_array_header.described?
end
it "can be put into a Data object as a described array" do
- @described.proton_put(@data)
- result = Array.proton_get(@data)
+ @data << @described
+ result = @data.array
expect(@described).must_equal(result)
expect(result).is_a? Qpid::Proton::Types::UniformArray
- expect(result.proton_array_header).wont_be_nil
- expect(result.proton_array_header).must_equal(@described.proton_array_header)
- expect(result.proton_array_header.described?).must_equal(true)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/spec_helper.rb b/proton-c/bindings/ruby/spec/spec_helper.rb
index 2698bb9..809da52 100644
--- a/proton-c/bindings/ruby/spec/spec_helper.rb
+++ b/proton-c/bindings/ruby/spec/spec_helper.rb
@@ -83,30 +83,24 @@ end
# Generates a random array of a random type.
# Returns both the array and the type.
def random_array(length, described = false, description = nil)
- result = []
- type = rand(128) % 4
+ choice = rand(128) % 4
+ type = [Qpid::Proton::Types::INT,
+ Qpid::Proton::Types::STRING,
+ Qpid::Proton::Types::DOUBLE,
+ Qpid::Proton::Types::UUID][choice]
+ result = Qpid::Proton::Types::UniformArray.new(type)
+
low = rand(512)
high = rand(8192)
(0...length).each do |element|
case
- when type == 0 then result << rand(1024)
- when type == 1 then result << random_string(rand(128))
- when type == 2 then result << rand * (low - high).abs + low
- when type == 3 then result << SecureRandom.uuid
+ when choice == 0 then result << rand(1024)
+ when choice == 1 then result << random_string(rand(128))
+ when choice == 2 then result << rand * (low - high).abs + low
+ when choice == 3 then result << SecureRandom.uuid
end
end
-
- # create the array header
- case
- when type == 0 then type = Qpid::Proton::Codec::INT
- when type == 1 then type = Qpid::Proton::Codec::STRING
- when type == 2 then type = Qpid::Proton::Codec::DOUBLE
- when type == 3 then type = Qpid::Proton::Codec::UUID
- end
-
- result.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(type, description)
-
return result
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
index de8077c..e8b21d2 100755
--- a/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/old_example_test.rb
@@ -28,7 +28,7 @@ def make_url(port, path) "amqp://:#{port}/#{path}"; end
class OldExampleTest < MiniTest::Test
def run_script(*args)
- IO.popen [RbConfig.ruby, "-W0", *args];
+ IO.popen [RbConfig.ruby, *args];
end
def assert_output(want, args)
@@ -91,7 +91,7 @@ end
# Start the broker before all tests.
$port = unused_port
-$broker = IO.popen [RbConfig.ruby, "-W0", "broker.rb", "-a", ":#{$port}"]
+$broker = IO.popen [RbConfig.ruby, "broker.rb", "-a", ":#{$port}"]
$broker.readline # Wait for "Listening"
# Kill the broker after all tests
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_adapter.rb b/proton-c/bindings/ruby/tests/test_adapter.rb
deleted file mode 100644
index 62ef109..0000000
--- a/proton-c/bindings/ruby/tests/test_adapter.rb
+++ /dev/null
@@ -1,227 +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.
-
-
-require 'minitest/autorun'
-require 'qpid_proton'
-require 'test_tools'
-include Qpid::Proton
-
-# Records every call
-class AllHandler < MessagingHandler
- def initialize(*args)
- super(*args)
- @calls = []
- end
-
- attr_accessor :calls
-
- def names; @calls.map { |c| c[0] }; end
- def events; @calls.map { |c| c[1] }; end
-
- def method_missing(name, *args) (/^on_/ =~ name) ? (@calls << [name] + args) : super; end
- def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
- def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
-end
-
-# Tests with Mock handler that handles all methods, expect both old and new calls
-class TestOldHandler < Minitest::Test
- def setup
- @h = [AllHandler.new, AllHandler.new]
- @ch, @sh = *@h
- @d = DriverPair.new(*@h)
- end
-
- def clear; @d.each { |d| h = d.handler; h.calls.clear }; end
-
- def test_handler_defaults
- want = { :prefetch => 10, :auto_settle => true, :auto_accept => true, :auto_open => true, :auto_close => true, :peer_close_is_error => false }
- assert_equal want, @ch.options
- assert_equal want, @sh.options
- end
-
- def test_auto_open_close
- @d.client.connection.open; @d.client.connection.open_sender; @d.run
- assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable], @ch.names
- assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening, :on_connection_opened, :on_session_opened, :on_link_opened], @sh.names
- clear
- @d.client.connection.close; @d.run
- assert_equal [:on_connection_closed, :on_transport_closed], @ch.names
- assert_equal [:on_connection_closing, :on_connection_closed, :on_transport_closed], @sh.names
- end
-
- def test_no_auto_open_close
- [:auto_close, :auto_open].each { |k| @ch.options[k] = @sh.options[k] = false }
- @d.client.connection.open; @d.run
- assert_equal [:on_connection_opening], @sh.names
- assert_equal [], @ch.names
- @d.server.connection.open; @d.run
- assert_equal [:on_connection_opened], @ch.names
- assert_equal [:on_connection_opening, :on_connection_opened], @sh.names
- clear
- @d.client.connection.session.open; @d.run
- assert_equal [:on_session_opening], @sh.names
- assert_equal [], @ch.names
- clear
- @d.client.connection.close;
- 3.times { @d.process }
- assert_equal [:on_connection_closing], @sh.names
- assert_equal [], @ch.names
- @d.server.connection.close; @d.run
- assert_equal [:on_connection_closed, :on_transport_closed], @ch.names
- assert_equal [:on_connection_closing, :on_connection_closed, :on_transport_closed], @sh.names
- end
-
- def test_transport_error
- @d.client.connection.open; @d.run
- clear
- @d.client.close "stop that"; @d.run
- assert_equal [:on_transport_closed], @ch.names
- assert_equal [:on_transport_error, :on_transport_closed], @sh.names
- assert_equal Condition.new("proton:io", "stop that (connection aborted)"), @d.client.transport.condition
- assert_equal Condition.new("amqp:connection:framing-error", "connection aborted"), @d.server.transport.condition
- end
-
- def test_connection_error
- @ch.options[:auto_open] = @sh.options[:auto_open] = false
- @d.client.connection.open; @d.run
- @d.server.connection.close "bad dog"; @d.run
- assert_equal [:on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], @ch.names
- assert_equal "bad dog", @ch.calls[2][1].condition.description
- assert_equal [:on_connection_opening, :on_connection_closed, :on_transport_closed], @sh.names
- end
-
- def test_session_error
- @d.client.connection.open
- s = @d.client.connection.session; s.open; @d.run
- s.close "bad dog"; @d.run
- assert_equal [:on_connection_opened, :on_session_opened, :on_session_closed], @ch.names
- assert_equal [:on_connection_opening, :on_session_opening, :on_connection_opened, :on_session_opened, :on_session_error, :on_session_closed], @sh.names
- assert_equal "bad dog", @sh.calls[-3][1].condition.description
- end
-
- def test_link_error
- @d.client.connection.open
- s = @d.client.connection.open_sender; @d.run
- s.close "bad dog"; @d.run
- assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable, :on_link_closed], @ch.names
- assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening,
- :on_connection_opened, :on_session_opened, :on_link_opened,
- :on_link_error, :on_link_closed], @sh.names
- assert_equal "bad dog", @sh.calls[-3][1].condition.description
- end
-
- def test_options_off
- off = {:prefetch => 0, :auto_settle => false, :auto_accept => false, :auto_open => false, :auto_close => false}
- @ch.options.replace(off)
- @sh.options.replace(off)
- @d.client.connection.open; @d.run
- assert_equal [[], [:on_connection_opening]], [@ch.names, @sh.names]
- @d.server.connection.open; @d.run
- assert_equal [[:on_connection_opened], [:on_connection_opening, :on_connection_opened]], [@ch.names, @sh.names]
- clear
- s = @d.client.connection.open_sender; @d.run
- assert_equal [[], [:on_session_opening, :on_link_opening]], [@ch.names, @sh.names]
- @sh.events[1].session.open
- r = @sh.events[1].link
- r.open; @d.run
- assert_equal [[:on_session_opened, :on_link_opened], [:on_session_opening, :on_link_opening, :on_session_opened, :on_link_opened]], [@ch.names, @sh.names]
- clear
- r.flow(1); @d.run
- assert_equal [[:on_sendable], []], [@ch.names, @sh.names]
- assert_equal 1, s.credit
- clear
- s.send Message.new("foo"); @d.run
- assert_equal [[], [:on_message]], [@ch.names, @sh.names]
- end
-
- def test_peer_close_is_error
- @ch.options[:peer_close_is_error] = true
- @d.client.connection.open; @d.run
- @d.server.connection.close; @d.run
- assert_equal [:on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], @ch.names
- assert_equal [:on_connection_opening, :on_connection_opened, :on_connection_closed, :on_transport_closed], @sh.names
- end
-end
-
-# Test with real handlers that implement a few methods
-class TestOldUnhandled < Minitest::Test
-
- def test_message
- handler_class = Class.new(MessagingHandler) do
- def on_message(event) @message = event.message; end
- def on_accepted(event) @accepted = true; end
- attr_accessor :message, :accepted, :sender
- end
- d = DriverPair.new(handler_class.new, handler_class.new)
- d.client.connection.open;
- s = d.client.connection.open_sender; d.run
- assert_equal 10, s.credit # Default prefetch
- s.send(Message.new("foo")); d.run
- assert_equal "foo", d.server.handler.message.body
- assert d.client.handler.accepted
- end
-
- # Verify on_unhandled is called
- def test_unhandled
- handler_class = Class.new(MessagingHandler) do
- def initialize() super; @unhandled = []; end
- def on_unhandled(event) @unhandled << event.method; end
- attr_accessor :unhandled
- end
- d = DriverPair.new(handler_class.new, handler_class.new)
- d.client.connection.open; d.run
- assert_equal [:on_connection_opened], d.client.handler.unhandled
- assert_equal [:on_connection_opening, :on_connection_opened], d.server.handler.unhandled
- end
-
- # Verify on_error is called
- def test_on_error
- handler_class = Class.new(MessagingHandler) do
- def initialize() super; @error = []; @unhandled = []; end
- def on_error(event) @error << event.method; end
- def on_unhandled(event) @unhandled << event.method; end
- attr_accessor :error, :unhandled
- end
- d = DriverPair.new(handler_class.new, handler_class.new)
- d.client.connection.open
- r = d.client.connection.open_receiver; d.run
- r.close "oops"; d.run
- assert_equal [:on_connection_opened, :on_session_opened, :on_link_opened,
- :on_link_closed, :on_connection_closed, :on_transport_closed], d.client.handler.unhandled
- assert_equal [:on_connection_error], d.client.handler.error
- assert_equal [:on_connection_opening, :on_session_opening, :on_link_opening,
- :on_connection_opened, :on_session_opened, :on_link_opened, :on_sendable,
- :on_link_closed, :on_connection_closed, :on_transport_closed], d.server.handler.unhandled
- assert_equal [:on_link_error], d.server.handler.error
-
- end
-
- # Verify on_unhandled is called even for errors if there is no on_error
- def test_unhandled_error
- handler_class = Class.new(MessagingHandler) do
- def initialize() super; @unhandled = []; end
- def on_unhandled(event) @unhandled << event.method; end
- attr_accessor :unhandled
- end
- d = DriverPair.new(handler_class.new, handler_class.new)
- d.client.connection.open; d.run
- d.client.connection.close "oops"; d.run
- assert_equal [:on_connection_opened, :on_connection_closed, :on_transport_closed], d.client.handler.unhandled
- assert_equal [:on_connection_opening, :on_connection_opened, :on_connection_error, :on_connection_closed, :on_transport_closed], d.server.handler.unhandled
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_connection_driver.rb b/proton-c/bindings/ruby/tests/test_connection_driver.rb
index a9982b5..3386e49 100644
--- a/proton-c/bindings/ruby/tests/test_connection_driver.rb
+++ b/proton-c/bindings/ruby/tests/test_connection_driver.rb
@@ -19,32 +19,49 @@ require 'test_tools'
include Qpid::Proton
-class HandlerDriverTest < Minitest::Test
+# Test delivery of raw proton events
+
+class RawDriverTest < Minitest::Test
+
+ # Raw handler to record all on_xxx calls
+ class RecordingHandler
+ def initialize() @calls =[]; end
+ attr_reader :calls
+
+ def method_missing(name, *args) respond_to_missing?(name) ? @calls << name : super; end
+ def respond_to_missing?(name, private=false); (/^on_/ =~ name); end
+ def respond_to?(name, all=false) super || respond_to_missing?(name); end # For ruby < 1.9.2
+ end
def test_send_recv
- send_class = Class.new(MessagingHandler) do
- attr_reader :accepted
- def on_sendable(event) event.sender.send Message.new("foo"); end
- def on_accepted(event) event.connection.close; @accepted = true; end
+ send_class = Class.new do
+ attr_reader :outcome
+ def on_link_flow(event) event.sender.send Message.new("foo"); end
+ def on_delivery(event)
+ @outcome = event.delivery.state
+ event.connection.close;
+ end
end
- recv_class = Class.new(MessagingHandler) do
+ recv_class = Class.new do
attr_reader :message
- def on_link_opened(event) event.link.flow(1); event.link.open; end
- def on_message(event) @message = event.message; event.connection.close; end
+ def on_connection_remote_open(event) event.context.open; end
+ def on_session_remote_open(event) event.context.open; end
+ def on_link_remote_open(event) event.link.open; event.link.flow(1); end
+ def on_delivery(event) @message = event.message; event.delivery.accept; end
end
d = DriverPair.new(send_class.new, recv_class.new)
- d.client.connection.open(:container_id => "sender");
+ d.client.connection.open(:container_id => __method__);
d.client.connection.open_sender()
d.run
assert_equal(d.server.handler.message.body, "foo")
- assert(d.client.handler.accepted)
+ assert_equal Transfer::ACCEPTED, d.client.handler.outcome
end
def test_idle
- d = DriverPair.new(UnhandledHandler.new, UnhandledHandler.new)
+ d = DriverPair.new(RecordingHandler.new, RecordingHandler.new)
ms = 444
secs = Rational(ms, 1000) # Use rationals to keep it accurate
opts = {:idle_timeout => secs}
@@ -56,8 +73,8 @@ class HandlerDriverTest < Minitest::Test
start = Time.at(1) # Dummy timeline
tick = d.run start # Process all IO events
assert_equal(secs/4, tick - start)
- assert_equal [:on_connection_opened], d.client.handler.calls
- assert_equal [:on_connection_opening, :on_connection_opened], d.server.handler.calls
+ assert_equal [:on_connection_init, :on_connection_local_open, :on_connection_bound], d.client.handler.calls
+ assert_equal [:on_connection_init, :on_connection_bound, :on_connection_remote_open, :on_transport], d.server.handler.calls
assert_equal (ms), d.client.transport.idle_timeout
assert_equal (ms/2), d.server.transport.remote_idle_timeout # proton changes the value
assert_equal (secs/2), d.server.connection.idle_timeout
@@ -67,6 +84,6 @@ class HandlerDriverTest < Minitest::Test
d.run(start + secs - 0.001) # Should nothing, timeout not reached
assert_equal [[],[]], d.collect { |x| x.handler.calls }
d.run(start + secs*2) # After 2x timeout, connections should close
- assert_equal [[:on_transport_error, :on_transport_closed], [:on_connection_error, :on_connection_closed, :on_transport_closed]], d.collect { |x| x.handler.calls }
+ assert_equal [[:on_transport_error, :on_transport_tail_closed, :on_transport_head_closed, :on_transport_closed], [:on_connection_remote_close, :on_transport_tail_closed, :on_transport_head_closed, :on_transport_closed]], d.collect { |x| x.handler.calls }
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a13bc2b9/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index bfa40b1..044ebf4 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -20,92 +20,79 @@ require 'test_tools'
require 'minitest/unit'
require 'socket'
-Message = Qpid::Proton::Message
-SASL = Qpid::Proton::SASL
-Disposition = Qpid::Proton::Disposition
-
-# Easier debugging of thread problems
-Thread::abort_on_exception=true
-
# Container that listens on a random port
-class TestContainer < Container
+class TestContainer < Qpid::Proton::Container
def initialize(handler, lopts=nil, id=nil)
super handler, id
- @server = TCPServer.open(0)
- @listener = listen_io(@server, ListenOnceHandler.new(lopts))
+ @listener = listen_io(TCPServer.open(0), ListenOnceHandler.new(lopts))
end
- def port() @server.addr[1]; end
- def url() "amqp://:#{port}"; end
+ def port() @listener.to_io.addr[1]; end
+ def url() "amqp://:#{port}"; end#
end
class ContainerTest < Minitest::Test
+ include Qpid::Proton
def test_simple()
- sh = Class.new(MessagingHandler) do
+ send_handler = Class.new(MessagingHandler) do
attr_reader :accepted, :sent
- def on_sendable(e)
- e.link.send Message.new("foo") unless @sent
+ def on_sendable(sender)
+ sender.send Message.new("foo") unless @sent
@sent = true
end
- def on_accepted(e)
+ def on_tracker_accept(tracker)
@accepted = true
- e.connection.close
+ tracker.connection.close
end
end.new
- rh = Class.new(MessagingHandler) do
+ receive_handler = Class.new(MessagingHandler) do
attr_reader :message, :link
- def on_link_opening(e)
- @link = e.link
- e.link.open
- e.link.flow(1)
+ def on_link_open(link)
+ @link = link
+ @link.open
+ @link.flow(1)
end
- def on_message(e)
- @message = e.message;
- e.delivery.update Disposition::ACCEPTED
- e.delivery.settle
+ def on_message(delivery, message)
+ @message = message;
+ delivery.update Disposition::ACCEPTED
+ delivery.settle
end
end.new
- c = TestContainer.new(rh, {}, __method__)
- c.connect(c.url, {:handler => sh}).open_sender({:name => "testlink"})
+ c = TestContainer.new(receive_handler, {}, __method__)
+ c.connect(c.url, {:handler => send_handler}).open_sender({:name => "testlink"})
c.run
- assert sh.accepted
- assert_equal "testlink", rh.link.name
- assert_equal "foo", rh.message.body
- assert_equal "test_simple", rh.link.connection.container_id
+ assert send_handler.accepted
+ assert_equal "testlink", receive_handler.link.name
+ assert_equal "foo", receive_handler.message.body
+ assert_equal "test_simple", receive_handler.link.connection.container_id
end
class CloseOnOpenHandler < TestHandler
- def on_connection_opened(e) e.connection.close; end
- end
-
- def test_multi_handler
- handler_class = Class.new(CloseOnOpenHandler) do
- @@opened = 0
- def self.opened; @@opened; end
- def on_connection_opened(e) @@opened += 1; super; end
- end
- hs = 3.times.collect { handler_class.new }
- c = TestContainer.new(hs, {}, __method__)
- c.connect(c.url)
- c.run
- assert_equal 6, handler_class.opened # Opened at each end * 3 handlers
+ def on_connection_open(c) c.close; end
end
def test_auto_stop_one
# A listener and a connection
- c = Container.new(__method__)
+ start_stop_handler = Class.new do
+ def on_container_start(c) @start = c; end
+ def on_container_stop(c) @stop = c; end
+ attr_reader :start, :stop
+ end.new
+ c = Container.new(start_stop_handler, __method__)
threads = 3.times.collect { Thread.new { c.run } }
sleep(0.01) while c.running < 3
+ assert_equal c, start_stop_handler.start
l = c.listen_io(TCPServer.new(0), ListenOnceHandler.new({ :handler => CloseOnOpenHandler.new}))
c.connect("amqp://:#{l.to_io.addr[1]}", { :handler => CloseOnOpenHandler.new} )
threads.each { |t| assert t.join(1) }
+ assert_equal c, start_stop_handler.stop
assert_raises(Container::StoppedError) { c.run }
end
@@ -113,8 +100,8 @@ class ContainerTest < Minitest::Test
# Connect between different containers
c1, c2 = Container.new("#{__method__}-1"), Container.new("#{__method__}-2")
threads = [ Thread.new {c1.run }, Thread.new {c2.run } ]
- l = c1.listen_io(TCPServer.new(0), ListenOnceHandler.new({ :handler => CloseOnOpenHandler.new}))
- c2.connect("amqp://:#{l.to_io.addr[1]}", { :handler => CloseOnOpenHandler.new} )
+ l = c2.listen_io(TCPServer.new(0), ListenOnceHandler.new({ :handler => CloseOnOpenHandler.new}))
+ c1.connect(l.url, { :handler => CloseOnOpenHandler.new} )
assert threads.each { |t| t.join(1) }
assert_raises(Container::StoppedError) { c1.run }
assert_raises(Container::StoppedError) { c2.connect("") }
@@ -155,7 +142,6 @@ class ContainerTest < Minitest::Test
conn = c.connect("amqp://:#{l.to_io.addr[1]}")
c.stop
assert c.stopped
-
threads.each { |t| assert t.join(1) }
assert_raises(Container::StoppedError) { c.run }
@@ -167,6 +153,7 @@ end
class ContainerSASLTest < Minitest::Test
+ include Qpid::Proton
# Handler for test client/server that sets up server and client SASL options
class SASLHandler < TestHandler
@@ -176,24 +163,25 @@ class ContainerSASLTest < Minitest::Test
@url, @opts = url, opts
end
- def on_start(e)
- @client = e.container.connect("#{@url}:#{e.container.port}", @opts)
+ def on_container_start(container)
+ @client = container.connect("#{@url}:#{container.port}", @opts)
end
attr_reader :auth_user
- def on_connection_opened(e)
+ def on_connection_open(connection)
super
- if e.connection == @client
- e.connection.close
+ if connection == @client
+ connection.close
else
- @auth_user = e.transport.sasl.user
+ @auth_user = connection.transport.sasl.user
end
end
end
# Generate SASL server configuration files and database, initialize proton SASL
class SASLConfig
+ include Qpid::Proton
attr_reader :conf_dir, :conf_file, :conf_name, :database
def initialize()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[22/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fixed
encoding problems, simplified Codec::Data.
Posted by ac...@apache.org.
PROTON-1537: [ruby] Fixed encoding problems, simplified Codec::Data.
Code::Data decodes/encodes all specific AMQP types with methods named type/type=
General encoding of any ruby object with Data#object=, Data#<<
General decoding with Data#object, decodes as ruby object for the 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/c172383d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c172383d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c172383d
Branch: refs/heads/go1
Commit: c172383d4439f0c47a094e403134a7d226b85fa7
Parents: 889c0c6
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Dec 7 14:26:05 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:48 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/codec/data.rb | 465 ++++++---------------
proton-c/bindings/ruby/lib/codec/mapping.rb | 273 ++++++------
proton-c/bindings/ruby/lib/core/container.rb | 2 +-
proton-c/bindings/ruby/lib/core/event.rb | 1 -
proton-c/bindings/ruby/lib/core/exceptions.rb | 3 +-
proton-c/bindings/ruby/lib/core/message.rb | 139 ++----
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
proton-c/bindings/ruby/lib/types/array.rb | 188 +++------
proton-c/bindings/ruby/lib/types/described.rb | 43 +-
proton-c/bindings/ruby/lib/types/hash.rb | 63 +--
proton-c/bindings/ruby/lib/types/type.rb | 68 +++
proton-c/bindings/ruby/lib/util/wrapper.rb | 1 +
proton-c/bindings/ruby/spec/array_spec.rb | 17 +-
proton-c/bindings/ruby/spec/data_spec.rb | 22 +-
proton-c/bindings/ruby/spec/hash_spec.rb | 12 -
proton-c/bindings/ruby/tests/test_data.rb | 66 +++
proton-c/bindings/ruby/tests/test_interop.rb | 76 ++--
17 files changed, 541 insertions(+), 899 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 9814836..86af3a1 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -15,80 +15,40 @@
# specific language governing permissions and limitations
# under the License.
+module Qpid::Proton
+ # @private
+ module Codec
-module Qpid::Proton module Codec
-
- # +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,
- # #enter, and #exit methods to navigate to the desired location in
- # the tree and using the supplied variety of mutator and accessor
- # methods to access or add a value of the desired type.
- #
- # The mutator methods will always add a value _after_ the current node
- # in the tree. If the current node has a next sibling the mutator method
- # will overwrite the value on this node. If there is no current node
- # or the current node has no next sibling then one will be added. The
- # accessor methods always set the added/modified node to the current
- # node. The accessor methods read the value of the current node and do
- # not change which node is current.
- #
- # The following types of scalar values are supported:
- #
- # * NULL
- # * BOOL
- # * UBYTE
- # * BYTE
- # * USHORT
- # * SHORT
- # * UINT
- # * INT
- # * CHAR
- # * ULONG
- # * LONG
- # * TIMESTAMP
- # * FLOAT
- # * DOUBLE
- # * DECIMAL32
- # * DECIMAL64
- # * DECIMAL128
- # * UUID
- # * BINARY
- # * STRING
- # * SYMBOL
- #
- # The following types of compound values are supported:
- #
- # * DESCRIBED
- # * ARRAY
- # * LIST
- # * MAP
- #
+ DataError = ::TypeError
+
+ # @private wrapper for pn_data_t*
+ # Raises TypeError for invalid conversions
class Data
# @private
- PROTON_METHOD_PREFIX = "pn_disposition"
+ PROTON_METHOD_PREFIX = "pn_data"
# @private
include Util::Wrapper
- # Rewind and convert a pn_data_t* containing a single value to a ruby object.
- def self.to_object(impl) Data.new(impl).rewind.object; end
+ # @private
+ # Convert a pn_data_t* containing a single value to a ruby object.
+ # @return [Object, nil] The ruby value extracted from +impl+ or nil if impl is empty
+ def self.to_object(impl)
+ if (Cproton.pn_data_size(impl) > 0)
+ d = Data.new(impl)
+ d.rewind
+ d.next_object
+ end
+ end
- # Clear a pn_data_t* and convert a ruby object into it.
- def self.from_object(impl, x) Data.new(impl).clear.object = x; end
+ # @private
+ # Clear a pn_data_t* and convert a ruby object into it. If x==nil leave it empty.
+ def self.from_object(impl, x)
+ d = Data.new(impl)
+ d.clear
+ d.object = x if x
+ nil
+ end
# @overload initialize(capacity)
# @param capacity [Integer] capacity for the new data instance.
@@ -115,86 +75,20 @@ module Qpid::Proton module Codec
}
end
- # Clears the object.
- #
- def clear
- Cproton.pn_data_clear(@impl)
- self
- end
-
- # Clears the current node and sets the parent to the root node.
- #
- # Clearing the current node sets it *before* the first node, calling
- # #next will advance to the first node.
- #
- # @return self
- def rewind
- Cproton.pn_data_rewind(@impl)
- self
- end
+ proton_caller :clear, :rewind, :next, :prev, :enter, :exit, :type
- # Advances the current node to its next sibling and returns its types.
- #
- # If there is no next sibling the current node remains unchanged
- # and nil is returned.
- #
- def next
- Cproton.pn_data_next(@impl)
+ def enter_exit()
+ enter
+ yield self
+ ensure
+ exit
end
- # Advances the current node to its previous sibling and returns its type.
- #
- # If there is no previous sibling then the current node remains unchanged
- # and nil is return.
- #
- def prev
- return Cproton.pn_data_prev(@impl) ? type : nil
- end
-
- # Sets the parent node to the current node and clears the current node.
- #
- # Clearing the current node sets it _before_ the first child.
- #
- def enter
- Cproton.pn_data_enter(@impl)
- end
-
- # Sets the current node to the parent node and the parent node to its own
- # parent.
- #
- def exit
- Cproton.pn_data_exit(@impl)
- end
-
- # Returns the numeric type code of the current node.
- #
- # @return [Integer] The current node type.
- # @return [nil] If there is no current node.
- #
- def type_code
- dtype = Cproton.pn_data_type(@impl)
- return (dtype == -1) ? nil : dtype
- end
+ def code() Cproton.pn_data_type(@impl); end
- # @return [Integer] The type object for the current node.
- # @see #type_code
- #
- def type
- Mapping.for_code(type_code)
- end
+ def type() Mapping.for_code(Cproton.pn_data_type(@impl)); end
# Returns a representation of the data encoded in AMQP format.
- #
- # @return [String] The context of the Data as an AMQP data string.
- #
- # @example
- #
- # @impl.string = "This is a test."
- # @encoded = @impl.encode
- #
- # # @encoded now contains the text "This is a test." encoded for
- # # AMQP transport.
- #
def encode
buffer = "\0"*1024
loop do
@@ -213,233 +107,101 @@ module Qpid::Proton module Codec
# of bytes consumed.
#
# @param encoded [String] The encoded data.
- #
- # @example
- #
- # # SCENARIO: A string of encoded data, @encoded, contains the text
- # # of "This is a test." and is passed to an instance of Data
- # # for decoding.
- #
- # @impl.decode(@encoded)
- # @impl.string #=> "This is a test."
- #
def decode(encoded)
check(Cproton.pn_data_decode(@impl, encoded, encoded.length))
end
- # Puts a list value.
- #
- # Elements may be filled by entering the list node and putting element
- # values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_list
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- def put_list
- check(Cproton.pn_data_put_list(@impl))
- end
+ proton_is :described, :array_described
+ proton_caller :put_described
+ proton_caller :put_list, :get_list, :put_map, :get_map
+ proton_get :array_type
+ proton_caller :put_array
+ def get_array() [Cproton.pn_data_get_array(@impl), array_described?, array_type]; end
- # If the current node is a list, this returns the number of elements.
- # Otherwise, it returns zero.
- #
- # List elements can be accessed by entering the list.
- #
- # @example
- #
- # count = @impl.list
- # @impl.enter
- # (0...count).each
- # type = @impl.next
- # puts "Value: #{@impl.string}" if type == STRING
- # # ... process other node types
- # end
- def list
- Cproton.pn_data_get_list(@impl)
+ def expect(code)
+ unless code == self.code
+ raise TypeError, "expected #{Cproton.pn_type_name(code)}, got #{Cproton.pn_type_name(code)}"
+ end
end
- # Puts a map value.
- #
- # Elements may be filled by entering the map node and putting alternating
- # key/value pairs.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_map
- # data.enter
- # data.string = "key"
- # data.string = "value"
- # data.exit
- #
- def put_map
- check(Cproton.pn_data_put_map(@impl))
+ def described
+ expect Cproton::PN_DESCRIBED
+ enter_exit { Types::Described.new(self.next_object, self.next_object) }
end
- # If the current node is a map, this returns the number of child
- # elements. Otherwise, it returns zero.
- #
- # Key/value pairs can be accessed by entering the map.
- #
- # @example
- #
- # count = @impl.map
- # @impl.enter
- # (0...count).each do
- # type = @impl.next
- # puts "Key=#{@impl.string}" if type == STRING
- # # ... process other key types
- # type = @impl.next
- # puts "Value=#{@impl.string}" if type == STRING
- # # ... process other value types
- # end
- # @impl.exit
- def map
- Cproton.pn_data_get_map(@impl)
+ def described= d
+ put_described
+ enter_exit { self << d.descriptor << d.value }
end
- # @private
- def get_map
- ::Hash.proton_data_get(self)
+ def fill(a, count, what)
+ a << self.object while self.next
+ raise TypeError, "#{what} expected #{count} elements, got #{a.size}" unless a.size == count
+ a
end
- # Puts an array value.
- #
- # Elements may be filled by entering the array node and putting the
- # element values. The values must all be of the specified array element
- # type.
- #
- # If an array is *described* then the first child value of the array
- # is the descriptor and may be of any type.
- #
- # @param described [Boolean] True if the array is described.
- # @param element_type [Integer] The AMQP type for each element of the array.
- #
- # @example
- #
- # # create an array of integer values
- # data = Qpid::Proton::Codec::Data.new
- # data.put_array(false, INT)
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- # # create a described array of double values
- # data.put_array(true, DOUBLE)
- # data.enter
- # data.symbol = "array-descriptor"
- # data.double = 1.1
- # data.double = 1.2
- # data.double = 1.3
- # data.exit
- #
- def put_array(described, element_type)
- check(Cproton.pn_data_put_array(@impl, described, element_type.code))
+ def list
+ return array if code == Cproton::PN_ARRAY
+ expect Cproton::PN_LIST
+ count = get_list
+ a = []
+ enter_exit { fill(a, count, __method__) }
end
- # If the current node is an array, returns a tuple of the element count, a
- # boolean indicating whether the array is described, and the type of each
- # element. Otherwise it returns +(0, false, nil).
- #
- # Array data can be accessed by entering the array.
- #
- # @example
- #
- # # get the details of thecurrent array
- # count, described, array_type = @impl.array
- #
- # # enter the node
- # data.enter
- #
- # # get the next node
- # data.next
- # puts "Descriptor: #{data.symbol}" if described
- # (0...count).each do
- # @impl.next
- # puts "Element: #{@impl.string}"
- # end
- def array
- count = Cproton.pn_data_get_array(@impl)
- described = Cproton.pn_data_is_array_described(@impl)
- array_type = Cproton.pn_data_get_array_type(@impl)
- return nil if array_type == -1
- [count, described, Mapping.for_code(array_type) ]
+ def list=(a)
+ put_list
+ enter_exit { a.each { |x| self << x } }
end
- # @private
- def get_array
- ::Array.proton_get(self)
+ def array
+ return list if code == Cproton::PN_LIST
+ expect Cproton::PN_ARRAY
+ count, d, t = get_array
+ enter_exit do
+ desc = next_object if d
+ a = Types::UniformArray.new(t, nil, desc)
+ fill(a, count, "array")
+ end
end
- # Puts a described value.
- #
- # A described node has two children, the descriptor and the value.
- # These are specified by entering the node and putting the
- # desired values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_described
- # data.enter
- # data.symbol = "value-descriptor"
- # data.string = "the value"
- # data.exit
- #
- def put_described
- check(Cproton.pn_data_put_described(@impl))
+ def array=(a)
+ t = a.type if a.respond_to? :type
+ d = a.descriptor if a.respond_to? :descriptor
+ if (h = a.instance_variable_get(:@proton_array_header))
+ t ||= h.type
+ d ||= h.descriptor
+ end
+ raise TypeError, "no type when converting #{a.class} to an array" unless t
+ put_array(!d.nil?, t.code)
+ m = Mapping[t]
+ enter_exit do
+ self << d unless d.nil?
+ a.each { |e| m.put(self, e); }
+ end
end
- # @private
- def get_described
- raise TypeError, "not a described type" unless self.described?
- self.enter
- self.next
- type = self.type
- descriptor = type.get(self)
- self.next
- type = self.type
- value = type.get(self)
- self.exit
- Qpid::Proton::Types::Described.new(descriptor, value)
+ def map
+ expect Cproton::PN_MAP
+ count = self.get_map
+ raise TypeError, "invalid map, total of keys and values is odd" if count.odd?
+ enter_exit do
+ m = {}
+ m[object] = next_object while self.next
+ raise TypeError, "map expected #{count/2} entries, got #{m.size}" unless m.size == count/2
+ m
+ end
end
- # Checks if the current node is a described value.
- #
- # The described and value may be accessed by entering the described value.
- #
- # @example
- #
- # if @impl.described?
- # @impl.enter
- # puts "The symbol is #{@impl.symbol}"
- # puts "The value is #{@impl.string}"
- # end
- def described?
- Cproton.pn_data_is_described(@impl)
+ def map= m
+ put_map
+ enter_exit { m.each_pair { |k,v| self << k << v } }
end
- # Puts a null value.
- #
- def null
- check(Cproton.pn_data_put_null(@impl))
- end
+ # Return nil if vallue is null, raise exception otherwise.
+ def null() raise TypeError, "expected null, got #{type || 'empty'}" unless null?; end
- # Utility method for Qpid::Proton::Codec::Mapping
- #
- # @private
- #
- def null=(value)
- null
- end
+ # Set the current value to null
+ def null=(dummy=nil) check(Cproton.pn_data_put_null(@impl)); end
# Puts an arbitrary object type.
#
@@ -450,6 +212,16 @@ module Qpid::Proton module Codec
#
def object=(object)
Mapping.for_class(object.class).put(self, object)
+ object
+ end
+
+ # Add an arbitrary data value using object=, return self
+ def <<(x) self.object=x; self; end
+
+ # Move forward to the next value and return it
+ def next_object
+ self.next or raise TypeError, "not enough data"
+ self.object
end
# Gets the current node, based on how it was encoded.
@@ -457,9 +229,7 @@ module Qpid::Proton module Codec
# @return [Object] The current node.
#
def object
- type = self.type
- return nil if type.nil?
- type.get(data)
+ self.type.get(self) if self.type
end
# Checks if the current node is null.
@@ -862,10 +632,10 @@ module Qpid::Proton module Codec
# If the current node is a symbol, returns its value. Otherwise, it
# returns an empty string ("").
#
- # @return [String] The symbolic string value.
+ # @return [Symbol] The symbol value.
#
def symbol
- Cproton.pn_data_get_symbol(@impl)
+ Cproton.pn_data_get_symbol(@impl).to_sym
end
# Get the current value as a single object.
@@ -901,13 +671,12 @@ module Qpid::Proton module Codec
# @private
def check(err)
if err < 0
- raise DataError, "[#{err}]: #{Cproton.pn_data_error(@impl)}"
+ raise TypeError, "[#{err}]: #{Cproton.pn_data_error(@impl)}"
else
return err
end
end
end
-
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/lib/codec/mapping.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/mapping.rb b/proton-c/bindings/ruby/lib/codec/mapping.rb
index 92d0858..1b8df6e 100644
--- a/proton-c/bindings/ruby/lib/codec/mapping.rb
+++ b/proton-c/bindings/ruby/lib/codec/mapping.rb
@@ -16,165 +16,170 @@
# under the License.
-module Qpid::Proton::Codec
+module Qpid::Proton
+ module Codec
- # Maps between Proton types and their Ruby native language counterparts.
- #
- # @private
- class Mapping
+ # Maps between Proton types and their Ruby native language counterparts.
+ #
+ # @private
+ class Mapping
+
+ attr_reader :code
+ attr_reader :put_method
+ attr_reader :get_method
+
+ @@by_code = {}
+ @@by_class = {}
+
+ # Creates a new mapping.
+ #
+ # ==== Arguments
+ #
+ # * code - the AMQP code for this type
+ # * name - the AMQP name for this type
+ # * klasses - native Ruby classes that are mapped to this AMQP type
+ # * getter - overrides the get method for the type
+ def initialize(code, name, klasses = nil, getter = nil)
+
+ @code = code
+ @name = name
+
+ @@by_code[code] = self
+
+ unless klasses.nil?
+ klasses.each do |klass|
+ raise "entry exists for #{klass}" if @@by_class.keys.include? klass
+ @@by_class[klass] = self unless klass.nil?
+ end
+ end
- attr_reader :code
- attr_reader :put_method
- attr_reader :get_method
+ @put_method = (name + "=").intern
- # Creates a new mapping.
- #
- # ==== Arguments
- #
- # * code - the AMQP code for this type
- # * name - the AMQP name for this type
- # * klasses - native Ruby classes that are mapped to this AMQP type
- # * getter - overrides the get method for the type
- def initialize(code, name, klasses = nil, getter = nil)
-
- @debug = (name == "bool")
-
- @code = code
- @name = name
-
- @@by_preferred ||= {}
- @@by_code ||= {}
- @@by_code["#{code}"] = self
- @@by_name ||= {}
- @@by_name[name] = self
- @@by_class ||= {}
-
- unless klasses.nil?
- klasses.each do |klass|
- raise "entry exists for #{klass}" if @@by_class.keys.include? klass
- @@by_class[klass] = self unless klass.nil?
+ if getter.nil?
+ @get_method = name.intern
+ else
+ @get_method = getter.intern
end
end
- @put_method = (name + "=").intern
+ def to_s; @name; end
- if getter.nil?
- @get_method = name.intern
- else
- @get_method = getter.intern
+ def put(data, value)
+ data.__send__(@put_method, value)
end
- end
- def to_s; @name; end
+ def get(data)
+ data.__send__(@get_method)
+ end
- def put(data, value)
- data.__send__(@put_method, value)
- end
+ def self.for_class(klass)
+ c = klass
+ c = c.superclass while c && (x = @@by_class[c]).nil?
+ raise TypeError, "#{klass} cannot be converted to AMQP" unless x
+ x
+ end
- def get(data)
- data.__send__(@get_method)
- end
+ def self.for_code(code)
+ @@by_code[code]
+ end
- def self.for_class(klass)
- c = klass
- c = c.superclass while c && (x = @@by_class[c]).nil?
- raise DataError, "no mapping for #{klass.inspect}" unless x
- x
- end
+ # Convert x to a Mapping
+ def self.[](x)
+ case x
+ when Mapping then x
+ when Integer then @@by_code[x]
+ when Types::Type then @@by_code[x.code]
+ end
+ end
- def self.for_code(code)
- @@by_code["#{code}"]
end
- end
-
- NULL = Mapping.new(Cproton::PN_NULL, "null", [NilClass], "nil?")
- BOOL = Mapping.new(Cproton::PN_BOOL, "bool", [TrueClass, FalseClass], "bool")
- UBYTE = Mapping.new(Cproton::PN_UBYTE, "ubyte")
- BYTE = Mapping.new(Cproton::PN_BYTE, "byte")
- USHORT = Mapping.new(Cproton::PN_USHORT, "ushort")
- SHORT = Mapping.new(Cproton::PN_SHORT, "short")
- UINT = Mapping.new(Cproton::PN_UINT, "uint")
- INT = Mapping.new(Cproton::PN_INT, "int")
- CHAR = Mapping.new(Cproton::PN_CHAR, "char")
- ULONG = Mapping.new(Cproton::PN_ULONG, "ulong")
- LONG = Mapping.new(Cproton::PN_LONG, "long", [Integer])
- TIMESTAMP = Mapping.new(Cproton::PN_TIMESTAMP, "timestamp", [Date, Time])
- FLOAT = Mapping.new(Cproton::PN_FLOAT, "float")
- DOUBLE = Mapping.new(Cproton::PN_DOUBLE, "double", [Float])
- DECIMAL32 = Mapping.new(Cproton::PN_DECIMAL32, "decimal32")
- DECIMAL64 = Mapping.new(Cproton::PN_DECIMAL64, "decimal64")
- DECIMAL128 = Mapping.new(Cproton::PN_DECIMAL128, "decimal128")
- UUID = Mapping.new(Cproton::PN_UUID, "uuid")
- BINARY = Mapping.new(Cproton::PN_BINARY, "binary")
- STRING = Mapping.new(Cproton::PN_STRING, "string", [::String,
- Qpid::Proton::Types::UTFString,
- Qpid::Proton::Types::BinaryString])
- SYMBOL = Mapping.new(Cproton::PN_SYMBOL, "symbol", [::Symbol])
- DESCRIBED = Mapping.new(Cproton::PN_DESCRIBED, "described", [Qpid::Proton::Types::Described], "get_described")
- ARRAY = Mapping.new(Cproton::PN_ARRAY, "array", nil, "get_array")
- LIST = Mapping.new(Cproton::PN_LIST, "list", [::Array], "get_array")
- MAP = Mapping.new(Cproton::PN_MAP, "map", [::Hash], "get_map")
-
-
- private
-
- class << STRING
- def put(data, value)
- # if we have a symbol then convert it to a string
- value = value.to_s if value.is_a?(Symbol)
-
- isutf = false
-
- if value.is_a?(Qpid::Proton::Types::UTFString)
- isutf = true
- else
- # For Ruby 1.8 we will just treat all strings as binary.
- # For Ruby 1.9+ we can check the encoding first to see what it is
- if RUBY_VERSION >= "1.9"
- # If the string is ASCII-8BIT then treat is as binary. Otherwise,
- # try to convert it to UTF-8 and, if successful, send as that.
- if value.encoding != Encoding::ASCII_8BIT &&
- value.encode(Encoding::UTF_8).valid_encoding?
- isutf = true
+ NULL = Mapping.new(Cproton::PN_NULL, "null", [NilClass])
+ BOOL = Mapping.new(Cproton::PN_BOOL, "bool", [TrueClass, FalseClass])
+ UBYTE = Mapping.new(Cproton::PN_UBYTE, "ubyte")
+ BYTE = Mapping.new(Cproton::PN_BYTE, "byte")
+ USHORT = Mapping.new(Cproton::PN_USHORT, "ushort")
+ SHORT = Mapping.new(Cproton::PN_SHORT, "short")
+ UINT = Mapping.new(Cproton::PN_UINT, "uint")
+ INT = Mapping.new(Cproton::PN_INT, "int")
+ CHAR = Mapping.new(Cproton::PN_CHAR, "char")
+ ULONG = Mapping.new(Cproton::PN_ULONG, "ulong")
+ LONG = Mapping.new(Cproton::PN_LONG, "long", [Integer])
+ TIMESTAMP = Mapping.new(Cproton::PN_TIMESTAMP, "timestamp", [Date, Time])
+ FLOAT = Mapping.new(Cproton::PN_FLOAT, "float")
+ DOUBLE = Mapping.new(Cproton::PN_DOUBLE, "double", [Float])
+ DECIMAL32 = Mapping.new(Cproton::PN_DECIMAL32, "decimal32")
+ DECIMAL64 = Mapping.new(Cproton::PN_DECIMAL64, "decimal64")
+ DECIMAL128 = Mapping.new(Cproton::PN_DECIMAL128, "decimal128")
+ UUID = Mapping.new(Cproton::PN_UUID, "uuid")
+ BINARY = Mapping.new(Cproton::PN_BINARY, "binary")
+ STRING = Mapping.new(Cproton::PN_STRING, "string", [::String,
+ Types::UTFString,
+ Types::BinaryString])
+ SYMBOL = Mapping.new(Cproton::PN_SYMBOL, "symbol", [::Symbol])
+ DESCRIBED = Mapping.new(Cproton::PN_DESCRIBED, "described", [Types::Described])
+ ARRAY = Mapping.new(Cproton::PN_ARRAY, "array", [Types::UniformArray])
+ LIST = Mapping.new(Cproton::PN_LIST, "list", [::Array])
+ MAP = Mapping.new(Cproton::PN_MAP, "map", [::Hash])
+
+ private
+
+ class << STRING
+ def put(data, value)
+ # if we have a symbol then convert it to a string
+ value = value.to_s if value.is_a?(Symbol)
+
+ isutf = false
+
+ if value.is_a?(Types::UTFString)
+ isutf = true
+ else
+ # For Ruby 1.8 we will just treat all strings as binary.
+ # For Ruby 1.9+ we can check the encoding first to see what it is
+ if RUBY_VERSION >= "1.9"
+ # If the string is ASCII-8BIT then treat is as binary. Otherwise,
+ # try to convert it to UTF-8 and, if successful, send as that.
+ if value.encoding != Encoding::ASCII_8BIT &&
+ value.encode(Encoding::UTF_8).valid_encoding?
+ isutf = true
+ end
end
end
- end
- data.string = value if isutf
- data.binary = value if !isutf
+ data.string = value if isutf
+ data.binary = value if !isutf
+ end
end
- end
- class << MAP
- def put(data, map, options = {})
- data.put_map
- data.enter
- map.each_pair do |key, value|
- if options[:keys] == :SYMBOL
- SYMBOL.put(data, key)
- else
- Mapping.for_class(key.class).put(data, key)
- end
+ class << MAP
+ def put(data, map, options = {})
+ data.put_map
+ data.enter
+ map.each_pair do |key, value|
+ if options[:keys] == :SYMBOL
+ SYMBOL.put(data, key)
+ else
+ data.object = key
+ end
- if value.nil?
- data.null
- else
- Mapping.for_class(value.class).put(data, value)
+ if value.nil?
+ data.null
+ else
+ data.object = value
+ end
end
+ data.exit
end
- data.exit
end
- end
- class << DESCRIBED
- def put(data, described)
- data.put_described
- data.enter
- data.object = described.descriptor
- data.object = described.value
- data.exit
+ class << DESCRIBED
+ def put(data, described)
+ data.put_described
+ data.enter
+ data.object = described.descriptor
+ data.object = described.value
+ data.exit
+ end
end
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 91a3d2a..dddde03 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -105,7 +105,7 @@ module Qpid::Proton
def initialize(handler = nil, id = nil)
# Allow ID as sole argument
(handler, id = nil, handler.to_str) if (id.nil? && handler.respond_to?(:to_str))
- # Allow multiple handlers for backwards compatibility
+ # Allow multiple handlers ofor backwards compatibility
a = Array(handler)
@handler = a.size > 1 ? MessagingHandlers.new(a) : handler
@id = ((id && id.to_s) || SecureRandom.uuid).freeze
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index a5aa08e..88fdbaf 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -84,7 +84,6 @@ module Qpid::Proton
when Cproton::CID_pn_session then Session.wrap(Cproton.pn_cast_pn_session(x))
when Cproton::CID_pn_link then Link.wrap(Cproton.pn_cast_pn_link(x))
when Cproton::CID_pn_delivery then Delivery.wrap(Cproton.pn_cast_pn_delivery(x))
- else raise TypeError, "bad class-id #{pn_class_id(Cproton.pn_event_class(impl))}"
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 f88b3c8..34a3e60 100644
--- a/proton-c/bindings/ruby/lib/core/exceptions.rb
+++ b/proton-c/bindings/ruby/lib/core/exceptions.rb
@@ -18,8 +18,8 @@
module Qpid::Proton
+ # @private
module Error
-
NONE = 0
EOS = Cproton::PN_EOS
ERROR = Cproton::PN_ERR
@@ -30,7 +30,6 @@ module Qpid::Proton
TIMEOUT = Cproton::PN_TIMEOUT
INTERRUPTED = Cproton::PN_INTR
INPROGRESS = Cproton::PN_INPROGRESS
-
end
# Represents a generic error at the messaging level.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 8f4f67c..7041d04 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -48,26 +48,10 @@ module Qpid::Proton
# @private
def post_decode
# decode elements from the message
- @properties = {}
- props = Codec::Data.new(Cproton::pn_message_properties(@impl))
- if props.next
- @properties = props.type.get(props)
- end
- @instructions = nil
- insts = Codec::Data.new(Cproton::pn_message_instructions(@impl))
- if insts.next
- @instructions = insts.type.get(insts)
- 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
+ @properties = Codec::Data.to_object(Cproton::pn_message_properties(@impl)) || {}
+ @instructions = Codec:: Data.to_object(Cproton::pn_message_instructions(@impl)) || {}
+ @annotations = Codec::Data.to_object(Cproton::pn_message_annotations(@impl)) || {}
+ @body = Codec::Data.to_object(Cproton::pn_message_body(@impl))
end
# Encodes the message.
@@ -88,27 +72,15 @@ module Qpid::Proton
# @private
def pre_encode
# encode elements from the message
- props = Codec::Data.new(Cproton::pn_message_properties(@impl))
- props.clear
- Codec::Mapping.for_class(@properties.class).put(props, @properties) unless @properties.empty?
- insts = Codec::Data.new(Cproton::pn_message_instructions(@impl))
- insts.clear
- if !@instructions.nil?
- mapping = Codec::Mapping.for_class(@instructions.class)
- mapping.put(insts, @instructions)
- end
- annts = Codec::Data.new(Cproton::pn_message_annotations(@impl))
- annts.clear
- if !@annotations.nil?
- mapping = Codec::Mapping.for_class(@annotations.class)
- mapping.put(annts, @annotations, :keys => :SYMBOL)
- end
- body = Codec::Data.new(Cproton::pn_message_body(@impl))
- body.clear
- if !@body.nil?
- mapping = Codec::Mapping.for_class(@body.class)
- mapping.put(body, @body)
+ Codec::Data.from_object(Cproton::pn_message_properties(@impl), !@properties.empty? && @properties)
+ Codec::Data.from_object(Cproton::pn_message_instructions(@impl), !@instructions.empty? && @instructions)
+ if @annotations # Make sure keys are symbols
+ @annotations.keys.each do |k|
+ @annotations[k.to_sym] = @annotations.delete(k) unless k.is_a? Symbol
+ end
end
+ Codec::Data.from_object(Cproton::pn_message_annotations(@impl), !@annotations.empty? && @annotations)
+ Codec::Data.from_object(Cproton::pn_message_body(@impl), @body)
end
# Creates a new +Message+ instance.
@@ -512,89 +484,32 @@ module Qpid::Proton
Cproton.pn_message_get_reply_to_group_id(@impl)
end
- # Returns the list of property names for associated with this message.
- #
- # ==== Examples
- #
- # msg.properties.each do |name|
- # end
- #
- def properties
- @properties
- end
+ # @return [Hash] Application properties for the message
+ attr_accessor :properties
- # Use +properties+ as the message properties.
- # @param properties [Hash] new properties
- def properties=(properties)
- @properties = properties
- end
+ # Equivalent to +{#properties}[name] = value+
+ def []=(name, value) @properties[name] = value; end
- # Assigns the value given to the named property.
- #
- # ==== Arguments
- #
- # * name - the property name
- # * value - the property value
- #
- def []=(name, value)
- @properties[name] = value
- end
+ # Equivalent to +{#properties}[name]+
+ def [](name) @properties[name]; end
- # Retrieves the value for the specified property name. If not found, then
- # it returns nil.
- #
- def [](name)
- @properties[name]
- end
+ # Equivalent to +{#properties}.delete(name)+
+ def delete_property(name) @properties.delete(name); end
- # Deletes the named property.
- #
- def delete_property(name)
- @properties.delete(name)
- end
-
- # Returns the instructions for this message.
- #
- def instructions
- @instructions
- end
+ # @return [Hash] Delivery instructions for this message.
+ attr_accessor :instructions
- # Assigns instructions to this message.
- #
- def instructions=(instr)
- @instructions = instr
- end
+ # @return [Hash] Delivery annotations for this message.
+ attr_accessor :annotations
- # Returns the annotations for this message.
- #
- def annotations
- @annotations
- end
-
- # Assigns annotations to this message.
- #
- def annotations=(annotations)
- @annotations = annotations
- end
-
- # Returns the body property of the message.
- #
- def body
- @body
- end
-
- # Assigns a new value to the body of the message.
- #
- def body=(body)
- Qpid::Proton::Codec::Mapping.for_class(body.class) unless body.nil? # Fail now if not convertible
- @body = body
- end
+ # @return [Object] body of the message.
+ attr_accessor :body
private
def check(err) # :nodoc:
if err < 0
- raise DataError, "[#{err}]: #{Cproton.pn_message_error(@data)}"
+ raise TypeError, "[#{err}]: #{Cproton.pn_message_error(@data)}"
else
return err
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 a226838..3af6d39 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -51,6 +51,7 @@ require "util/wrapper"
require "util/timeout"
# Types
+require "types/type"
require "types/strings"
require "types/hash"
require "types/array"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 88eb26b..3051f31 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -21,151 +21,83 @@
# to a Qpid::Proton::Data instance.
#++
-module Qpid::Proton::Types
+module Qpid::Proton
+ module Types
+
+ # @deprecated use {UniformArray}
+ class ArrayHeader
+ def initialize(type, descriptor = nil) @type, @descriptor = Codec::Mapping[type], descriptor; end
+ attr_reader :type, :descriptor
+ def described?() !@descriptor.nil?; end
+ def <=>(x) [@type, @descriptor] <=> [x.type, x.descriptor]; end
+ include Comparable
+ 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
+ # *Unsettled API* - An array that is converted to/from an AMQP array of uniform element type.
+ # A plain ruby +::Array+ is converted to/from an AMQP list, which can contain mixed type elements.
+ # If invalid elements are included, then {TypeError} will be raised when encoding to AMQP.
+ class UniformArray < ::Array
+
+ # Construct a uniform array, which will be converted to an AMQP array.
+ # A plain ruby +::Array+ is converted to/from an AMQP list, containing mixed type elements.
+ #
+ # @param type [Type] Elements must be convertible to this AMQP type.
+ # @param elements [Enumerator] Initial elements for the array
+ # @param descriptor [Object] Optional array descriptor
+ def initialize(type, elements=nil, descriptor=nil)
+ @type, @descriptor = type, descriptor
+ raise ArgumentError, "no type specified for array" if @type.nil?
+ super elements if elements
+ @proton_array_header = ArrayHeader.new(@type, @descriptor) # Deprecated
+ end
- def initialize(type, descriptor = nil)
- @type = type
- @descriptor = descriptor
- end
+ # @return [Type] Array elements must be convertible to this AMQP type
+ attr_reader :type
- # Returns true if the array is described.
- def described?
- !@descriptor.nil?
- end
+ # @return [Object] Optional descriptor.
+ def attr_reader() descriptor; end
- def ==(that)
- ((@type == that.type) && (@descriptor == that.descriptor))
+ def inspect() "#{self.class.name}<#{type}>#{super}"; end
end
end
-
end
-# @private
-class Array # :nodoc:
+# {Array} is converted to/from an AMQP list, which is allowed to hold mixed-type elements.
+# Use {UniformArray} to convert/from an AMQP array with uniform element type.
+class ::Array
+ # @deprecated use {UniformArray}
+ def proton_array_header
+ Qpid.deprecated __method__, "UniformArray"
+ @proton_array_header
+ end
- # Used to declare an array as an AMQP array.
- #
- # The value, if defined, is an instance of Qpid::Proton::Types::ArrayHeader
- attr_accessor :proton_array_header
+ # @deprecated use {UniformArray}
+ def proton_array_header=(h)
+ Qpid.deprecated __method__, "UniformArray"
+ @proton_array_header= h
+ end
- # Returns true if the array is the a Proton described type.
- def proton_described?
- !@proton_array_header.nil? && @proton_array_header.described?
+ # @deprecated use {UniformArray}
+ def proton_described?()
+ Qpid.deprecated __method__, "UniformArray"
+ @proton_array_header && @proton_array_header.described?
end
- # Puts the elements of the array into the specified Qpid::Proton::Data object.
+ # @deprecated
def proton_put(data)
- raise TypeError, "data object cannot be nil" if data.nil?
-
- if @proton_array_header.nil?
- proton_put_list(data)
+ Qpid.deprecated __method__, "Codec::Data#array=, Codec::Data#list="
+ raise TypeError, "nil data" unless data
+ if @proton_array_header && @proton_array_header.type
+ data.array = self
else
- proton_put_array(data)
+ data.list = self
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::Codec::Mapping.for_class(element.class)
- # add the element
- mapping.put(data, element)
- end
- # exit the list
- data.exit
+ # @deprecated
+ def self.proton_get(data)
+ Qpid.deprecated __method__, "Codec::Data#list"
+ data.list
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 list out of the specified
- # Qpid::Proton::Data object.
- def proton_get(data)
- raise TypeError, "can't convert nil into Qpid::Proton::Data" if data.nil?
-
- type = data.type
-
- if type == Qpid::Proton::Codec::LIST
- result = proton_get_list(data)
- elsif type == Qpid::Proton::Codec::ARRAY
- result = proton_get_array(data)
- else
- raise TypeError, "element is not a list and not an array"
- end
- end
-
- private
-
- def proton_get_list(data)
- size = data.list
- raise TypeError, "not a list" unless data.enter
- elements = []
- (0...size).each do
- data.next
- type = data.type
- raise TypeError, "missing next element in list" unless type
- elements << type.get(data)
- end
- data.exit
- return elements
- end
-
- def proton_get_array(data)
- count, described, type = data.array
-
- raise TypeError, "not an array" unless data.enter
- elements = []
-
- descriptor = nil
-
- if described
- data.next
- descriptor = data.symbol
- end
-
- elements.proton_array_header = Qpid::Proton::Types::ArrayHeader.new(type, descriptor)
- (0...count).each do |which|
- if data.next
- etype = data.type
- raise TypeError, "missing next element in array" unless etype
- raise TypeError, "invalid array element: #{etype}" unless etype == type
- elements << type.get(data)
- end
- end
- data.exit
- return elements
- end
-
- end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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 fb880ba..41d7ed2 100644
--- a/proton-c/bindings/ruby/lib/types/described.rb
+++ b/proton-c/bindings/ruby/lib/types/described.rb
@@ -17,46 +17,5 @@
module Qpid::Proton::Types
-
- # @private
- class Described
-
- attr_reader :descriptor
- attr_reader :value
-
- def initialize(descriptor, value)
- @descriptor = descriptor
- @value = value
- end
-
- # Puts the description into the Data object.
- #
- # ==== Arguments
- #
- # * data - the Qpid::Proton::Data instance
- #
- # ==== Examples
- #
- # described = Qpid::Proton::Described.new("my-descriptor", "the value")
- # data = Qpid::Proton::Data.new
- # ...
- # described.put(data)
- #
- def put(data)
- data.symbol = @descriptor
- data.string = @value
- end
-
- def ==(that) # :nodoc:
- (that.is_a?(Qpid::Proton::Types::Described) &&
- (self.descriptor == that.descriptor) &&
- (self.value == that.value))
- end
-
- def to_s # :nodoc:
- "descriptor=#{descriptor} value=#{value}"
- end
-
- end
-
+ Described = Struct.new(:descriptor, :value)
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index 9415f86..736bb8f 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -23,64 +23,15 @@
# @private
class Hash # :nodoc:
-
- # Places the contents of the hash into the specified data object.
- #
- # ==== Arguments
- #
- # * data - the Qpid::Proton::Data instance
- #
- # ==== Examples
- #
- # data = Qpid::Proton::Data.new
- # values = {:foo => :bar}
- # values.proton_data_put(data)
- #
+ # @deprecated
def proton_data_put(data)
- raise TypeError, "data object cannot be nil" if data.nil?
-
- data.put_map
- data.enter
-
- each_pair do |key, value|
- type = Qpid::Proton::Codec::Mapping.for_class(key.class)
- type.put(data, key)
- type = Qpid::Proton::Codec::Mapping.for_class(value.class)
- type.put(data, value)
- end
-
- data.exit
+ Qpid.deprecated(__method__, "Codec::Data#map=")
+ data.map = self
end
- class << self
-
- def proton_data_get(data)
- raise TypeError, "data object cannot be nil" if data.nil?
-
- type = data.type
-
- raise TypeError, "element is not a map" unless type == Qpid::Proton::Codec::MAP
-
- count = data.map
- result = {}
-
- data.enter
-
- (0...(count/2)).each do
- data.next
- type = data.type
- key = type.get(data)
- data.next
- type = data.type
- value = type.get(data)
- result[key] = value
- end
-
- data.exit
-
- return result
- end
-
+ # @deprecated
+ def self.proton_data_get(data)
+ Qpid.deprecated(__method__, "Codec::Data#map")
+ data.map
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/lib/types/type.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/type.rb b/proton-c/bindings/ruby/lib/types/type.rb
new file mode 100644
index 0000000..8defa42
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/types/type.rb
@@ -0,0 +1,68 @@
+#--
+# 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 Types
+
+ # Represents an AMQP Type
+ class Type
+ private
+ @@builtin = {}
+ def initialize(code) @code = code; @@builtin[code] = self; end
+
+ public
+ def self.try_convert(code) code.is_a?(Type) ? code : @@builtin[code]; end
+ def self.[](code) try_convert(code) or raise IndexError, "unknown type code #{code}"; end
+
+ attr_reader :code
+ def name() Cproton.pn_type_name(@code); end
+ alias to_s name
+ def <=>(x) @code <=> x; end
+ def hash() @code.hash; end
+ end
+
+ # @!group
+ NULL = Type.new(Cproton::PN_NULL)
+ BOOL = Type.new(Cproton::PN_BOOL)
+ UBYTE = Type.new(Cproton::PN_UBYTE)
+ BYTE = Type.new(Cproton::PN_BYTE)
+ USHORT = Type.new(Cproton::PN_USHORT)
+ SHORT = Type.new(Cproton::PN_SHORT)
+ UINT = Type.new(Cproton::PN_UINT)
+ INT = Type.new(Cproton::PN_INT)
+ CHAR = Type.new(Cproton::PN_CHAR)
+ ULONG = Type.new(Cproton::PN_ULONG)
+ LONG = Type.new(Cproton::PN_LONG)
+ TIMESTAMP = Type.new(Cproton::PN_TIMESTAMP)
+ FLOAT = Type.new(Cproton::PN_FLOAT)
+ DOUBLE = Type.new(Cproton::PN_DOUBLE)
+ DECIMAL32 = Type.new(Cproton::PN_DECIMAL32)
+ DECIMAL64 = Type.new(Cproton::PN_DECIMAL64)
+ DECIMAL128 = Type.new(Cproton::PN_DECIMAL128)
+ UUID = Type.new(Cproton::PN_UUID)
+ BINARY = Type.new(Cproton::PN_BINARY)
+ STRING = Type.new(Cproton::PN_STRING)
+ SYMBOL = Type.new(Cproton::PN_SYMBOL)
+ DESCRIBED = Type.new(Cproton::PN_DESCRIBED)
+ ARRAY = Type.new(Cproton::PN_ARRAY)
+ LIST = Type.new(Cproton::PN_LIST)
+ MAP = Type.new(Cproton::PN_MAP)
+ #@!endgroup
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/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
index 39cd7b4..347a9a5 100644
--- a/proton-c/bindings/ruby/lib/util/wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/wrapper.rb
@@ -113,6 +113,7 @@ module Qpid::Proton
end
RBCTX = self.hash.to_i
end
+
# @private
module Wrapper
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/spec/array_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/array_spec.rb b/proton-c/bindings/ruby/spec/array_spec.rb
index 3bfe559..e760877 100644
--- a/proton-c/bindings/ruby/spec/array_spec.rb
+++ b/proton-c/bindings/ruby/spec/array_spec.rb
@@ -38,20 +38,10 @@ describe "The extended array type" do
expect(value).respond_to? :proton_described?
end
- it "raises an error when putting into a nil Data object" do
- expect { @list.proton_put(nil) }.must_raise(TypeError)
- end
-
it "raises an error when getting from a nil Data object" do
expect {
Array.proton_get(nil)
- }.must_raise(TypeError)
- end
-
- it "raises an error when the data object is empty" do
- expect {
- Array.proton_get(@data)
- }.must_raise(TypeError)
+ }.must_raise
end
it "raises an error when the current object is not a list" do
@@ -92,6 +82,7 @@ describe "The extended array type" do
it "can be put into a Data object as an undescribed array" do
@undescribed.proton_put(@data)
result = Array.proton_get(@data)
+ expect(result).is_a? Qpid::Proton::Types::UniformArray
expect(@undescribed).must_equal(result)
expect(result.proton_array_header).wont_be_nil
expect(result.proton_array_header).must_equal(@undescribed.proton_array_header)
@@ -101,8 +92,8 @@ describe "The extended array type" do
it "can be put into a Data object as a described array" do
@described.proton_put(@data)
result = Array.proton_get(@data)
- expect(@described) == result
-
+ expect(@described).must_equal(result)
+ expect(result).is_a? Qpid::Proton::Types::UniformArray
expect(result.proton_array_header).wont_be_nil
expect(result.proton_array_header).must_equal(@described.proton_array_header)
expect(result.proton_array_header.described?).must_equal(true)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/spec/data_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/data_spec.rb b/proton-c/bindings/ruby/spec/data_spec.rb
index f4041e4..d5c92fb 100644
--- a/proton-c/bindings/ruby/spec/data_spec.rb
+++ b/proton-c/bindings/ruby/spec/data_spec.rb
@@ -34,7 +34,7 @@ module Qpid
end
it "can hold a null" do
- @data.null
+ @data.null = nil
expect(@data.null?).must_equal(true)
end
@@ -385,17 +385,17 @@ module Qpid
it "can hold a null symbol" do
@data.symbol = nil
- expect(@data.symbol).must_equal("")
+ expect(@data.symbol).must_equal(:"")
end
it "can hold a symbol" do
- value = random_string(128)
+ value = random_string(128).to_sym
@data.symbol = value
expect(@data.symbol).must_equal(value)
end
it "can hold a described value" do
- name = random_string(16)
+ name = random_string(16).to_sym
value = random_string(16)
@data.put_described
@data.enter
@@ -411,12 +411,16 @@ module Qpid
expect(@data.string).must_equal(value)
end
- it "raises an error when setting the wrong type in an array"
+ it "raises an error when setting the wrong type in an array" do
+ expect {
+ @data << Qpid::Proton::Types::UniformArray.new(Qpid::Proton::Types::INT, [1, 2.0, :a, "b"])
+ }.must_raise(TypeError)
+ end
it "can hold an array" do
values = []
(1..(rand(100) + 5)).each { values << rand(2**16) }
- @data.put_array false, Qpid::Proton::Codec::INT
+ @data.put_array false, Qpid::Proton::Codec::INT.code
@data.enter
values.each { |value| @data.int = value }
@data.exit
@@ -431,14 +435,14 @@ module Qpid
it "can hold a described array" do
values = []
(1..(rand(100) + 5)).each { values << random_string(64) }
- descriptor = random_string(32)
- @data.put_array true, Qpid::Proton::Codec::STRING
+ descriptor = random_string(32).to_sym
+ @data.put_array true, Qpid::Proton::Codec::STRING.code
@data.enter
@data.symbol = descriptor
values.each { |value| @data.string = value }
@data.exit
- expect(@data.array).must_equal([values.size, true, Qpid::Proton::Codec::STRING])
+ expect(@data.get_array).must_equal([values.size, true, Qpid::Proton::Codec::STRING.code])
@data.enter
@data.next
expect(@data.symbol).must_equal(descriptor)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/spec/hash_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/hash_spec.rb b/proton-c/bindings/ruby/spec/hash_spec.rb
index cd661c2..92acd0a 100644
--- a/proton-c/bindings/ruby/spec/hash_spec.rb
+++ b/proton-c/bindings/ruby/spec/hash_spec.rb
@@ -26,12 +26,6 @@ describe "The extended hash type" do
@hash = random_hash(rand(128) + 64)
end
- it "raises an error when put into a nil Data instance" do
- expect {
- @hash.proton_data_put(nil)
- }.must_raise(TypeError)
- end
-
it "can be put into an instance of Data" do
@hash.proton_data_put(@data)
result = Hash.proton_data_get(@data)
@@ -39,12 +33,6 @@ describe "The extended hash type" do
expect(result.values).must_equal(@hash.values)
end
- it "raises an error when retrieved from a nil Data instance" do
- expect {
- Hash.proton_data_get(nil)
- }.must_raise(TypeError)
- end
-
it "raises an error when trying to get what is not a Hash" do
@data.string = random_string(128)
@data.rewind
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/tests/test_data.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_data.rb b/proton-c/bindings/ruby/tests/test_data.rb
new file mode 100644
index 0000000..b1ae2d9
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_data.rb
@@ -0,0 +1,66 @@
+# 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 'minitest/autorun'
+require "securerandom"
+require 'qpid_proton'
+
+class TestData < Minitest::Test
+ include Qpid::Proton
+
+ def assert_from_to(*values)
+ d = Codec::Data.new
+ values.each do |x|
+ Codec::Data.from_object(d.impl, x)
+ assert_equal x, Codec::Data.to_object(d.impl)
+ end
+ end
+
+ def test_from_to
+ assert_from_to({ 1 => :one, 2=>:two })
+ assert_from_to([{:a => 1, "b" => 2}, 3, 4.4, :five])
+ assert_from_to(Types::UniformArray.new(Types::INT, [1, 2, 3, 4]))
+ end
+
+ def rnum(*arg) SecureRandom.random_number(*arg); end
+ def rstr(*arg) SecureRandom.base64(*arg); end
+
+ def test_nil()
+ assert_nil((Codec::Data.new << nil).object)
+ end
+
+ def assert_convert(*values)
+ values.each { |x| assert_equal x, ((Codec::Data.new << x).object) }
+ end
+
+ def test_bool()
+ assert_convert(true, false)
+ end
+
+ def test_float()
+ assert_convert(0.0, 1.0, -1.0, 1.23e123, rnum(), rnum(), rnum(), rnum())
+ end
+
+ def test_string()
+ assert_convert("", "foo", rstr(100000), rstr(rnum(1000)), rstr(rnum(1000)))
+ end
+
+ def test_symbol()
+ assert_convert(:"", :foo, rstr(256).to_sym)
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c172383d/proton-c/bindings/ruby/tests/test_interop.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_interop.rb b/proton-c/bindings/ruby/tests/test_interop.rb
index e08ada1..0a13a3d 100755
--- a/proton-c/bindings/ruby/tests/test_interop.rb
+++ b/proton-c/bindings/ruby/tests/test_interop.rb
@@ -14,8 +14,8 @@ if ((RUBY_VERSION.split(".").map {|x| x.to_i} <=> [1, 9]) < 0)
end
class InteropTest < MiniTest::Test
- Data = Qpid::Proton::Codec::Data
- Message = Qpid::Proton::Message
+ include Qpid::Proton
+ Data = Codec::Data
def setup
@data = Data.new
@@ -53,87 +53,81 @@ class InteropTest < MiniTest::Test
def assert_next(type, value)
assert @data.next
assert_equal(type, @data.type)
- assert_equal(value, type.get(@data))
+ assert_equal(value, @data.object)
end
- def assert_array_next(expected, header)
- assert_next(Qpid::Proton::Codec::ARRAY, expected)
- result = @data.type.get(@data)
- assert_equal(result.proton_array_header, header)
+ def assert_array_next(expected)
+ result = @data.next_object
+ assert_equal(expected, result)
end
def test_message
decode_message_file("message")
- assert_next(Qpid::Proton::Codec::STRING, "hello")
+ assert_next(Codec::STRING, "hello")
assert !@data.next
end
def test_primitives
decode_data_file("primitives")
- assert_next(Qpid::Proton::Codec::BOOL, true)
- assert_next(Qpid::Proton::Codec::BOOL, false)
- assert_next(Qpid::Proton::Codec::UBYTE, 42)
- assert_next(Qpid::Proton::Codec::USHORT, 42)
- assert_next(Qpid::Proton::Codec::SHORT, -42)
- assert_next(Qpid::Proton::Codec::UINT, 12345)
- assert_next(Qpid::Proton::Codec::INT, -12345)
- assert_next(Qpid::Proton::Codec::ULONG, 12345)
- assert_next(Qpid::Proton::Codec::LONG, -12345)
- assert_next(Qpid::Proton::Codec::FLOAT, 0.125)
- assert_next(Qpid::Proton::Codec::DOUBLE, 0.125)
+ assert_next(Codec::BOOL, true)
+ assert_next(Codec::BOOL, false)
+ assert_next(Codec::UBYTE, 42)
+ assert_next(Codec::USHORT, 42)
+ assert_next(Codec::SHORT, -42)
+ assert_next(Codec::UINT, 12345)
+ assert_next(Codec::INT, -12345)
+ assert_next(Codec::ULONG, 12345)
+ assert_next(Codec::LONG, -12345)
+ assert_next(Codec::FLOAT, 0.125)
+ assert_next(Codec::DOUBLE, 0.125)
assert !@data.next
end
def test_strings
decode_data_file("strings")
- assert_next(Qpid::Proton::Codec::BINARY, "abc\0defg")
- assert_next(Qpid::Proton::Codec::STRING, "abcdefg")
- assert_next(Qpid::Proton::Codec::SYMBOL, "abcdefg")
- assert_next(Qpid::Proton::Codec::BINARY, "")
- assert_next(Qpid::Proton::Codec::STRING, "")
- assert_next(Qpid::Proton::Codec::SYMBOL, "")
+ assert_next(Codec::BINARY, "abc\0defg")
+ assert_next(Codec::STRING, "abcdefg")
+ assert_next(Codec::SYMBOL, :abcdefg)
+ assert_next(Codec::BINARY, "")
+ assert_next(Codec::STRING, "")
+ assert_next(Codec::SYMBOL, :"")
assert !@data.next
end
def test_described
decode_data_file("described")
- assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new("foo-descriptor", "foo-value"))
+ assert_next(Codec::DESCRIBED, Types::Described.new(:"foo-descriptor", "foo-value"))
assert(@data.described?)
- assert_next(Qpid::Proton::Codec::DESCRIBED, Qpid::Proton::Types::Described.new(12, 13))
+ assert_next(Codec::DESCRIBED, Types::Described.new(12, 13))
assert(@data.described?)
assert !@data.next
end
def test_described_array
decode_data_file("described_array")
- assert_array_next((0...10).to_a,
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT,
- "int-array"))
+ assert_array_next(Types::UniformArray.new(Types::INT, (0...10).to_a, :"int-array"))
end
def test_arrays
decode_data_file("arrays")
- assert_array_next((0...100).to_a,
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
- assert_array_next(["a", "b", "c"],
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::STRING))
- assert_array_next([],
- Qpid::Proton::Types::ArrayHeader.new(Qpid::Proton::Codec::INT))
+ assert_array_next(Types::UniformArray.new(Codec::INT, (0...100).to_a))
+ assert_array_next(Types::UniformArray.new(Codec::STRING, ["a", "b", "c"]))
+ assert_array_next(Types::UniformArray.new(Codec::INT))
assert !@data.next
end
def test_lists
decode_data_file("lists")
- assert_next(Qpid::Proton::Codec::LIST, [32, "foo", true])
- assert_next(Qpid::Proton::Codec::LIST, [])
+ assert_next(Codec::LIST, [32, "foo", true])
+ assert_next(Codec::LIST, [])
assert !@data.next
end
def test_maps
decode_data_file("maps")
- assert_next(Qpid::Proton::Codec::MAP, {"one" => 1, "two" => 2, "three" => 3 })
- assert_next(Qpid::Proton::Codec::MAP, {1 => "one", 2 => "two", 3 => "three"})
- assert_next(Qpid::Proton::Codec::MAP, {})
+ assert_next(Codec::MAP, {"one" => 1, "two" => 2, "three" => 3 })
+ assert_next(Codec::MAP, {1 => "one", 2 => "two", 3 => "three"})
+ assert_next(Codec::MAP, {})
assert !@data.next
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[05/50] [abbrv] qpid-proton git commit: PROTON-1537: Rename
Tracker#modified to Tracker#modifications
Posted by ac...@apache.org.
PROTON-1537: Rename Tracker#modified to Tracker#modifications
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8166c297
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8166c297
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8166c297
Branch: refs/heads/go1
Commit: 8166c2977bf5805b9d30ac1caab88203156cf525
Parents: b57acda
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 8 10:34:09 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 8 10:43:15 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/.yardopts | 5 ++-
proton-c/bindings/ruby/CMakeLists.txt | 2 +-
proton-c/bindings/ruby/lib/core/delivery.rb | 48 ++++++++++++------------
proton-c/bindings/ruby/lib/core/tracker.rb | 12 +++---
proton-c/bindings/ruby/lib/core/transfer.rb | 6 +--
5 files changed, 36 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8166c297/proton-c/bindings/ruby/.yardopts
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/.yardopts b/proton-c/bindings/ruby/.yardopts
index bea5abe..00217af 100644
--- a/proton-c/bindings/ruby/.yardopts
+++ b/proton-c/bindings/ruby/.yardopts
@@ -1 +1,4 @@
---no-private lib/**/*.rb
+-r README.rdoc
+--no-private
+--default-return ""
+--hide-void-return
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8166c297/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
index 4df738d..8ff1323 100644
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ b/proton-c/bindings/ruby/CMakeLists.txt
@@ -132,7 +132,7 @@ if (YARD_EXE)
add_custom_command(
OUTPUT ${bin}/doc
WORKING_DIRECTORY ${src}
- COMMAND ${YARD_EXE} -q -o ${bin}/doc -b ${bin}/.yardoc --no-progress --no-private -r README.rdoc
+ COMMAND ${YARD_EXE} -q -o ${bin}/doc -b ${bin}/.yardoc --no-progress --yardopts ${src}/.yardopts
DEPENDS ${RUBY_SRC}
)
add_custom_target(docs-ruby DEPENDS ${bin}/doc)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8166c297/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
index b08c667..b240784 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -24,38 +24,36 @@ module Qpid::Proton
# Accept the receiveed message.
def accept() settle ACCEPTED; end
- # Reject a received message that is considered invalid and should never
- # be delivered again to this or any other receiver.
+ # Reject a message, indicating to the sender that is invalid and should
+ # never be delivered again to this or any other receiver.
def reject() settle REJECTED; end
- # Release a received message. It may be delivered again to this or another
- # receiver.
+ # Release a message, indicating to the sender that it was not processed
+ # but may be delivered again to this or another receiver.
#
- # @option opts [Boolean] :failed (default true) If true
- # {Message#delivery_count} will be increased so future receivers will know
- # there was a failed delivery. If false, {Message#delivery_count} will not
- # be increased.
+ # @param mods [Hash] Instructions to the sender to modify re-delivery.
+ # To allow re-delivery with no modifications at all use +release(nil)+
#
- # @option opts [Boolean] :undeliverable (default false) If true the message
- # will not be re-delivered to this receiver. It may be delivered tbo other
- # receivers.
+ # @option mods [Boolean] :failed Instruct the sender to increase
+ # {Message#delivery_count} so future receivers will know there was a
+ # previous failed delivery.
#
- # @option opts [Hash] :annotations Annotations to be added to
- # {Message#annotations} before re-delivery. Entries with the same key
- # replace existing entries in {Message#annotations}
- def release(opts = nil)
- opts = { :failed => true } if opts == true # Backwards compatibility
- failed = opts ? opts.fetch(:failed, true) : true
- undeliverable = opts && opts[:undeliverable]
- annotations = opts && opts[:annotations]
- if failed || undeliverable || annotations
+ # @option mods [Boolean] :undeliverable Instruct the sender that this
+ # message should never be re-delivered to this receiver, although it may be
+ # delivered other receivers.
+ #
+ # @option mods [Hash] :annotations Instruct the sender to update the
+ # {Message#annotations} with these +key=>value+ pairs before re-delivery.
+ def release(mods = {:failed=>true})
+ mods = { :failed => true } if mods == true # Backwards compatibility
+ if !mods || mods.empty?
+ settle(RELEASED)
+ else
d = Cproton.pn_delivery_local(@impl)
- Cproton.pn_disposition_set_failed(d) if failed
- Cproton.pn_disposition_set_undeliverable(d) if undeliverable
- Data.from_object(Cproton.pn_disposition_annotations(d), annotations) if annotations
+ Cproton.pn_disposition_set_failed(mods[:failed])
+ Cproton.pn_disposition_set_undeliverable(mods[:undeliverable])
+ Data.from_object(Cproton.pn_disposition_annotations(d), mods[:annotations]) if mods.key? :annotations
settle(MODIFIED)
- else
- settle(RELEASED)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8166c297/proton-c/bindings/ruby/lib/core/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/tracker.rb b/proton-c/bindings/ruby/lib/core/tracker.rb
index 7363e3a..79620de 100644
--- a/proton-c/bindings/ruby/lib/core/tracker.rb
+++ b/proton-c/bindings/ruby/lib/core/tracker.rb
@@ -18,17 +18,15 @@
module Qpid::Proton
- # Tracks the status of a sent message.
+ # Track the {Transfer::State} of a sent message.
class Tracker < Transfer
# @return [Sender] The parent {Sender} link.
def sender() link; end
- # If {#state} == {MODIFIED} this method returns additional information
- # about re-delivery from the receiver's call to {Delivery#release}
- #
- # @return [Hash] See {Delivery#release} options for the meaning of hash entries.
- def modified()
- return unless (state == MODIFIED) && (d = Cproton.pn_delivery_remote(@impl))
+ # Re-delivery modifications provided by the receiver in {Delivery#release}
+ # @return [Hash] See the {Delivery#release} +mods+ parameter.
+ def modifications()
+ return {} unless (state == MODIFIED) && (d = Cproton.pn_delivery_remote(@impl))
{
:failed => Cproton.pn_disposition_get_failed(d),
:undeliverable => Cproton.pn_disposition_get_undeliverable(d),
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8166c297/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index db2a03e..7c3a502 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -43,7 +43,7 @@ module Qpid::Proton
public
- # States of a transfer
+ # AMQP Delivery States describing the outcome of a message transfer
module State
# Message was successfully processed by the receiver
ACCEPTED = Cproton::PN_ACCEPTED
@@ -55,8 +55,8 @@ module Qpid::Proton
# acceptable if re-delivered to another receiver
RELEASED = Cproton::PN_RELEASED
- # Like {RELEASED}, but {Tracker#modified} has modifications to be made to
- # the message before re-delivery
+ # Like {RELEASED}, but there are modifications (see {Tracker#modifications})
+ # that must be applied to the message by the {Sender} before re-delivering it.
MODIFIED = Cproton::PN_MODIFIED
# Partial message data received. Only used during link recovery.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[03/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Move
`deprecated` into Qpid module
Posted by ac...@apache.org.
PROTON-1537: [ruby] Move `deprecated` into Qpid module
Minor fixup of doc comments, removed dead code in Qpid module.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/56902090
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/56902090
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/56902090
Branch: refs/heads/go1
Commit: 56902090d59f44abff6c4c15f371244eefa3face
Parents: 56b0949
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 5 14:30:26 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 5 16:54:52 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 4 +--
proton-c/bindings/ruby/lib/core/delivery.rb | 2 +-
proton-c/bindings/ruby/lib/core/disposition.rb | 2 +-
proton-c/bindings/ruby/lib/core/event.rb | 2 +-
proton-c/bindings/ruby/lib/core/link.rb | 2 +-
proton-c/bindings/ruby/lib/core/uri.rb | 3 +-
proton-c/bindings/ruby/lib/core/url.rb | 2 +-
.../bindings/ruby/lib/messenger/messenger.rb | 6 ++--
proton-c/bindings/ruby/lib/qpid_proton.rb | 38 ++++++++------------
proton-c/bindings/ruby/lib/reactor/container.rb | 2 +-
proton-c/bindings/ruby/spec/data_spec.rb | 4 +--
.../ruby/spec/exception_handling_spec.rb | 4 +--
proton-c/bindings/ruby/spec/message_spec.rb | 4 +--
13 files changed, 34 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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 c2f477c..3715080 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -61,10 +61,10 @@ module Qpid::Proton
public
# @deprecated no replacement
- def overrides?() deprecated __method__; false; end
+ def overrides?() Qpid.deprecated __method__; false; end
# @deprecated no replacement
- def session_policy?() deprecated __method__; false; end
+ def session_policy?() Qpid.deprecated __method__; false; end
# @return [Connection] self
def connection() self; end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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
index 838671f..30307f6 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -62,7 +62,7 @@ module Qpid::Proton
# @deprecated use {#release} with modification options
def modify()
- deprecated __method__, "#release"
+ Qpid.deprecated __method__, "#release"
release failed=>true
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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
index 38fab6b..3a24f7a 100644
--- a/proton-c/bindings/ruby/lib/core/disposition.rb
+++ b/proton-c/bindings/ruby/lib/core/disposition.rb
@@ -32,7 +32,7 @@ module Qpid::Proton
# @private
def initialize(impl, local)
- deprecated self.class, Delivery
+ Qpid.deprecated self.class, Delivery
@impl = impl
@local = local
@data = nil
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index e62214b..552a605 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -151,7 +151,7 @@ module Qpid::Proton
end
# @deprecated use {#container}
- def reactor() deprecated __method__, :container; container; end
+ def reactor() Qpid.deprecated __method__, :container; container; end
# @deprecated use {Qpid::Proton::Event}
Event = self
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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
index 370fb61..e525aa9 100644
--- a/proton-c/bindings/ruby/lib/core/link.rb
+++ b/proton-c/bindings/ruby/lib/core/link.rb
@@ -291,7 +291,7 @@ module Qpid::Proton
# @deprecated use {Sender#send}
def delivery(tag)
- deprecated __method__, "Sender#send"
+ Qpid.deprecated __method__, "Sender#send"
Delivery.new(Cproton.pn_delivery(@impl, tag))
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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 636d20f..e9c5add 100644
--- a/proton-c/bindings/ruby/lib/core/uri.rb
+++ b/proton-c/bindings/ruby/lib/core/uri.rb
@@ -19,12 +19,13 @@
require 'uri'
+# Extend the standard ruby {URI} with AMQP and AMQPS schemes
module URI
# AMQP URI scheme for the AMQP protocol
class AMQP < Generic
DEFAULT_PORT = 5672
- # Get the AMQP address: the {#path} minus any leading "/"
+ # @return [String] The AMQP address is the {#path} stripped of 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/56902090/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
index 6bd7ece..88545e3 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -33,7 +33,7 @@ module Qpid::Proton
# Parse a string, return a new URL
# @param url [#to_s] the URL string
def initialize(url = nil)
- deprecated self.class, 'URI or String'
+ Qpid.deprecated self.class, 'URI or String'
if url
@url = Cproton.pn_url_parse(url.to_s)
if @url.nil?
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index aaeee1e..65e0ae8 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -1,4 +1,4 @@
-#
+# --
# 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
@@ -15,7 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#
+# ++
module Qpid::Proton::Messenger
# @deprecated use {Qpid::Proton::Container}
@@ -73,7 +73,7 @@ module Qpid::Proton::Messenger
# * name - the name (def. nil)
#
def initialize(name = nil)
- deprecated 'Qpid::Proton::Messenger', 'Qpid::Proton::Container'
+ Qpid.deprecated 'Qpid::Proton::Messenger', 'Qpid::Proton::Container'
@impl = Cproton.pn_messenger(name)
@selectables = {}
ObjectSpace.define_finalizer(self, self.class.finalize!(@impl))
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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 f92f2df..36c14a1 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -27,10 +27,19 @@ rescue LoadError
require "kconv" # Ruby < 1.9
end
-DEPRECATION = "[DEPRECATION]"
-def deprecated(old, new=nil)
- repl = new ? "use `#{new}`" : "internal use only"
- warn "#{DEPRECATION} `#{old}` is deprecated, #{repl} (called from #{caller(2).first})"
+# Qpid is the top level module for the Qpid project http://qpid.apache.org
+# Definitions for this library are in module {Qpid::Proton}
+module Qpid
+ # @private
+ def self.deprecated(old, new=nil)
+ repl = new ? "use `#{new}`" : "internal use only"
+ warn "[DEPRECATION] `#{old}` is deprecated, #{repl} (called from #{caller(2).first})"
+ end
+
+ # Proton is a ruby API for sending and receiving AMQP messages in clients or servers.
+ # {overveiw}[README.rdoc]
+ module Proton
+ end
end
# Exception classes
@@ -85,35 +94,18 @@ require "messenger/messenger"
# Handler classes
require "handler/adapter"
-
# Core classes that depend on Handler
require "core/messaging_handler"
require "core/container"
require "core/connection_driver"
# Backwards compatibility shims
+
require "reactor/container"
module Qpid::Proton::Handler
- # TODO aconway 2017-12-05: replace with back-compatible handler
+ # @deprecated alias for backwards compatibility
MessagingHandler = Qpid::Proton::MessagingHandler
end
-module Qpid::Proton
- private
- def self.registry
- @registry ||= {}
- end
-
- def self.add_to_registry(key, value)
- self.registry[key] = value
- end
-
- def self.get_from_registry(key)
- self.registry[key]
- end
- def self.delete_from_registry(key)
- self.registry.delete(key)
- end
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/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 41b2a88..9c6b13d 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -29,7 +29,7 @@ module Qpid::Proton::Reactor
# @deprecated use {Qpid::Proton::Container}
def initialize(handlers, opts=nil)
- deprecated self.class, "Qpid::Proton::Container"
+ Qpid.deprecated self.class, "Qpid::Proton::Container"
super handlers || (opts && opts[:global_handler]), opts && opts[:container_id]
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/proton-c/bindings/ruby/spec/data_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/data_spec.rb b/proton-c/bindings/ruby/spec/data_spec.rb
index 99c269c..3123f61 100644
--- a/proton-c/bindings/ruby/spec/data_spec.rb
+++ b/proton-c/bindings/ruby/spec/data_spec.rb
@@ -1,4 +1,4 @@
-#
+# --
# 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
@@ -15,7 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#
+# ++
require "spec_helper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/proton-c/bindings/ruby/spec/exception_handling_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/exception_handling_spec.rb b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
index 129bba4..a78dcd9 100644
--- a/proton-c/bindings/ruby/spec/exception_handling_spec.rb
+++ b/proton-c/bindings/ruby/spec/exception_handling_spec.rb
@@ -1,4 +1,4 @@
-#
+# --
# 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
@@ -15,7 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#
+# ++
require "spec_helper"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/56902090/proton-c/bindings/ruby/spec/message_spec.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/spec/message_spec.rb b/proton-c/bindings/ruby/spec/message_spec.rb
index f36a64b..6486d24 100644
--- a/proton-c/bindings/ruby/spec/message_spec.rb
+++ b/proton-c/bindings/ruby/spec/message_spec.rb
@@ -1,4 +1,4 @@
-#
+# --
# 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
@@ -15,7 +15,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-#
+# ++
require "spec_helper"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[09/50] [abbrv] qpid-proton git commit: PROTON-1549: Document legal
values for the reconnect parameter
Posted by ac...@apache.org.
PROTON-1549: Document legal values for the reconnect parameter
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1eb8a7ba
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1eb8a7ba
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1eb8a7ba
Branch: refs/heads/go1
Commit: 1eb8a7ba4bd58a1d1a73e5c6f2ce56c11409b4df
Parents: e4b5a4f
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 09:41:50 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 09:41:50 2017 -0800
----------------------------------------------------------------------
proton-c/bindings/python/proton/reactor.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1eb8a7ba/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index c210a8f..58045e9 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -698,9 +698,11 @@ class Container(Reactor):
Only one of url or urls should be specified.
- @param reconnect: A value of False will prevent the library
- form automatically trying to reconnect if the underlying
- socket is disconnected before the connection has been closed.
+ @param reconnect: Reconnect is enabled by default. You can
+ pass in an instance of Backoff to control reconnect behavior.
+ A value of False will prevent the library from automatically
+ trying to reconnect if the underlying socket is disconnected
+ before the connection has been closed.
@param heartbeat: A value in milliseconds indicating the
desired frequency of heartbeats used to test the underlying
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[12/50] [abbrv] qpid-proton git commit: PROTON-1651: Fix typos found
by way of spell check (Thanks, Jiri)
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/log.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/log.h b/proton-c/include/proton/log.h
index 35538f7..2f2046b 100644
--- a/proton-c/include/proton/log.h
+++ b/proton-c/include/proton/log.h
@@ -45,7 +45,7 @@ typedef void (*pn_logger_t)(const char *message);
/**
* Enable/disable global logging.
*
- * By default, logging is enabled by envionment variable PN_TRACE_LOG.
+ * By default, logging is enabled by environment variable PN_TRACE_LOG.
* Calling this function overrides the environment setting.
*/
PN_EXTERN void pn_log_enable(bool enabled);
@@ -55,7 +55,7 @@ PN_EXTERN void pn_log_enable(bool enabled);
*
* By default a logger that prints to stderr is installed.
*
- * @param logger is called with each log messsage if logging is enabled.
+ * @param logger is called with each log message if logging is enabled.
* Passing 0 disables logging regardless of pn_log_enable() or environment settings.
*/
PN_EXTERN void pn_log_logger(pn_logger_t logger);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/message.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/message.h b/proton-c/include/proton/message.h
index d379436..f9d62b0 100644
--- a/proton-c/include/proton/message.h
+++ b/proton-c/include/proton/message.h
@@ -280,7 +280,7 @@ PN_EXTERN pn_data_t * pn_message_id (pn_message_t *msg);
* The message id provides a globally unique identifier for a message.
* A message id can be an a string, an unsigned long, a uuid or a
* binary value. This operation returns the value of the id using the
- * ::pn_atom_t descriminated union. See ::pn_atom_t for details on how
+ * ::pn_atom_t discriminated union. See ::pn_atom_t for details on how
* to access the value.
*
* @param[in] msg a message object
@@ -437,7 +437,7 @@ PN_EXTERN pn_data_t * pn_message_correlation_id (pn_message_t *msg);
*
* A correlation id can be an a string, an unsigned long, a uuid or a
* binary value. This operation returns the value of the id using the
- * ::pn_atom_t descriminated union. See ::pn_atom_t for details on how
+ * ::pn_atom_t discriminated union. See ::pn_atom_t for details on how
* to access the value.
*
* @param[in] msg a message object
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/messenger.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/messenger.h b/proton-c/include/proton/messenger.h
index 3caf272..0445865 100644
--- a/proton-c/include/proton/messenger.h
+++ b/proton-c/include/proton/messenger.h
@@ -82,7 +82,7 @@ extern "C" {
* Sending & Receiving Messages
* ============================
*
- * The messenger API works in conjuction with the ::pn_message_t API.
+ * The messenger API works in conjunction with the ::pn_message_t API.
* A ::pn_message_t is a mutable holder of message content.
*
* The ::pn_messenger_put() operation copies content from the supplied
@@ -130,7 +130,7 @@ extern "C" {
* and then return. You can then look at the number of incoming and
* outgoing messages to see how much outstanding work still remains.
*
- * Authentication Mechanims
+ * Authentication Mechanisms
* ========================
*
* The messenger API authenticates using some specific mechanisms. In prior versions
@@ -726,7 +726,7 @@ PNX_EXTERN int pn_messenger_receiving(pn_messenger_t *messenger);
*
* The get operation copies the message data from the head of the
* messenger's incoming queue into the provided ::pn_message_t object.
- * If provided ::pn_message_t pointer is NULL, the head essage will be
+ * If provided ::pn_message_t pointer is NULL, the head message will be
* discarded. This operation will return ::PN_EOS if there are no
* messages left on the incoming queue.
*
@@ -756,7 +756,7 @@ PNX_EXTERN pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger)
* Get the subscription of the message most recently retrieved by ::pn_messenger_get().
*
* This operation will return NULL if ::pn_messenger_get() has never
- * been succesfully called.
+ * been successfully called.
*
* @param[in] messenger a messenger object
* @return a pn_subscription_t or NULL
@@ -1035,7 +1035,7 @@ PNX_EXTERN pn_millis_t
const char *address);
/**
- * Sets the SSL peer authentiacation mode required when a trust
+ * Sets the SSL peer authentication mode required when a trust
* certificate is used.
*
* @param[in] messenger a messenger object
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/reactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/reactor.h b/proton-c/include/proton/reactor.h
index f617b0d..e8a8864 100644
--- a/proton-c/include/proton/reactor.h
+++ b/proton-c/include/proton/reactor.h
@@ -74,7 +74,7 @@ PNX_EXTERN pn_error_t *pn_reactor_error(pn_reactor_t *reactor);
/**
* Create an outgoing connection that will be managed by the reactor.
*
- * The reator's pn_iohandler will create a socket connection to the host
+ * The reactor's pn_iohandler will create a socket connection to the host
* once the connection is opened.
*
* @param[in] reactor the reactor that will own the connection.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/sasl.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/sasl.h b/proton-c/include/proton/sasl.h
index 671ffec..90b08f5 100644
--- a/proton-c/include/proton/sasl.h
+++ b/proton-c/include/proton/sasl.h
@@ -80,7 +80,7 @@ PN_EXTERN pn_sasl_t *pn_sasl(pn_transport_t *transport);
* All implementations of Proton support ANONYMOUS and EXTERNAL on both
* client and server sides and PLAIN on the client side.
*
- * Extended SASL implememtations use an external library (Cyrus SASL)
+ * Extended SASL implementations use an external library (Cyrus SASL)
* to support other mechanisms beyond these basic ones.
*
* @return true if we support extended SASL negotiation, false if we only support basic negotiation.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/selectable.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/selectable.h b/proton-c/include/proton/selectable.h
index 8c0a4db..9bfb867 100644
--- a/proton-c/include/proton/selectable.h
+++ b/proton-c/include/proton/selectable.h
@@ -203,7 +203,7 @@ PNX_EXTERN void pn_selectable_expired(pn_selectable_t *selectable);
* Check if a selectable is registered.
*
* This flag is set via ::pn_selectable_set_registered() and can be
- * used for tracking whether a given selectable has been registerd
+ * used for tracking whether a given selectable has been registered
* with an external event loop.
*
* @param[in] selectable
@@ -255,7 +255,7 @@ PNX_EXTERN void pn_selectable_free(pn_selectable_t *selectable);
* Configure a selectable with a set of callbacks that emit readable,
* writable, and expired events into the supplied collector.
*
- * @param[in] selectable a selectable objet
+ * @param[in] selectable a selectable object
* @param[in] collector a collector object
*/
PNX_EXTERN void pn_selectable_collect(pn_selectable_t *selectable, pn_collector_t *collector);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/terminus.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/terminus.h b/proton-c/include/proton/terminus.h
index c18fb3e..b2344c0 100644
--- a/proton-c/include/proton/terminus.h
+++ b/proton-c/include/proton/terminus.h
@@ -85,7 +85,7 @@ typedef enum {
* Expiry policy of an AMQP terminus.
*
* An orphaned terminus can only exist for the timeout configured by
- * ::pn_terminus_set_timeout. The expiry policy determins when a
+ * ::pn_terminus_set_timeout. The expiry policy determines when a
* terminus is considered orphaned, i.e. when the expiry timer starts
* counting down.
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/transport.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/transport.h b/proton-c/include/proton/transport.h
index a32505f..84494f1 100644
--- a/proton-c/include/proton/transport.h
+++ b/proton-c/include/proton/transport.h
@@ -180,7 +180,7 @@ PN_EXTERN bool pn_transport_is_authenticated(pn_transport_t *transport);
*
* There are several ways within the AMQP protocol suite to get encrypted connections:
* - Use TLS
- * - Use a SASL with a mechanism that supports saecurity layers
+ * - Use a SASL with a mechanism that supports security layers
*
* The default if this option is not set is to allow unencrypted connections.
*
@@ -204,7 +204,7 @@ PN_EXTERN bool pn_transport_is_encrypted(pn_transport_t *transport);
* Get additional information about the condition of the transport.
*
* When a PN_TRANSPORT_ERROR event occurs, this operation can be used
- * to access the details of the error condtion.
+ * to access the details of the error condition.
*
* The pointer returned by this operation is valid until the
* transport object is freed.
@@ -364,7 +364,7 @@ PN_EXTERN uint16_t pn_transport_get_channel_max(pn_transport_t *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
+ * maximum number of simultaneously 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
@@ -474,7 +474,7 @@ PN_EXTERN ssize_t pn_transport_output(pn_transport_t *transport, char *bytes, si
* If the engine is in an exceptional state such as encountering an
* error condition or reaching the end of stream state, a negative
* value will be returned indicating the condition. If an error is
- * indicated, futher details can be obtained from
+ * indicated, further details can be obtained from
* ::pn_transport_error. Calls to ::pn_transport_process may alter the
* value of this pointer. See ::pn_transport_process for details.
*
@@ -487,7 +487,7 @@ PN_EXTERN ssize_t pn_transport_capacity(pn_transport_t *transport);
* Get the transport's tail pointer.
*
* The amount of free space following this pointer is reported by
- * ::pn_transport_capacity. Calls to ::pn_transport_process may alther
+ * ::pn_transport_capacity. Calls to ::pn_transport_process may alter
* the value of this pointer. See ::pn_transport_process for details.
*
* @param[in] transport the transport
@@ -498,10 +498,10 @@ PN_EXTERN char *pn_transport_tail(pn_transport_t *transport);
/**
* Pushes the supplied bytes into the tail of the transport.
*
- * This is equivalent to copying @c size bytes afther the tail pointer
+ * This is equivalent to copying @c size bytes after the tail pointer
* and then calling ::pn_transport_process with an argument of @c
* size. Only some of the bytes will be copied if there is
- * insufficienty capacity available. Use ::pn_transport_capacity to
+ * insufficient capacity available. Use ::pn_transport_capacity to
* determine how much capacity the transport has.
*
* @param[in] transport the transport
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/type_compat.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/type_compat.h b/proton-c/include/proton/type_compat.h
index b6d7760..12a96e6 100644
--- a/proton-c/include/proton/type_compat.h
+++ b/proton-c/include/proton/type_compat.h
@@ -63,7 +63,7 @@
# define PNI_DEFINE_SSIZE_T
#endif
-/* Determinine default action */
+/* Determine default action */
#ifndef _MSC_VER
/* Not Windows and not using Visual Studio */
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/mllib/dom.py
----------------------------------------------------------------------
diff --git a/proton-c/mllib/dom.py b/proton-c/mllib/dom.py
index 9421504..d297cb5 100644
--- a/proton-c/mllib/dom.py
+++ b/proton-c/mllib/dom.py
@@ -65,7 +65,7 @@ class Component:
class DispatchError(Exception):
def __init__(self, scope, f):
- msg = "no such attribtue"
+ msg = "no such attribute"
class Dispatcher:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/core/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c
index 21d62db..48eddd2 100644
--- a/proton-c/src/core/transport.c
+++ b/proton-c/src/core/transport.c
@@ -338,7 +338,7 @@ ssize_t pn_io_layer_input_autodetect(pn_transport_t *transport, unsigned int lay
}
if (transport->encryption_required && !pn_transport_is_encrypted(transport)) {
pn_do_error(transport, "amqp:connection:policy-error",
- "Client connection unencryted - forbidden");
+ "Client connection unencrypted - forbidden");
pn_set_error_layer(transport);
return 8;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/libqpid-proton-proactor.pc.in
----------------------------------------------------------------------
diff --git a/proton-c/src/libqpid-proton-proactor.pc.in b/proton-c/src/libqpid-proton-proactor.pc.in
index 19007a8..c9f7ddb 100644
--- a/proton-c/src/libqpid-proton-proactor.pc.in
+++ b/proton-c/src/libqpid-proton-proactor.pc.in
@@ -23,7 +23,7 @@ libdir=@LIBDIR@
includedir=@INCLUDEDIR@
Name: Proton Proactor
-Description: Qpid Proton C proative IO library
+Description: Qpid Proton C proactive IO library
Version: @PN_VERSION@
URL: http://qpid.apache.org/proton/
Libs: -L${libdir} -lqpid-proton-proactor
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 1fb0c9e..4f3890f 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -397,7 +397,7 @@ struct pn_proactor_t {
bool need_inactive;
bool need_timeout;
bool timeout_set; /* timeout has been set by user and not yet cancelled or generated event */
- bool timeout_processed; /* timout event dispatched in the most recent event batch */
+ bool timeout_processed; /* timeout event dispatched in the most recent event batch */
bool timer_armed; /* timer is armed in epoll */
bool shutting_down;
// wake subsystem
@@ -521,7 +521,7 @@ typedef struct pconnection_t {
bool timer_armed;
bool queued_disconnect; /* deferred from pn_proactor_disconnect() */
pn_condition_t *disconnect_condition;
- ptimer_t timer; // TODO: review one timerfd per connectoin
+ ptimer_t timer; // TODO: review one timerfd per connection
// Following values only changed by (sole) working context:
uint32_t current_arm; // active epoll io events
bool connected;
@@ -951,7 +951,7 @@ static inline bool pconnection_work_pending(pconnection_t *pc) {
static void pconnection_done(pconnection_t *pc) {
bool notify = false;
lock(&pc->context.mutex);
- pc->context.working = false; // So we can wake() ourself if necessary. We remain the defacto
+ pc->context.working = false; // So we can wake() ourself if necessary. We remain the de facto
// working context while the lock is held.
pc->hog_count = 0;
if (pconnection_has_event(pc) || pconnection_work_pending(pc)) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 4819646..750c743 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -39,7 +39,7 @@
#include <uv.h>
-/* All asserts are cheap and should remain in a release build for debugability */
+/* All asserts are cheap and should remain in a release build for debuggability */
#undef NDEBUG
#include <assert.h>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index 0d276e8..ca0c5c4 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -123,7 +123,7 @@ struct iocpdesc_t {
bool read_in_progress;
write_pipeline_t *pipeline;
read_result_t *read_result;
- bool bound; // associted with the completion port
+ bool bound; // associated with the completion port
bool closing; // close called by application
bool read_closed; // EOF or read error
bool write_closed; // shutdown sent or write error
@@ -3256,7 +3256,7 @@ static bool proactor_remove(pcontext_t *ctx) {
if (--ctx->disconnect_ops == 0) {
--p->disconnects_pending;
}
- else // procator_disconnect() still processing
+ else // proactor_disconnect() still processing
can_free = false; // this psocket
}
else {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/reactor/connection.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/connection.c b/proton-c/src/reactor/connection.c
index 4bc8b8d..090947c 100644
--- a/proton-c/src/reactor/connection.c
+++ b/proton-c/src/reactor/connection.c
@@ -189,7 +189,7 @@ void pni_handle_bound(pn_reactor_t *reactor, pn_event_t *event) {
pn_transport_close_head(transport);
} else {
pn_socket_t sock = pn_connect(pni_reactor_io(reactor), host, port);
- // invalid sockets are ignored by poll, so we need to do this manualy
+ // invalid sockets are ignored by poll, so we need to do this manually
if (sock == PN_INVALID_SOCKET) {
pn_condition_t *cond = pn_transport_condition(transport);
pn_condition_set_name(cond, "proton:io");
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index bb95429..f015514 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -367,7 +367,7 @@ void pnx_sasl_set_desired_state(pn_transport_t *transport, enum pnx_sasl_state d
}
}
-// Look for symbol in the mech include list - not particlarly efficient,
+// Look for symbol in the mech include list - not particularly efficient,
// but probably not used enough to matter.
//
// Note that if there is no inclusion list then every mech is implicitly included.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/ssl/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/schannel.c b/proton-c/src/ssl/schannel.c
index 7469095..b541c96 100644
--- a/proton-c/src/ssl/schannel.c
+++ b/proton-c/src/ssl/schannel.c
@@ -1409,7 +1409,7 @@ static bool grow_inbuf2(pn_transport_t *transport, size_t minimum_size) {
if (old_capacity >= max_frame) {
// already big enough
ssl_log(transport, "Application expecting %d bytes (> negotiated maximum frame)\n", new_capacity);
- ssl_failed(transport, "TLS: transport maximimum frame size error");
+ ssl_failed(transport, "TLS: transport maximum frame size error");
return false;
}
}
@@ -1450,7 +1450,7 @@ static void start_ssl_shutdown(pn_transport_t *transport)
desc.pBuffers = &shutBuff;
ApplyControlToken(&ssl->ctxt_handle, &desc);
- // Next handshake will generate the shudown alert token
+ // Next handshake will generate the shutdown alert token
ssl_handshake(transport);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index 3137da0..b0efa55 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -356,7 +356,7 @@ static pn_event_type_t listen_abort_handler(test_handler_t *th, pn_event_t *e) {
}
}
-/* Verify that pn_transport_close_head/tail aborts a connection without an AMQP protoocol close */
+/* Verify that pn_transport_close_head/tail aborts a connection without an AMQP protocol close */
static void test_abort(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_abort_handler) };
pn_proactor_t *client = tps[0].proactor;
@@ -415,7 +415,7 @@ static pn_event_type_t listen_refuse_handler(test_handler_t *th, pn_event_t *e)
}
}
-/* Verify that pn_transport_close_head/tail aborts a connection without an AMQP protoocol close */
+/* Verify that pn_transport_close_head/tail aborts a connection without an AMQP protocol close */
static void test_refuse(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_refuse_handler) };
pn_proactor_t *client = tps[0].proactor;
@@ -846,7 +846,7 @@ static void test_parse_addr(test_t *t) {
TEST_STR_EQUAL(t, "5672", port);
}
-/* Test pn_proactor_addr funtions */
+/* Test pn_proactor_addr functions */
static void test_netaddr(test_t *t) {
test_proactor_t tps[] ={ test_proactor(t, open_wake_handler), test_proactor(t, listen_handler) };
@@ -1003,7 +1003,7 @@ static pn_event_type_t message_stream_handler(test_handler_t *th, pn_event_t *e)
return PN_CONNECTION_WAKE;
}
- case PN_DELIVERY: { /* Receive a delvery - smaller than a chunk? */
+ case PN_DELIVERY: { /* Receive a delivery - smaller than a chunk? */
pn_delivery_t *dlv = pn_event_delivery(e);
if (pn_delivery_readable(dlv)) {
ssize_t n = pn_delivery_pending(dlv);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/tests/refcount.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/refcount.c b/proton-c/src/tests/refcount.c
index 267c861..487f115 100644
--- a/proton-c/src/tests/refcount.c
+++ b/proton-c/src/tests/refcount.c
@@ -234,7 +234,7 @@ static void test_decref_order(int *indexes, void **objects) {
}
for (int j = i+1; j < 4; j++) {
// everything we haven't decreffed yet should have a refcount of
- // 2 unless it has a descendent that has not been decrefed (or
+ // 2 unless it has a descendant that has not been decrefed (or
// it has no child) in which case it should have a refcount of 1
int idx = indexes[j];
void *obj = objects[idx];
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/tests/test_port.h
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/test_port.h b/proton-c/src/tests/test_port.h
index 959e597..b252dd9 100644
--- a/proton-c/src/tests/test_port.h
+++ b/proton-c/src/tests/test_port.h
@@ -20,7 +20,7 @@
* under the License.
*/
-/* Some simple platform-secifics to acquire an unused socket */
+/* Some simple platform-specifics to acquire an unused socket */
#include <stdio.h>
#include <stdlib.h>
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/src/tests/test_tools.h
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/test_tools.h b/proton-c/src/tests/test_tools.h
index f34b790..11354ee 100644
--- a/proton-c/src/tests/test_tools.h
+++ b/proton-c/src/tests/test_tools.h
@@ -47,7 +47,7 @@ typedef struct test_t {
} test_t;
/* Internal, use macros. Print error message and increase the t->errors count.
- All output from test marcros goes to stderr so it interleaves with PN_TRACE logs.
+ All output from test macros goes to stderr so it interleaves with PN_TRACE logs.
*/
void test_vlogf_(test_t *t, const char *prefix, const char* expr,
const char* file, int line, const char *fmt, va_list ap)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/javascript/codec.js
----------------------------------------------------------------------
diff --git a/tests/javascript/codec.js b/tests/javascript/codec.js
index 193c878..5110f4f 100755
--- a/tests/javascript/codec.js
+++ b/tests/javascript/codec.js
@@ -520,7 +520,7 @@ if (typeof process === 'object' && typeof require === 'function') {
assert(data.format() === this.data.format());
- // Deserialise from the copied Data instance into a new JavaScript Object.
+ // Deserialize from the copied Data instance into a new JavaScript Object.
data.rewind();
assert(data.next());
var copy = data.getObject();
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/javascript/message.js
----------------------------------------------------------------------
diff --git a/tests/javascript/message.js b/tests/javascript/message.js
index e714922..8e6ec2e 100755
--- a/tests/javascript/message.js
+++ b/tests/javascript/message.js
@@ -280,7 +280,7 @@ if (typeof process === 'object' && typeof require === 'function') {
};
/**
- * This test tests the transparent serialisation and deserialisation of JavaScript
+ * This test tests the transparent serialization and deserialization of JavaScript
* Objects using the AMQP type system (this is the default behaviour).
*/
CodecTest.testRoundTripBodyObject = function() {
@@ -301,7 +301,7 @@ if (typeof process === 'object' && typeof require === 'function') {
};
/**
- * This test tests the transparent serialisation and deserialisation of JavaScript
+ * This test tests the transparent serialization and deserialization of JavaScript
* Objects as JSON. In this case the "on-the-wire" representation is an AMQP binary
* stored in the AMQP data section.
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/perf/README.txt
----------------------------------------------------------------------
diff --git a/tests/perf/README.txt b/tests/perf/README.txt
index 3805ad1..5f01ae9 100644
--- a/tests/perf/README.txt
+++ b/tests/perf/README.txt
@@ -6,5 +6,5 @@ connection on the loopback interface. The latter is timed. This
provides a crude view of the overhead of the Proton library alone
(CMake target "quick_perf_c") or with a language binding. It is most
useful for verifying a lack of performance degradation on a large
-ckeckin or between releases. It probably says little about expected
+check-in or between releases. It probably says little about expected
performance on a physical network or for a particular application.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/perf/quick_perf.py
----------------------------------------------------------------------
diff --git a/tests/perf/quick_perf.py b/tests/perf/quick_perf.py
index 7af57d2..4371fb4 100644
--- a/tests/perf/quick_perf.py
+++ b/tests/perf/quick_perf.py
@@ -19,7 +19,7 @@
# For use with CMake to run simple performance tests in Proton.
# Assumes that rector-recv and reactor-send can be found in PATH.
-# CMkake's choice of python executable may be passed via PYTHON_EXE environment var.
+# CMake's choice of python executable may be passed via PYTHON_EXE environment var.
# Add any OS specific monitor helpers in PN_QPERF_MON: i.e.
# PN_QPERF_MON="time taskset 0x2" make quick_perf_c
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/codec.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/codec.py b/tests/python/proton_tests/codec.py
index 49a57e0..27e70cf 100644
--- a/tests/python/proton_tests/codec.py
+++ b/tests/python/proton_tests/codec.py
@@ -272,7 +272,7 @@ class DataTest(Test):
def testFloat(self):
# we have to use a special comparison here because python
- # internaly only uses doubles and converting between floats and
+ # internally only uses doubles and converting between floats and
# doubles is imprecise
self._test("float", 0, 1, 2, 3, 0.1, 0.2, 0.3, -1, -2, -3, -0.1, -0.2, -0.3,
eq=lambda x, y: x - y < 0.000001)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 7bb5f78..22b209b 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -35,7 +35,7 @@ if not hasattr(gc, "garbage"):
# future test areas
# + different permutations of setup
# - creating deliveries and calling input/output before opening the session/link
-# + shrinking output_size down to something small? should the enginge buffer?
+# + shrinking output_size down to something small? should the engine buffer?
# + resuming
# - locally and remotely created deliveries with the same tag
@@ -1170,7 +1170,7 @@ class MaxFrameTransferTest(Test):
def testBigMessage(self):
"""
- Test transfering a big message.
+ Test transferring a big message.
"""
self.snd, self.rcv = self.link("test-link")
self.c1 = self.snd.session.connection
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/message.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/message.py b/tests/python/proton_tests/message.py
index 2d6e19e..550520e 100644
--- a/tests/python/proton_tests/message.py
+++ b/tests/python/proton_tests/message.py
@@ -69,7 +69,7 @@ class AccessorsTest(Test):
def testTtl(self):
self._test("ttl", 0, range(12345, 54321))
- def testFirstAquirer(self):
+ def testFirstAcquirer(self):
self._test("first_acquirer", False, (True, False))
def testDeliveryCount(self):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/messenger.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/messenger.py b/tests/python/proton_tests/messenger.py
index 7e08c98..91283ed 100644
--- a/tests/python/proton_tests/messenger.py
+++ b/tests/python/proton_tests/messenger.py
@@ -629,7 +629,7 @@ class MessengerTest(Test):
def testDefaultRewriteSUPHPN(self):
self._testRewrite("amqp://user:pass@original:123/name", "amqp://original:123/name")
- def testRewriteSupress(self):
+ def testRewriteSuppress(self):
self.client.rewrite("*", None)
self._testRewrite("asdf", None)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index c23ef97..e916229 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -27,7 +27,7 @@ from .common import pump, Skipped
from proton._compat import str2bin
def _sslCertpath(file):
- """ Return the full path to the certificate,keyfile, etc.
+ """ Return the full path to the certificate, keyfile, etc.
"""
if os.name=="nt":
if file.find("private-key")!=-1:
@@ -353,7 +353,7 @@ class SASLMechTest(Test):
_testSaslMech(self, 'PLAIN')
# SCRAM not supported before Cyrus SASL 2.1.26
-# so not universal and hance need a test for support
+# so not universal and hence need a test for support
# to keep it in tests.
# def testSCRAMSHA1(self):
# common.ensureCanTestExtendedSASL()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index a8fe837..1cada89 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -571,7 +571,7 @@ class SslTest(common.Test):
self._pump( client, server )
def test_multiple_sessions(self):
- """ Test multiple simultaineous active SSL sessions with bi-directional
+ """ Test multiple simultaneous active SSL sessions with bi-directional
certificate verification, shared across two domains.
"""
self.server_domain.set_credentials(self._testpath("server-certificate.pem"),
@@ -789,7 +789,7 @@ class SslTest(common.Test):
self.tearDown()
# Pass: ensure that the hostname supplied by the connection is used if
- # none has been specified for the SSL instanace
+ # none has been specified for the SSL instance
self.setUp()
self.server_domain.set_credentials(self._testpath("server-certificate.pem"),
self._testpath("server-private-key.pem"),
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tests/tools/apps/c/reactor-recv.c
----------------------------------------------------------------------
diff --git a/tests/tools/apps/c/reactor-recv.c b/tests/tools/apps/c/reactor-recv.c
index bdd1cc2..2a3d434 100644
--- a/tests/tools/apps/c/reactor-recv.c
+++ b/tests/tools/apps/c/reactor-recv.c
@@ -154,7 +154,7 @@ void connection_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t typ
{
pn_link_t *link = pn_event_link(event);
if (pn_link_is_receiver(link)) {
- check(cc->recv_link == NULL, "Multiple incomming links on one connection");
+ check(cc->recv_link == NULL, "Multiple incoming links on one connection");
cc->recv_link = link;
pn_connection_t *conn = pn_event_connection(event);
pn_list_add(cc->global->active_connections, conn);
@@ -337,7 +337,7 @@ void listener_dispatch(pn_handler_t *h, pn_event_t *event, pn_event_type_t type)
break;
case PN_REACTOR_QUIESCED:
{
- // Two quiesce in a row means we have been idle for a timout period
+ // Two quiesce in a row means we have been idle for a timeout period
if (gc->opts->timeout != -1 && gc->quiesce_count > 1)
global_shutdown(gc);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tools/check_abi/README.md
----------------------------------------------------------------------
diff --git a/tools/check_abi/README.md b/tools/check_abi/README.md
index d9865c3..efe9eaf 100644
--- a/tools/check_abi/README.md
+++ b/tools/check_abi/README.md
@@ -1,7 +1,7 @@
This is a tool for looking at the ELF symbols exported by a C/C++ shared library.
Currently it has some rough edges, but it will take a file of expected symbols and
-tell you the difference from what is ewxpected.
+tell you the difference from what is expected.
Currently you also need to compile the C++ programs in the same directory to support the script
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tools/cmake/Modules/WindowsC99SymbolCheck.py
----------------------------------------------------------------------
diff --git a/tools/cmake/Modules/WindowsC99SymbolCheck.py b/tools/cmake/Modules/WindowsC99SymbolCheck.py
index 7c2c9f2..dd1f8f9 100644
--- a/tools/cmake/Modules/WindowsC99SymbolCheck.py
+++ b/tools/cmake/Modules/WindowsC99SymbolCheck.py
@@ -19,7 +19,7 @@
#
# Stop cmake build if pn_i_xxx substitute functions aren't used for
-# the dangererous non-complying [v]snprintf family. A source of
+# the dangerous non-complying [v]snprintf family. A source of
# painful bug-hunting.
#
# Each obj must be checked instead of just the dll since Visual Studio
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/tools/py/proctest.py
----------------------------------------------------------------------
diff --git a/tools/py/proctest.py b/tools/py/proctest.py
index 35eb216..d779573 100644
--- a/tools/py/proctest.py
+++ b/tools/py/proctest.py
@@ -41,7 +41,7 @@ class TestPort(object):
def __init__(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- self.sock.bind(('127.0.0.1', 0)) # Testing exampless is local only
+ self.sock.bind(('127.0.0.1', 0)) # Testing examples is local only
self.host, self.port = socket.getnameinfo(self.sock.getsockname(), 0)
self.addr = "%s:%s" % (self.host, self.port)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[43/50] [abbrv] qpid-proton git commit: PROTON-1669: update versions
for 0.19.0-rc1
Posted by ac...@apache.org.
PROTON-1669: update versions for 0.19.0-rc1
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/01917c71
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/01917c71
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/01917c71
Branch: refs/heads/go1
Commit: 01917c713a00dc50c148fb726229e9aa444bbf0c
Parents: 4d16e61
Author: Robbie Gemmell <ro...@apache.org>
Authored: Tue Dec 19 19:39:43 2017 +0000
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Tue Dec 19 19:57:42 2017 +0000
----------------------------------------------------------------------
proton-c/bindings/python/docs/conf.py | 2 +-
version.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/01917c71/proton-c/bindings/python/docs/conf.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/conf.py b/proton-c/bindings/python/docs/conf.py
index 97d65c9..a4497f5 100644
--- a/proton-c/bindings/python/docs/conf.py
+++ b/proton-c/bindings/python/docs/conf.py
@@ -50,7 +50,7 @@ copyright = u'2015, Apache Qpid'
# The short X.Y version.
version = '0.19.0'
# The full version, including alpha/beta/rc tags.
-release = '0.19.0-SNAPSHOT'
+release = '0.19.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/01917c71/version.txt
----------------------------------------------------------------------
diff --git a/version.txt b/version.txt
index aa2ab03..1cf0537 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.19.0-SNAPSHOT
+0.19.0
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[29/50] [abbrv] qpid-proton git commit: PROTON-1717 [C proactor]
Allow initialization of transport and connection before binding
Posted by ac...@apache.org.
PROTON-1717 [C proactor] Allow initialization of transport and connection before binding
pn_proactor_connect and pn_listener_accept now take a pn_connection_t* and pn_transport_t*
Either can be NULL, in which case a connection/transport is created with no special config.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/4859de40
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4859de40
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4859de40
Branch: refs/heads/go1
Commit: 4859de40b478ae5c401a254b9608a79492f70588
Parents: d6e5360
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Dec 14 17:47:33 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 09:14:50 2017 -0500
----------------------------------------------------------------------
examples/c/broker.c | 2 +-
examples/c/direct.c | 2 +-
examples/c/receive.c | 2 +-
examples/c/send-abort.c | 2 +-
examples/c/send-ssl.c | 2 +-
examples/c/send.c | 2 +-
.../cpp/src/proactor_container_impl.cpp | 4 +-
proton-c/bindings/cpp/src/reconnect_test.cpp | 6 +--
proton-c/include/proton/listener.h | 11 +++--
proton-c/include/proton/proactor.h | 13 +++--
proton-c/src/proactor/epoll.c | 22 +++++----
proton-c/src/proactor/libuv.c | 16 +++----
proton-c/src/proactor/win_iocp.c | 22 +++++----
proton-c/src/tests/proactor.c | 50 ++++++++++----------
14 files changed, 84 insertions(+), 72 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/broker.c
----------------------------------------------------------------------
diff --git a/examples/c/broker.c b/examples/c/broker.c
index ceb9e96..d5a3eef 100644
--- a/examples/c/broker.c
+++ b/examples/c/broker.c
@@ -291,7 +291,7 @@ static void handle(broker_t* b, pn_event_t* e) {
break;
case PN_LISTENER_ACCEPT:
- pn_listener_accept(pn_event_listener(e), pn_connection());
+ pn_listener_accept(pn_event_listener(e), NULL, NULL);
break;
case PN_CONNECTION_INIT:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/direct.c b/examples/c/direct.c
index 104a4a1..cf5db68 100644
--- a/examples/c/direct.c
+++ b/examples/c/direct.c
@@ -234,7 +234,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
break;
case PN_LISTENER_ACCEPT:
- pn_listener_accept(pn_event_listener(event), pn_connection());
+ pn_listener_accept(pn_event_listener(event), NULL, NULL);
break;
case PN_CONNECTION_INIT:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/receive.c
----------------------------------------------------------------------
diff --git a/examples/c/receive.c b/examples/c/receive.c
index e77ef27..8b25115 100644
--- a/examples/c/receive.c
+++ b/examples/c/receive.c
@@ -193,7 +193,7 @@ int main(int argc, char **argv) {
/* Create the proactor and connect */
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, pn_connection(), addr);
+ pn_proactor_connect(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
return exit_code;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/send-abort.c
----------------------------------------------------------------------
diff --git a/examples/c/send-abort.c b/examples/c/send-abort.c
index 2894ebe..240d459 100644
--- a/examples/c/send-abort.c
+++ b/examples/c/send-abort.c
@@ -218,7 +218,7 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, pn_connection(), addr);
+ pn_proactor_connect(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
free(app.message_buffer.start);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/send-ssl.c
----------------------------------------------------------------------
diff --git a/examples/c/send-ssl.c b/examples/c/send-ssl.c
index e307fa4..cc8c6d0 100644
--- a/examples/c/send-ssl.c
+++ b/examples/c/send-ssl.c
@@ -221,7 +221,7 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, pn_connection(), addr);
+ pn_proactor_connect(app.proactor, NULL, NULL, addr);
run(&app);
pn_ssl_domain_free(app.ssl_domain);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/examples/c/send.c
----------------------------------------------------------------------
diff --git a/examples/c/send.c b/examples/c/send.c
index 2f48877..d667828 100644
--- a/examples/c/send.c
+++ b/examples/c/send.c
@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, pn_connection(), addr);
+ pn_proactor_connect(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
free(app.message_buffer.start);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index 491b69b..25efde6 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -209,7 +209,7 @@ pn_connection_t* container::impl::make_connection_lh(
void container::impl::start_connection(const url& url, pn_connection_t *pnc) {
char caddr[PN_MAX_ADDR];
pn_proactor_addr(caddr, sizeof(caddr), url.host().c_str(), url.port().c_str());
- pn_proactor_connect(proactor_, pnc, caddr); // Takes ownership of pnc
+ pn_proactor_connect(proactor_, pnc, NULL, caddr); // Takes ownership of pnc
}
void container::impl::reconnect(pn_connection_t* pnc) {
@@ -531,7 +531,7 @@ bool container::impl::handle(pn_event_t* event) {
cc.listener_context_ = &lc;
cc.handler = opts.handler();
cc.work_queue_ = new container::impl::connection_work_queue(*container_.impl_, c);
- pn_listener_accept(l, c);
+ pn_listener_accept(l, c, NULL);
return false;
}
case PN_LISTENER_CLOSE: {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/bindings/cpp/src/reconnect_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_test.cpp b/proton-c/bindings/cpp/src/reconnect_test.cpp
index b7df213..cc44b77 100644
--- a/proton-c/bindings/cpp/src/reconnect_test.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_test.cpp
@@ -192,10 +192,10 @@ int test_stop_reconnect() {
return 0;
}
-int main(int, char**) {
+int main(int argc, char** argv) {
int failed = 0;
- RUN_TEST(failed, test_failover_simple());
- RUN_TEST(failed, test_stop_reconnect());
+ RUN_ARGV_TEST(failed, test_failover_simple());
+ RUN_ARGV_TEST(failed, test_stop_reconnect());
return failed;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/include/proton/listener.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/listener.h b/proton-c/include/proton/listener.h
index 0994a70..ebe3614 100644
--- a/proton-c/include/proton/listener.h
+++ b/proton-c/include/proton/listener.h
@@ -56,11 +56,16 @@ PNP_EXTERN pn_listener_t *pn_listener(void);
PNP_EXTERN void pn_listener_free(pn_listener_t *l);
/**
- * Bind @p connection to a new transport accepted from @p listener.
- * Errors are returned as @ref PN_TRANSPORT_CLOSED events by pn_proactor_wait().
+ * Accept an incoming connection request on @p transport bound to @p connection.
+ * Call after a @ref PN_LISTENER_ACCEPT event.
*
+ * @param[in] listener the listener
+ * @param[in] connection If NULL a new connection is created.
+ * Memory management is the same as for pn_proactor_connect()
+ * @param[in] transport If NULL a new transport is created.
+ * Memory management is the same as for pn_proactor_connect()
*/
-PNP_EXTERN void pn_listener_accept(pn_listener_t*, pn_connection_t *);
+PNP_EXTERN void pn_listener_accept(pn_listener_t *listener, pn_connection_t *connection, pn_transport_t *transport);
/**
* Get the error condition for a listener.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/include/proton/proactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/proactor.h b/proton-c/include/proton/proactor.h
index 52d3891..1d32668 100644
--- a/proton-c/include/proton/proactor.h
+++ b/proton-c/include/proton/proactor.h
@@ -96,27 +96,30 @@ PNP_EXTERN pn_proactor_t *pn_proactor(void);
PNP_EXTERN void pn_proactor_free(pn_proactor_t *proactor);
/**
- * Bind @p connection to a new @ref transport connected to @p addr.
+ * Connect @p transport to @p addr and bind to @p connection.
* Errors are returned as @ref PN_TRANSPORT_CLOSED events by pn_proactor_wait().
*
* @note Thread-safe
*
* @param[in] proactor the proactor object
*
- * @param[in] connection @p proactor *takes ownership* of @p connection and will
+ * @param[in] connection If NULL a new connection is created.
+ * @p proactor *takes ownership* of @p connection and will
* automatically call pn_connection_free() after the final @ref
* PN_TRANSPORT_CLOSED event is handled, or when pn_proactor_free() is
* called. You can prevent the automatic free with
* pn_proactor_release_connection()
*
+ * @param[in] transport If NULL a new transport is created.
+ * @p proactor *takes ownership* of @p transport, it will be freed even
+ * if pn_proactor_release_connection() is called.
+ *
* @param[in] addr the "host:port" network address, constructed by pn_proactor_addr()
* An empty host will connect to the local host via the default protocol (IPV6 or IPV4).
* An empty port will connect to the standard AMQP port (5672).
*
- * @param[in] connection @ref connection to be connected to @p addr.
- *
*/
-PNP_EXTERN void pn_proactor_connect(pn_proactor_t *proactor, pn_connection_t *connection, const char *addr);
+PNP_EXTERN void pn_proactor_connect(pn_proactor_t *proactor, pn_connection_t *connection, pn_transport_t *transport, const char *addr);
/**
* Start listening for incoming connections.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index 4f3890f..ff515b1 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -760,12 +760,18 @@ static const pn_class_t pconnection_class = PN_CLASS(pconnection);
static void pconnection_tick(pconnection_t *pc);
-static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_connection_t *c, bool server, const char *addr)
+static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, bool server, const char *addr)
{
+ if (pn_connection_driver_init(&pc->driver, c, t) != 0) {
+ free(pc);
+ return "pn_connection_driver_init failure";
+ }
+
lock(&p->bind_mutex);
- pn_record_t *r = pn_connection_attachments(c);
+ pn_record_t *r = pn_connection_attachments(pc->driver.connection);
if (pn_record_get(r, PN_PROACTOR)) {
unlock(&p->bind_mutex);
+ pn_connection_driver_destroy(&pc->driver);
free(pc);
return "pn_connection_t already in use";
}
@@ -774,10 +780,6 @@ static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_con
pc->bound = true;
unlock(&p->bind_mutex);
- if (pn_connection_driver_init(&pc->driver, c, NULL) != 0) {
- free(pc);
- return "pn_connection_driver_init failure";
- }
pcontext_init(&pc->context, PCONNECTION, p, pc);
psocket_init(&pc->psocket, p, NULL, addr);
pc->new_events = 0;
@@ -1292,10 +1294,10 @@ static bool wake_if_inactive(pn_proactor_t *p) {
return false;
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr) {
+void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
- const char *err = pconnection_setup(pc, p, c, false, addr);
+ const char *err = pconnection_setup(pc, p, c, t, false, addr);
if (err) { /* TODO aconway 2017-09-13: errors must be reported as events */
pn_logf("pn_proactor_connect failure: %s", err);
return;
@@ -1695,10 +1697,10 @@ pn_record_t *pn_listener_attachments(pn_listener_t *l) {
return l->attachments;
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) {
+void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
- const char *err = pconnection_setup(pc, pn_listener_proactor(l), c, true, "");
+ const char *err = pconnection_setup(pc, pn_listener_proactor(l), c, t, true, "");
if (err) {
pn_logf("pn_listener_accept failure: %s", err);
return;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 750c743..6f13040 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -176,7 +176,7 @@ typedef struct pconnection_t {
uv_connect_t connect; /* Outgoing connection only */
int connected; /* 0: not connected, <0: connecting after error, 1 = connected ok */
- lsocket_t *lsocket; /* Incoming connection only */
+ lsocket_t *lsocket; /* Incoming connection only */
struct pn_netaddr_t local, remote; /* Actual addresses */
uv_timer_t timer;
@@ -297,9 +297,9 @@ static void parse_addr(addr_t *addr, const char *str) {
pni_parse_addr(str, addr->addr_buf, sizeof(addr->addr_buf), &addr->host, &addr->port);
}
-static pconnection_t *pconnection(pn_proactor_t *p, pn_connection_t *c, bool server) {
+static pconnection_t *pconnection(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, bool server) {
pconnection_t *pc = (pconnection_t*)calloc(1, sizeof(*pc));
- if (!pc || pn_connection_driver_init(&pc->driver, c, NULL) != 0) {
+ if (!pc || pn_connection_driver_init(&pc->driver, c, t) != 0) {
return NULL;
}
work_init(&pc->work, p, T_CONNECTION);
@@ -865,7 +865,7 @@ static bool leader_process_pconnection(pconnection_t *pc) {
uv_mutex_lock(&pc->lock);
pc->wake = W_CLOSED; /* wake() is a no-op from now on */
uv_mutex_unlock(&pc->lock);
- uv_safe_close((uv_handle_t*)&pc->tcp, on_close_pconnection);
+ uv_safe_close((uv_handle_t*)&pc->tcp, on_close_pconnection);
} else {
/* Check for events that can be generated without blocking for IO */
check_wake(pc);
@@ -1115,8 +1115,8 @@ void pn_proactor_cancel_timeout(pn_proactor_t *p) {
uv_mutex_unlock(&p->lock);
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr) {
- pconnection_t *pc = pconnection(p, c, false);
+void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
+ pconnection_t *pc = pconnection(p, c, t, false);
assert(pc); /* TODO aconway 2017-03-31: memory safety */
pn_connection_open(pc->driver.connection); /* Auto-open */
parse_addr(&pc->addr, addr);
@@ -1270,9 +1270,9 @@ pn_record_t *pn_listener_attachments(pn_listener_t *l) {
return l->attachments;
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) {
+void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
uv_mutex_lock(&l->lock);
- pconnection_t *pc = pconnection(l->work.proactor, c, true);
+ pconnection_t *pc = pconnection(l->work.proactor, c, t, true);
assert(pc);
/* Get the socket from the accept event that we are processing */
pn_event_t *e = pn_collector_prev(l->collector);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index ca0c5c4..679b045 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -2078,11 +2078,17 @@ static void pconnection_finalize(void *vp_pconnection) {
static const pn_class_t pconnection_class = PN_CLASS(pconnection);
-static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_connection_t *c, bool server, const char *addr) {
+static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, bool server, const char *addr)
+{
+ if (pn_connection_driver_init(&pc->driver, c, t) != 0) {
+ free(pc);
+ return "pn_connection_driver_init failure";
+ }
{
csguard g(&p->bind_lock);
- pn_record_t *r = pn_connection_attachments(c);
+ pn_record_t *r = pn_connection_attachments(pc->driver.connection);
if (pn_record_get(r, PN_PROACTOR)) {
+ pn_connection_driver_destroy(&pc->driver);
free(pc);
return "pn_connection_t already in use";
}
@@ -2092,10 +2098,6 @@ static const char *pconnection_setup(pconnection_t *pc, pn_proactor_t *p, pn_con
pc->can_wake = true;
}
- if (pn_connection_driver_init(&pc->driver, c, NULL) != 0) {
- free(pc);
- return "pn_connection_driver_init failure";
- }
pc->completion_queue = new std::queue<iocp_result_t *>();
pc->work_queue = new std::queue<iocp_result_t *>();
pcontext_init(&pc->context, PCONNECTION, p, pc);
@@ -2713,10 +2715,10 @@ static void connect_step_done(pconnection_t *pc, connect_result_t *result) {
}
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr) {
+void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
- const char *err = pconnection_setup(pc, p, c, false, addr);
+ const char *err = pconnection_setup(pc, p, c, t, false, addr);
if (err) {
pn_logf("pn_proactor_connect failure: %s", err);
return;
@@ -3154,7 +3156,7 @@ static void recycle_result(accept_result_t *accept_result) {
}
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) {
+void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
accept_result_t *accept_result = NULL;
DWORD err = 0;
psocket_t *ps = NULL;
@@ -3164,7 +3166,7 @@ void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) {
csguard g(&l->context.cslock);
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
- const char *err_str = pconnection_setup(pc, p, c, true, "");
+ const char *err_str = pconnection_setup(pc, p, c, t, true, "");
if (err_str) {
pn_logf("pn_listener_accept failure: %s", err_str);
return;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4859de40/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index b0efa55..332a73a 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -207,7 +207,7 @@ static pn_event_type_t common_handler(test_handler_t *th, pn_event_t *e) {
case PN_LISTENER_ACCEPT:
last_accepted = pn_connection();
- pn_listener_accept(l, last_accepted);
+ pn_listener_accept(l, last_accepted, NULL);
pn_listener_close(l); /* Only accept one connection */
return PN_EVENT_NONE;
@@ -257,7 +257,7 @@ static pn_event_type_t listen_handler(test_handler_t *th, pn_event_t *e) {
case PN_LISTENER_ACCEPT:
/* No automatic listener close/free for tests that accept multiple connections */
last_accepted = pn_connection();
- pn_listener_accept(pn_event_listener(e), last_accepted);
+ pn_listener_accept(pn_event_listener(e), last_accepted, NULL);
/* No automatic close */
return PN_EVENT_NONE;
@@ -285,7 +285,7 @@ static void test_client_server(test_t *t) {
test_proactor_t tps[] ={ test_proactor(t, open_close_handler), test_proactor(t, common_handler) };
test_listener_t l = test_listen(&tps[1], localhost);
/* Connect and wait for close at both ends */
- pn_proactor_connect(tps[0].proactor, pn_connection(), l.port.host_port);
+ pn_proactor_connect(tps[0].proactor, NULL, NULL, l.port.host_port);
TEST_PROACTORS_RUN_UNTIL(tps, PN_TRANSPORT_CLOSED);
TEST_PROACTORS_RUN_UNTIL(tps, PN_TRANSPORT_CLOSED);
TEST_PROACTORS_DESTROY(tps);
@@ -312,7 +312,7 @@ static void test_connection_wake(test_t *t) {
pn_connection_t *c = pn_connection();
pn_incref(c); /* Keep a reference for wake() after free */
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_CHECK(t, pn_proactor_get(client) == NULL); /* Should be idle */
pn_connection_wake(c);
@@ -325,7 +325,7 @@ static void test_connection_wake(test_t *t) {
/* Verify we don't get a wake after close even if they happen together */
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, l.port.host_port);
+ pn_proactor_connect(client, c2, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c2);
pn_proactor_disconnect(client, NULL);
@@ -361,7 +361,7 @@ static void test_abort(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_abort_handler) };
pn_proactor_t *client = tps[0].proactor;
test_listener_t l = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, pn_connection(), l.port.host_port);
+ pn_proactor_connect(client, NULL, NULL, l.port.host_port);
/* server transport closes */
if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps))) {
@@ -420,7 +420,7 @@ static void test_refuse(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_refuse_handler) };
pn_proactor_t *client = tps[0].proactor;
test_listener_t l = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, pn_connection(), l.port.host_port);
+ pn_proactor_connect(client, NULL, NULL, l.port.host_port);
/* client transport closes */
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps)); /* client */
@@ -458,7 +458,7 @@ static void test_inactive(test_t *t) {
/* Listen, connect, disconnect */
test_listener_t l = test_listen(&tps[1], localhost);
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_WAKE, TEST_PROACTORS_RUN(tps));
@@ -475,7 +475,7 @@ static void test_inactive(test_t *t) {
/* Connect, set-timer, disconnect */
pn_proactor_set_timeout(client, 1000000);
c = pn_connection();
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_WAKE, TEST_PROACTORS_RUN(tps));
@@ -503,7 +503,7 @@ static void test_errors(test_t *t) {
/* Invalid connect/listen service name */
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, "127.0.0.1:xxx");
+ pn_proactor_connect(client, c, NULL, "127.0.0.1:xxx");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, "xxx", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -516,7 +516,7 @@ static void test_errors(test_t *t) {
/* Invalid connect/listen host name */
c = pn_connection();
- pn_proactor_connect(client, c, "nosuch.example.com:");
+ pn_proactor_connect(client, c, NULL, "nosuch.example.com:");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, "nosuch", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -544,7 +544,7 @@ static void test_errors(test_t *t) {
/* Connect with no listener */
c = pn_connection();
- pn_proactor_connect(client, c, port.host_port);
+ pn_proactor_connect(client, c, NULL, port.host_port);
if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps))) {
TEST_COND_DESC(t, "refused", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -573,7 +573,7 @@ static pn_event_type_t transport_close_connection_handler(test_handler_t *th, pn
*/
static void test_proton_1586(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, transport_close_connection_handler) };
- pn_proactor_connect(tps[0].proactor, pn_connection(), ":yyy");
+ pn_proactor_connect(tps[0].proactor, NULL, NULL, ":yyy");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, ":yyy", last_condition);
test_handler_clear(&tps[0].handler, 0); /* Clear events */
@@ -598,7 +598,7 @@ static void test_ipv4_ipv6(test_t *t) {
TEST_PROACTORS_DRAIN(tps);
#define EXPECT_CONNECT(TP, HOST) do { \
- pn_proactor_connect(client, pn_connection(), test_port_use_host(&(TP), (HOST))); \
+ pn_proactor_connect(client, NULL, NULL, test_port_use_host(&(TP), (HOST))); \
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps)); \
TEST_COND_EMPTY(t, last_condition); \
TEST_PROACTORS_DRAIN(tps); \
@@ -645,12 +645,12 @@ static void test_release_free(test_t *t) {
test_listener_t l = test_listen(&tps[1], localhost);
/* leave one connection to the proactor */
- pn_proactor_connect(client, pn_connection(), l.port.host_port);
+ pn_proactor_connect(client, NULL, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
/* release c1 and free immediately */
pn_connection_t *c1 = pn_connection();
- pn_proactor_connect(client, c1, l.port.host_port);
+ pn_proactor_connect(client, c1, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_release_connection(c1); /* We free but socket should still be cleaned up */
pn_connection_free(c1);
@@ -659,7 +659,7 @@ static void test_release_free(test_t *t) {
/* release c2 and but don't free till after proactor free */
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, l.port.host_port);
+ pn_proactor_connect(client, c2, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_release_connection(c2);
TEST_CHECK(t, pn_proactor_get(client) == NULL); /* Should be idle */
@@ -750,7 +750,7 @@ static void test_ssl(test_t *t) {
test_listener_t l = test_listen(server, localhost);
/* Basic SSL connection */
- pn_proactor_connect(client->proactor, pn_connection(), l.port.host_port);
+ pn_proactor_connect(client->proactor, NULL, NULL, l.port.host_port);
/* Open ok at both ends */
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_COND_EMPTY(t, last_condition);
@@ -764,7 +764,7 @@ static void test_ssl(test_t *t) {
TEST_INT_EQUAL(t, 0, pn_ssl_domain_set_peer_authentication(cd, PN_SSL_VERIFY_PEER_NAME, NULL));
pn_connection_t *c = pn_connection();
pn_connection_set_hostname(c, "test_server");
- pn_proactor_connect(client->proactor, c, l.port.host_port);
+ pn_proactor_connect(client->proactor, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_COND_EMPTY(t, last_condition);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
@@ -775,7 +775,7 @@ static void test_ssl(test_t *t) {
/* Verify peer with bad hostname */
c = pn_connection();
pn_connection_set_hostname(c, "wrongname");
- pn_proactor_connect(client->proactor, c, l.port.host_port);
+ pn_proactor_connect(client->proactor, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_NAME(t, "amqp:connection:framing-error", last_condition);
TEST_COND_DESC(t, "SSL", last_condition);
@@ -854,7 +854,7 @@ static void test_netaddr(test_t *t) {
/* Use IPv4 to get consistent results all platforms */
test_listener_t l = test_listen(&tps[1], "127.0.0.1");
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
if (!TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps))) {
TEST_COND_EMPTY(t, last_condition); /* Show the last condition */
return; /* don't continue if connection is closed */
@@ -910,10 +910,10 @@ static void test_disconnect(test_t *t) {
/* Only wait for one connection to remote-open before disconnect */
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, l2.port.host_port);
+ pn_proactor_connect(client, c2, NULL, l2.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_PROACTORS_DRAIN(tps);
@@ -945,7 +945,7 @@ static void test_disconnect(test_t *t) {
/* Make sure the proactors are still functional */
test_listener_t l3 = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, pn_connection(), l3.port.host_port);
+ pn_proactor_connect(client, NULL, NULL, l3.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_disconnect(client, NULL);
@@ -1042,7 +1042,7 @@ static void test_message_stream(test_t *t) {
pn_message_free(m);
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, l.port.host_port);
+ pn_proactor_connect(client, c, NULL, l.port.host_port);
pn_session_t *ssn = pn_session(c);
pn_session_open(ssn);
pn_link_t *snd = pn_sender(ssn, "x");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[48/50] [abbrv] qpid-proton git commit: Merge tag '0.19.0' into go1
Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/proton/engine.go
----------------------------------------------------------------------
diff --cc proton/engine.go
index c0f0093,0000000..d28a09f
mode 100644,000000..100644
--- a/proton/engine.go
+++ b/proton/engine.go
@@@ -1,422 -1,0 +1,422 @@@
+/*
+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.
+*/
+
+package proton
+
+import (
+ "fmt"
+ "net"
+ "os"
+ "strings"
+ "sync"
+ "time"
+ "unsafe"
+)
+
+/*
+#include <proton/connection.h>
+#include <proton/event.h>
+#include <proton/error.h>
+#include <proton/handlers.h>
+#include <proton/session.h>
+#include <proton/transport.h>
+#include <memory.h>
+#include <stdlib.h>
+*/
+import "C"
+
+// Injecter allows functions to be "injected" into the event-processing loop, to
+// be called in the same goroutine as event handlers.
+type Injecter interface {
+ // Inject a function into the engine goroutine.
+ //
+ // f() will be called in the same goroutine as event handlers, so it can safely
+ // use values belonging to event handlers without synchronization. f() should
+ // not block, no further events or injected functions can be processed until
+ // f() returns.
+ //
+ // Returns a non-nil error if the function could not be injected and will
+ // never be called. Otherwise the function will eventually be called.
+ //
+ // Note that proton values (Link, Session, Connection etc.) that existed when
+ // Inject(f) was called may have become invalid by the time f() is executed.
+ // Handlers should handle keep track of Closed events to ensure proton values
+ // are not used after they become invalid. One technique is to have map from
+ // proton values to application values. Check that the map has the correct
+ // proton/application value pair at the start of the injected function and
+ // delete the value from the map when handling a Closed event.
+ Inject(f func()) error
+
+ // InjectWait is like Inject but does not return till f() has completed.
+ // If f() cannot be injected it returns the error from Inject(), otherwise
+ // it returns the error from f()
+ InjectWait(f func() error) error
+}
+
+// Engine reads from a net.Conn, decodes AMQP events and calls the appropriate
+// Handler functions sequentially in a single goroutine. Actions taken by
+// Handler functions (such as sending messages) are encoded and written to the
+// net.Conn. You can create multiple Engines to handle multiple connections
+// concurrently.
+//
+// You implement the EventHandler and/or MessagingHandler interfaces and provide
+// those values to NewEngine(). Their HandleEvent method will be called in the
+// event-handling goroutine.
+//
+// Handlers can pass values from an event (Connections, Links, Deliveries etc.) to
+// other goroutines, store them, or use them as map indexes. Effectively they are
+// just pointers. Other goroutines cannot call their methods directly but they can
+// can create a function closure to call such methods and pass it to Engine.Inject()
+// to have it evaluated in the engine goroutine.
+//
+// You are responsible for ensuring you don't use an event value after it is
+// invalid. The handler methods will tell you when a value is no longer valid. For
+// example after a LinkClosed event, that link is no longer valid. If you do
+// Link.Close() yourself (in a handler or injected function) the link remains valid
- // until the corresponing LinkClosed event is received by the handler.
++// until the corresponding LinkClosed event is received by the handler.
+//
+// Engine.Close() will take care of cleaning up any remaining values when you are
+// done with the Engine. All values associated with a engine become invalid when you
+// call Engine.Close()
+//
+// The qpid.apache.org/proton/concurrent package will do all this for you, so it
+// may be a better choice for some applications.
+//
+type Engine struct {
+ // Error is set on exit from Run() if there was an error.
+ err ErrorHolder
+ inject chan func()
+
+ conn net.Conn
+ connection Connection
+ transport Transport
+ collector *C.pn_collector_t
+ handlers []EventHandler // Handlers for proton events.
+ running chan struct{} // This channel will be closed when the goroutines are done.
+ closeOnce sync.Once
+ timer *time.Timer
+ traceEvent bool
+}
+
+const bufferSize = 4096
+
+func envBool(name string) bool {
+ v := strings.ToLower(os.Getenv(name))
+ return v == "true" || v == "1" || v == "yes" || v == "on"
+}
+
+// Create a new Engine and call Initialize() with conn and handlers
+func NewEngine(conn net.Conn, handlers ...EventHandler) (*Engine, error) {
+ eng := &Engine{}
+ return eng, eng.Initialize(conn, handlers...)
+}
+
+// Initialize an Engine with a connection and handlers. Start it with Run()
+func (eng *Engine) Initialize(conn net.Conn, handlers ...EventHandler) error {
+ eng.inject = make(chan func())
+ eng.conn = conn
+ eng.connection = Connection{C.pn_connection()}
+ eng.transport = Transport{C.pn_transport()}
+ eng.collector = C.pn_collector()
+ eng.handlers = handlers
+ eng.running = make(chan struct{})
+ eng.timer = time.NewTimer(0)
+ eng.traceEvent = envBool("PN_TRACE_EVT")
+ if eng.transport.IsNil() || eng.connection.IsNil() || eng.collector == nil {
+ eng.free()
+ return fmt.Errorf("proton.NewEngine cannot allocate")
+ }
+ C.pn_connection_collect(eng.connection.pn, eng.collector)
+ return nil
+}
+
+// Create a byte slice backed by C memory.
+// Empty or error (size <= 0) returns a nil byte slice.
+func cByteSlice(start unsafe.Pointer, size int) []byte {
+ if start == nil || size <= 0 {
+ return nil
+ } else {
+ // Slice from very large imaginary array in C memory
+ return (*[1 << 30]byte)(start)[:size:size]
+ }
+}
+
+func (eng *Engine) Connection() Connection {
+ return eng.connection
+}
+
+func (eng *Engine) Transport() Transport {
+ return eng.transport
+}
+
+func (eng *Engine) String() string {
+ return fmt.Sprintf("[%s]%s-%s", eng.Id(), eng.conn.LocalAddr(), eng.conn.RemoteAddr())
+}
+
+func (eng *Engine) Id() string {
+ // Use transport address to match default PN_TRACE_FRM=1 output.
+ return fmt.Sprintf("%p", eng.Transport().CPtr())
+}
+
+func (eng *Engine) Error() error {
+ return eng.err.Get()
+}
+
+// Inject a function into the Engine's event loop.
+//
+// f() will be called in the same event-processing goroutine that calls Handler
+// methods. f() can safely call methods on values that belong to this engine
+// (Sessions, Links etc)
+//
+// The injected function has no parameters or return values. It is normally a
+// closure and can use channels to communicate with the injecting goroutine if
+// necessary.
+//
+// Returns a non-nil error if the engine is closed before the function could be
+// injected.
+func (eng *Engine) Inject(f func()) error {
+ select {
+ case eng.inject <- f:
+ return nil
+ case <-eng.running:
+ return eng.Error()
+ }
+}
+
+// InjectWait is like Inject but does not return till f() has completed or the
+// engine is closed, and returns an error value from f()
+func (eng *Engine) InjectWait(f func() error) error {
+ done := make(chan error)
+ defer close(done)
+ err := eng.Inject(func() { done <- f() })
+ if err != nil {
+ return err
+ }
+ select {
+ case <-eng.running:
+ return eng.Error()
+ case err := <-done:
+ return err
+ }
+}
+
+// Server puts the Engine in server mode, meaning it will auto-detect security settings on
- // the incoming connnection such as use of SASL and SSL.
++// the incoming connection such as use of SASL and SSL.
+// Must be called before Run()
+//
+func (eng *Engine) Server() { eng.Transport().SetServer() }
+
+func (eng *Engine) disconnect(err error) {
+ cond := eng.Transport().Condition()
+ cond.SetError(err) // Set the provided error.
+ cond.SetError(eng.conn.Close()) // Use connection error if cond is not already set.
+ eng.transport.CloseTail()
+ eng.transport.CloseHead()
+}
+
+// Close the engine's connection.
+// If err != nil pass it to the remote end as the close condition.
+// Returns when the remote end closes or disconnects.
+func (eng *Engine) Close(err error) {
+ _ = eng.Inject(func() { CloseError(eng.Connection(), err) })
+ <-eng.running
+}
+
+// CloseTimeout like Close but disconnect if the remote end doesn't close within timeout.
+func (eng *Engine) CloseTimeout(err error, timeout time.Duration) {
+ _ = eng.Inject(func() { CloseError(eng.Connection(), err) })
+ select {
+ case <-eng.running:
+ case <-time.After(timeout):
+ eng.Disconnect(err)
+ }
+}
+
+// Disconnect the engine's connection immediately without an AMQP close.
+// Process any termination events before returning.
+func (eng *Engine) Disconnect(err error) {
+ _ = eng.Inject(func() { eng.disconnect(err) })
+ <-eng.running
+}
+
+// Let proton run timed activity and set up the next tick
+func (eng *Engine) tick() {
+ now := time.Now()
+ next := eng.Transport().Tick(now)
+ if !next.IsZero() {
+ eng.timer.Reset(next.Sub(now))
+ }
+}
+
+func (eng *Engine) dispatch() bool {
+ for ce := C.pn_collector_peek(eng.collector); ce != nil; ce = C.pn_collector_peek(eng.collector) {
+ e := makeEvent(ce, eng)
+ if eng.traceEvent {
+ eng.transport.Log(e.String())
+ }
+ for _, h := range eng.handlers {
+ h.HandleEvent(e)
+ }
+ if e.Type() == EConnectionRemoteOpen {
+ eng.tick() // Update the tick if changed by remote.
+ }
+ C.pn_collector_pop(eng.collector)
+ }
+ return !eng.transport.Closed() || C.pn_collector_peek(eng.collector) != nil
+}
+
+func (eng *Engine) writeBuffer() []byte {
+ size := eng.Transport().Pending() // Evaluate before Head(), may change buffer.
+ start := eng.Transport().Head()
+ return cByteSlice(start, size)
+}
+
+func (eng *Engine) readBuffer() []byte {
+ size := eng.Transport().Capacity()
+ start := eng.Transport().Tail()
+ return cByteSlice(start, size)
+}
+
+func (eng *Engine) free() {
+ if !eng.transport.IsNil() {
+ eng.transport.Unbind()
+ eng.transport.Free()
+ eng.transport = Transport{}
+ }
+ if !eng.connection.IsNil() {
+ eng.connection.Free()
+ eng.connection = Connection{}
+ }
+ if eng.collector != nil {
+ C.pn_collector_release(eng.collector)
+ C.pn_collector_free(eng.collector)
+ eng.collector = nil
+ }
+}
+
+// Run the engine. Engine.Run() will exit when the engine is closed or
+// disconnected. You can check for errors after exit with Engine.Error().
+//
+func (eng *Engine) Run() error {
+ defer eng.free()
+ eng.transport.Bind(eng.connection)
+ eng.tick() // Start ticking if needed
+
+ // Channels for read and write buffers going in and out of the read/write goroutines.
- // The channels are unbuffered: we want to exchange buffers in seuquence.
++ // The channels are unbuffered: we want to exchange buffers in sequence.
+ readsIn, writesIn := make(chan []byte), make(chan []byte)
+ readsOut, writesOut := make(chan []byte), make(chan []byte)
+
+ wait := sync.WaitGroup{}
+ wait.Add(2) // Read and write goroutines
+
+ go func() { // Read goroutine
+ defer wait.Done()
+ for {
+ rbuf, ok := <-readsIn
+ if !ok {
+ return
+ }
+ n, err := eng.conn.Read(rbuf)
+ if n > 0 {
+ readsOut <- rbuf[:n]
+ } else if err != nil {
+ _ = eng.Inject(func() {
+ eng.Transport().Condition().SetError(err)
+ eng.Transport().CloseTail()
+ })
+ return
+ }
+ }
+ }()
+
+ go func() { // Write goroutine
+ defer wait.Done()
+ for {
+ wbuf, ok := <-writesIn
+ if !ok {
+ return
+ }
+ n, err := eng.conn.Write(wbuf)
+ if n > 0 {
+ writesOut <- wbuf[:n]
+ } else if err != nil {
+ _ = eng.Inject(func() {
+ eng.Transport().Condition().SetError(err)
+ eng.Transport().CloseHead()
+ })
+ return
+ }
+ }
+ }()
+
+ for eng.dispatch() {
+ readBuf := eng.readBuffer()
+ writeBuf := eng.writeBuffer()
+ // Note that getting the buffers can generate events (eg. SASL events) that
+ // might close the transport. Check if we are already finished before
+ // blocking for IO.
+ if !eng.dispatch() {
+ break
+ }
+
+ // sendReads/sendWrites are nil (not sendable in select) unless we have a
+ // buffer to read/write
+ var sendReads, sendWrites chan []byte
+ if readBuf != nil {
+ sendReads = readsIn
+ }
+ if writeBuf != nil {
+ sendWrites = writesIn
+ }
+
+ // Send buffers to the read/write goroutines if we have them.
+ // Get buffers from the read/write goroutines and process them
+ // Check for injected functions
+ select {
+
+ case sendReads <- readBuf:
+
+ case sendWrites <- writeBuf:
+
+ case buf := <-readsOut:
+ eng.transport.Process(uint(len(buf)))
+
+ case buf := <-writesOut:
+ eng.transport.Pop(uint(len(buf)))
+
+ case f, ok := <-eng.inject: // Function injected from another goroutine
+ if ok {
+ f()
+ }
+
+ case <-eng.timer.C:
+ eng.tick()
+ }
+ }
+
+ eng.err.Set(EndpointError(eng.Connection()))
+ eng.err.Set(eng.Transport().Condition().Error())
+ close(readsIn)
+ close(writesIn)
+ close(eng.running) // Signal goroutines have exited and Error is set, disable Inject()
+ _ = eng.conn.Close() // Close conn, force read/write goroutines to exit (they will Inject)
+ wait.Wait() // Wait for goroutines
+ return eng.err.Get()
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/proton/handlers.go
----------------------------------------------------------------------
diff --cc proton/handlers.go
index 961136e,0000000..f101548
mode 100644,000000..100644
--- a/proton/handlers.go
+++ b/proton/handlers.go
@@@ -1,395 -1,0 +1,395 @@@
+/*
+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.
+*/
+
+package proton
+
+import "fmt"
+
+// EventHandler handles core proton events.
+type EventHandler interface {
+ // HandleEvent is called with an event.
+ // Typically HandleEvent() is implemented as a switch on e.Type()
+ // Returning an error will stop the Engine.
+ HandleEvent(e Event)
+}
+
+// MessagingHandler provides an alternative interface to EventHandler.
+// it is easier to use for most applications that send and receive messages.
+//
+// Implement this interface and then wrap your value with a MessagingHandlerDelegator.
+// MessagingHandlerDelegator implements EventHandler and can be registered with a Engine.
+//
+type MessagingHandler interface {
+ // HandleMessagingEvent is called with MessagingEvent.
+ // Typically HandleEvent() is implemented as a switch on e.Type()
+ // Returning an error will stop the Engine.
+ HandleMessagingEvent(MessagingEvent, Event)
+}
+
+// MessagingEvent provides a set of events that are easier to work with than the
+// core events defined by EventType
+//
+// There are 3 types of "endpoint": Connection, Session and Link. For each
+// endpoint there are 5 events: Opening, Opened, Closing, Closed and Error.
+//
+// The meaning of these events is as follows:
+//
+// Opening: The remote end opened, the local end will open automatically.
+//
+// Opened: Both ends are open, regardless of which end opened first.
+//
+// Closing: The remote end closed without error, the local end will close automatically.
+//
+// Error: The remote end closed with an error, the local end will close automatically.
+//
+// Closed: Both ends are closed, regardless of which end closed first or if there was an error.
+// No further events will be received for the endpoint.
+//
+type MessagingEvent int
+
+const (
+ // The event loop starts.
+ MStart MessagingEvent = iota
+ // The peer closes the connection with an error condition.
+ MConnectionError
+ // The peer closes the session with an error condition.
+ MSessionError
+ // The peer closes the link with an error condition.
+ MLinkError
+ // The peer Initiates the opening of the connection.
+ MConnectionOpening
+ // The peer initiates the opening of the session.
+ MSessionOpening
+ // The peer initiates the opening of the link.
+ MLinkOpening
+ // The connection is opened.
+ MConnectionOpened
+ // The session is opened.
+ MSessionOpened
+ // The link is opened.
+ MLinkOpened
+ // The peer initiates the closing of the connection.
+ MConnectionClosing
+ // The peer initiates the closing of the session.
+ MSessionClosing
+ // The peer initiates the closing of the link.
+ MLinkClosing
+ // Both ends of the connection are closed.
+ MConnectionClosed
+ // Both ends of the session are closed.
+ MSessionClosed
+ // Both ends of the link are closed.
+ MLinkClosed
+ // The sender link has credit and messages can
+ // therefore be transferred.
+ MSendable
+ // The remote peer accepts an outgoing message.
+ MAccepted
+ // The remote peer rejects an outgoing message.
+ MRejected
+ // The peer releases an outgoing message. Note that this may be in response to
+ // either the RELEASE or MODIFIED state as defined by the AMQP specification.
+ MReleased
+ // The peer has settled the outgoing message. This is the point at which it
+ // should never be re-transmitted.
+ MSettled
+ // A message is received. Call Event.Delivery().Message() to decode as an amqp.Message.
+ // To manage the outcome of this messages (e.g. to accept or reject the message)
+ // use Event.Delivery().
+ MMessage
+ // A network connection was disconnected.
+ MDisconnected
+)
+
+func (t MessagingEvent) String() string {
+ switch t {
+ case MStart:
+ return "Start"
+ case MConnectionError:
+ return "ConnectionError"
+ case MSessionError:
+ return "SessionError"
+ case MLinkError:
+ return "LinkError"
+ case MConnectionOpening:
+ return "ConnectionOpening"
+ case MSessionOpening:
+ return "SessionOpening"
+ case MLinkOpening:
+ return "LinkOpening"
+ case MConnectionOpened:
+ return "ConnectionOpened"
+ case MSessionOpened:
+ return "SessionOpened"
+ case MLinkOpened:
+ return "LinkOpened"
+ case MConnectionClosing:
+ return "ConnectionClosing"
+ case MSessionClosing:
+ return "SessionClosing"
+ case MLinkClosing:
+ return "LinkClosing"
+ case MConnectionClosed:
+ return "ConnectionClosed"
+ case MSessionClosed:
+ return "SessionClosed"
+ case MLinkClosed:
+ return "LinkClosed"
+ case MDisconnected:
+ return "Disconnected"
+ case MSendable:
+ return "Sendable"
+ case MAccepted:
+ return "Accepted"
+ case MRejected:
+ return "Rejected"
+ case MReleased:
+ return "Released"
+ case MSettled:
+ return "Settled"
+ case MMessage:
+ return "Message"
+ default:
+ return "Unknown"
+ }
+}
+
+// ResourceHandler provides a simple way to track the creation and deletion of
+// various proton objects.
+// endpointDelegator captures common patterns for endpoints opening/closing
+type endpointDelegator struct {
+ remoteOpen, remoteClose, localOpen, localClose EventType
+ opening, opened, closing, closed, error MessagingEvent
+ endpoint func(Event) Endpoint
+ delegator *MessagingAdapter
+}
+
+// HandleEvent handles an open/close event for an endpoint in a generic way.
+func (d endpointDelegator) HandleEvent(e Event) {
+ endpoint := d.endpoint(e)
+ state := endpoint.State()
+
+ switch e.Type() {
+
+ case d.localOpen:
+ if state.RemoteActive() {
+ d.delegator.mhandler.HandleMessagingEvent(d.opened, e)
+ }
+
+ case d.remoteOpen:
+ d.delegator.mhandler.HandleMessagingEvent(d.opening, e)
+ switch {
+ case state.LocalActive():
+ d.delegator.mhandler.HandleMessagingEvent(d.opened, e)
+ case state.LocalUninit():
+ if d.delegator.AutoOpen {
+ endpoint.Open()
+ }
+ }
+
+ case d.remoteClose:
+ if endpoint.RemoteCondition().IsSet() { // Closed with error
+ d.delegator.mhandler.HandleMessagingEvent(d.error, e)
+ } else {
+ d.delegator.mhandler.HandleMessagingEvent(d.closing, e)
+ }
+ if state.LocalClosed() {
+ d.delegator.mhandler.HandleMessagingEvent(d.closed, e)
+ } else if state.LocalActive() {
+ endpoint.Close()
+ }
+
+ case d.localClose:
+ if state.RemoteClosed() {
+ d.delegator.mhandler.HandleMessagingEvent(d.closed, e)
+ }
+
+ default:
+ // We shouldn't be called with any other event type.
+ panic(fmt.Errorf("internal error, not an open/close event: %s", e))
+ }
+}
+
+type flowcontroller struct {
+ window, drained int
+}
+
+func (d flowcontroller) HandleEvent(e Event) {
+ link := e.Link()
+
+ switch e.Type() {
+ case ELinkLocalOpen, ELinkRemoteOpen, ELinkFlow, EDelivery:
+ if link.IsReceiver() {
+ d.drained += link.Drained()
+ if d.drained != 0 {
+ link.Flow(d.window - link.Credit())
+ }
+ }
+ }
+}
+
- // MessagingAdapter implments a EventHandler and delegates to a MessagingHandler.
++// MessagingAdapter implements a EventHandler and delegates to a MessagingHandler.
+// You can modify the exported fields before you pass the MessagingAdapter to
+// a Engine.
+type MessagingAdapter struct {
+ mhandler MessagingHandler
+ connection, session, link endpointDelegator
+ flowcontroller EventHandler
+
+ // AutoSettle (default true) automatically pre-settle outgoing messages.
+ AutoSettle bool
+ // AutoAccept (default true) automatically accept and settle incoming messages
+ // if they are not settled by the delegate.
+ AutoAccept bool
+ // AutoOpen (default true) automatically open remotely opened endpoints.
+ AutoOpen bool
+ // Prefetch (default 10) initial credit to issue for incoming links.
+ Prefetch int
+ // PeerCloseIsError (default false) if true a close by the peer will be treated as an error.
+ PeerCloseError bool
+}
+
+func NewMessagingAdapter(h MessagingHandler) *MessagingAdapter {
+ return &MessagingAdapter{
+ mhandler: h,
+ flowcontroller: nil,
+ AutoSettle: true,
+ AutoAccept: true,
+ AutoOpen: true,
+ Prefetch: 10,
+ PeerCloseError: false,
+ }
+}
+
+func handleIf(h EventHandler, e Event) {
+ if h != nil {
+ h.HandleEvent(e)
+ }
+}
+
+// Handle a proton event by passing the corresponding MessagingEvent(s) to
+// the MessagingHandler.
+func (d *MessagingAdapter) HandleEvent(e Event) {
+ handleIf(d.flowcontroller, e)
+
+ switch e.Type() {
+
+ case EConnectionInit:
+ d.connection = endpointDelegator{
+ EConnectionRemoteOpen, EConnectionRemoteClose, EConnectionLocalOpen, EConnectionLocalClose,
+ MConnectionOpening, MConnectionOpened, MConnectionClosing, MConnectionClosed,
+ MConnectionError,
+ func(e Event) Endpoint { return e.Connection() },
+ d,
+ }
+ d.session = endpointDelegator{
+ ESessionRemoteOpen, ESessionRemoteClose, ESessionLocalOpen, ESessionLocalClose,
+ MSessionOpening, MSessionOpened, MSessionClosing, MSessionClosed,
+ MSessionError,
+ func(e Event) Endpoint { return e.Session() },
+ d,
+ }
+ d.link = endpointDelegator{
+ ELinkRemoteOpen, ELinkRemoteClose, ELinkLocalOpen, ELinkLocalClose,
+ MLinkOpening, MLinkOpened, MLinkClosing, MLinkClosed,
+ MLinkError,
+ func(e Event) Endpoint { return e.Link() },
+ d,
+ }
+ if d.Prefetch > 0 {
+ d.flowcontroller = flowcontroller{window: d.Prefetch, drained: 0}
+ }
+ d.mhandler.HandleMessagingEvent(MStart, e)
+
+ case EConnectionRemoteOpen:
+
+ d.connection.HandleEvent(e)
+
+ case EConnectionRemoteClose:
+ d.connection.HandleEvent(e)
+ e.Connection().Transport().CloseTail()
+
+ case EConnectionLocalOpen, EConnectionLocalClose:
+ d.connection.HandleEvent(e)
+
+ case ESessionRemoteOpen, ESessionRemoteClose, ESessionLocalOpen, ESessionLocalClose:
+ d.session.HandleEvent(e)
+
+ case ELinkRemoteOpen:
+ e.Link().Source().Copy(e.Link().RemoteSource())
+ e.Link().Target().Copy(e.Link().RemoteTarget())
+ d.link.HandleEvent(e)
+
+ case ELinkRemoteClose, ELinkLocalOpen, ELinkLocalClose:
+ d.link.HandleEvent(e)
+
+ case ELinkFlow:
+ if e.Link().IsSender() && e.Link().Credit() > 0 {
+ d.mhandler.HandleMessagingEvent(MSendable, e)
+ }
+
+ case EDelivery:
+ if e.Delivery().Link().IsReceiver() {
+ d.incoming(e)
+ } else {
+ d.outgoing(e)
+ }
+
+ case ETransportClosed:
+ d.mhandler.HandleMessagingEvent(MDisconnected, e)
+ }
+}
+
+func (d *MessagingAdapter) incoming(e Event) {
+ delivery := e.Delivery()
+ if delivery.HasMessage() {
+ d.mhandler.HandleMessagingEvent(MMessage, e)
+ if d.AutoAccept && !delivery.Settled() {
+ delivery.Accept()
+ }
+ if delivery.Current() {
+ e.Link().Advance()
+ }
+ } else if delivery.Updated() && delivery.Settled() {
+ d.mhandler.HandleMessagingEvent(MSettled, e)
+ }
+ return
+}
+
+func (d *MessagingAdapter) outgoing(e Event) {
+ delivery := e.Delivery()
+ if delivery.Updated() {
+ switch delivery.Remote().Type() {
+ case Accepted:
+ d.mhandler.HandleMessagingEvent(MAccepted, e)
+ case Rejected:
+ d.mhandler.HandleMessagingEvent(MRejected, e)
+ case Released, Modified:
+ d.mhandler.HandleMessagingEvent(MReleased, e)
+ }
+ if delivery.Settled() {
+ // The delivery was settled remotely, inform the local end.
+ d.mhandler.HandleMessagingEvent(MSettled, e)
+ }
+ if d.AutoSettle {
+ delivery.Settle() // Local settle, don't mhandler MSettled till the remote end settles.
+ }
+ }
+ return
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/proton/message.go
----------------------------------------------------------------------
diff --cc proton/message.go
index 2336483,0000000..fbb1d48
mode 100644,000000..100644
--- a/proton/message.go
+++ b/proton/message.go
@@@ -1,93 -1,0 +1,93 @@@
+/*
+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.
+*/
+
+package proton
+
+// #include <proton/types.h>
+// #include <proton/message.h>
+// #include <proton/codec.h>
+import "C"
+
+import (
+ "fmt"
+ "qpid.apache.org/amqp"
+ "strconv"
+ "sync/atomic"
+)
+
+// HasMessage is true if all message data is available.
+// Equivalent to !d.isNil && d.Readable() && !d.Partial()
+func (d Delivery) HasMessage() bool { return !d.IsNil() && d.Readable() && !d.Partial() }
+
- // Message decodes the message containined in a delivery.
++// Message decodes the message contained in a delivery.
+//
+// Must be called in the correct link context with this delivery as the current message,
+// handling an MMessage event is always a safe context to call this function.
+//
+// Will return an error if message is incomplete or not current.
+func (delivery Delivery) Message() (m amqp.Message, err error) {
+ if !delivery.Readable() {
+ return nil, fmt.Errorf("delivery is not readable")
+ }
+ if delivery.Partial() {
+ return nil, fmt.Errorf("delivery has partial message")
+ }
+ data := make([]byte, delivery.Pending())
+ result := delivery.Link().Recv(data)
+ if result != len(data) {
+ return nil, fmt.Errorf("cannot receive message: %s", PnErrorCode(result))
+ }
+ m = amqp.NewMessage()
+ err = m.Decode(data)
+ return
+}
+
+// Process-wide atomic counter for generating tag names
+var tagCounter uint64
+
+func nextTag() string {
+ return strconv.FormatUint(atomic.AddUint64(&tagCounter, 1), 32)
+}
+
+// Send sends a amqp.Message over a Link.
+// Returns a Delivery that can be use to determine the outcome of the message.
+func (link Link) Send(m amqp.Message) (Delivery, error) {
+ if !link.IsSender() {
+ return Delivery{}, fmt.Errorf("attempt to send message on receiving link")
+ }
+
+ delivery := link.Delivery(nextTag())
+ bytes, err := m.Encode(nil)
+ if err != nil {
- return Delivery{}, fmt.Errorf("cannot send mesage %s", err)
++ return Delivery{}, fmt.Errorf("cannot send message %s", err)
+ }
+ result := link.SendBytes(bytes)
+ link.Advance()
+ if result != len(bytes) {
+ if result < 0 {
+ return delivery, fmt.Errorf("send failed %v", PnErrorCode(result))
+ } else {
+ return delivery, fmt.Errorf("send incomplete %v of %v", result, len(bytes))
+ }
+ }
+ if link.RemoteSndSettleMode() == SndSettled {
+ delivery.Settle()
+ }
+ return delivery, nil
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b25d21e6/proton/wrappers.go
----------------------------------------------------------------------
diff --cc proton/wrappers.go
index 09f3e65,0000000..a7b7fb2
mode 100644,000000..100644
--- a/proton/wrappers.go
+++ b/proton/wrappers.go
@@@ -1,460 -1,0 +1,460 @@@
+/*
+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.
+*/
+
+// This file contains special-case wrapper functions or wrappers that don't follow
+// the pattern of genwrap.go.
+
+package proton
+
+//#include <proton/codec.h>
+//#include <proton/connection.h>
+//#include <proton/delivery.h>
+//#include <proton/event.h>
+//#include <proton/link.h>
+//#include <proton/link.h>
+//#include <proton/object.h>
+//#include <proton/sasl.h>
+//#include <proton/session.h>
+//#include <proton/transport.h>
+//#include <stdlib.h>
+import "C"
+
+import (
+ "fmt"
+ "qpid.apache.org/amqp"
+ "reflect"
+ "time"
+ "unsafe"
+)
+
+// TODO aconway 2015-05-05: Documentation for generated types.
+
+// CHandle holds an unsafe.Pointer to a proton C struct, the C type depends on the
+// Go type implementing this interface. For low level, at-your-own-risk use only.
+type CHandle interface {
+ // CPtr returns the unsafe C pointer, equivalent to a C void*.
+ CPtr() unsafe.Pointer
+}
+
+// Incref increases the refcount of a proton value, which prevents the
+// underlying C struct being freed until you call Decref().
+//
+// It can be useful to "pin" a proton value in memory while it is in use by
+// goroutines other than the event loop goroutine. For example if you Incref() a
+// Link, the underlying object is not freed when the link is closed, so means
+// other goroutines can continue to safely use it as an index in a map or inject
+// it into the event loop goroutine. There will of course be an error if you try
+// to use a link after it is closed, but not a segmentation fault.
+func Incref(c CHandle) {
+ if p := c.CPtr(); p != nil {
+ C.pn_incref(p)
+ }
+}
+
+// Decref decreases the refcount of a proton value, freeing the underlying C
+// struct if this is the last reference. Only call this if you previously
+// called Incref() for this value.
+func Decref(c CHandle) {
+ if p := c.CPtr(); p != nil {
+ C.pn_decref(p)
+ }
+}
+
+// Event is an AMQP protocol event.
+type Event struct {
+ pn *C.pn_event_t
+ eventType EventType
+ connection Connection
+ transport Transport
+ session Session
+ link Link
+ delivery Delivery
+ injecter Injecter
+}
+
+func makeEvent(pn *C.pn_event_t, injecter Injecter) Event {
+ return Event{
+ pn: pn,
+ eventType: EventType(C.pn_event_type(pn)),
+ connection: Connection{C.pn_event_connection(pn)},
+ transport: Transport{C.pn_event_transport(pn)},
+ session: Session{C.pn_event_session(pn)},
+ link: Link{C.pn_event_link(pn)},
+ delivery: Delivery{C.pn_event_delivery(pn)},
+ injecter: injecter,
+ }
+}
+func (e Event) IsNil() bool { return e.eventType == EventType(0) }
+func (e Event) Type() EventType { return e.eventType }
+func (e Event) Connection() Connection { return e.connection }
+func (e Event) Transport() Transport { return e.transport }
+func (e Event) Session() Session { return e.session }
+func (e Event) Link() Link { return e.link }
+func (e Event) Delivery() Delivery { return e.delivery }
+func (e Event) String() string { return e.Type().String() }
+
+// Injecter should not be used in a handler function, but it can be passed to
+// other goroutines (via a channel or to a goroutine started by handler
+// functions) to let them inject functions back into the handlers goroutine.
+func (e Event) Injecter() Injecter { return e.injecter }
+
+// Data is an intermediate form of decoded AMQP data.
+type Data struct{ pn *C.pn_data_t }
+
+func (d Data) Free() { C.pn_data_free(d.pn) }
+func (d Data) CPtr() unsafe.Pointer { return unsafe.Pointer(d.pn) }
+func (d Data) Clear() { C.pn_data_clear(d.pn) }
+func (d Data) Rewind() { C.pn_data_rewind(d.pn) }
+func (d Data) Next() { C.pn_data_next(d.pn) }
+func (d Data) Error() error { return PnError(C.pn_data_error(d.pn)) }
+func (d Data) Empty() bool { return C.pn_data_size(d.pn) == 0 }
+
+func (d Data) String() string {
+ str := C.pn_string(C.CString(""))
+ defer C.pn_free(unsafe.Pointer(str))
+ C.pn_inspect(unsafe.Pointer(d.pn), str)
+ return C.GoString(C.pn_string_get(str))
+}
+
+// Unmarshal the value of d into value pointed at by ptr, see amqp.Unmarshal() for details
+func (d Data) Unmarshal(ptr interface{}) error {
+ d.Rewind()
+ d.Next()
+ err := amqp.UnmarshalUnsafe(d.CPtr(), ptr)
+ return err
+}
+
+// Marshal the value v into d, see amqp.Marshal() for details
+func (d Data) Marshal(v interface{}) error {
+ d.Clear()
+ return amqp.MarshalUnsafe(v, d.CPtr())
+}
+
+// State holds the state flags for an AMQP endpoint.
+type State byte
+
+const (
+ SLocalUninit State = C.PN_LOCAL_UNINIT
+ SLocalActive = C.PN_LOCAL_ACTIVE
+ SLocalClosed = C.PN_LOCAL_CLOSED
+ SRemoteUninit = C.PN_REMOTE_UNINIT
+ SRemoteActive = C.PN_REMOTE_ACTIVE
+ SRemoteClosed = C.PN_REMOTE_CLOSED
+)
+
+// Has is True if bits & state is non 0.
+func (s State) Has(bits State) bool { return s&bits != 0 }
+
+func (s State) LocalUninit() bool { return s.Has(SLocalUninit) }
+func (s State) LocalActive() bool { return s.Has(SLocalActive) }
+func (s State) LocalClosed() bool { return s.Has(SLocalClosed) }
+func (s State) RemoteUninit() bool { return s.Has(SRemoteUninit) }
+func (s State) RemoteActive() bool { return s.Has(SRemoteActive) }
+func (s State) RemoteClosed() bool { return s.Has(SRemoteClosed) }
+
- // Return a State containig just the local flags
++// Return a State containing just the local flags
+func (s State) Local() State { return State(s & C.PN_LOCAL_MASK) }
+
- // Return a State containig just the remote flags
++// Return a State containing just the remote flags
+func (s State) Remote() State { return State(s & C.PN_REMOTE_MASK) }
+
+// Endpoint is the common interface for Connection, Link and Session.
+type Endpoint interface {
+ // State is the open/closed state.
+ State() State
+ // Open an endpoint.
+ Open()
+ // Close an endpoint.
+ Close()
+ // Condition holds a local error condition.
+ Condition() Condition
+ // RemoteCondition holds a remote error condition.
+ RemoteCondition() Condition
+ // Human readable name
+ String() string
+ // Human readable endpoint type "sender-link", "session" etc.
+ Type() string
+}
+
+// CloseError sets an error condition (if err != nil) on an endpoint and closes
+// the endpoint if not already closed
+func CloseError(e Endpoint, err error) {
+ if err != nil && !e.Condition().IsSet() {
+ e.Condition().SetError(err)
+ }
+ e.Close()
+}
+
+// EndpointError returns the remote error if there is one, the local error if not
+// nil if there is no error.
+func EndpointError(e Endpoint) error {
+ err := e.RemoteCondition().Error()
+ if err == nil {
+ err = e.Condition().Error()
+ }
+ return err
+}
+
+const (
+ Received uint64 = C.PN_RECEIVED
+ Accepted = C.PN_ACCEPTED
+ Rejected = C.PN_REJECTED
+ Released = C.PN_RELEASED
+ Modified = C.PN_MODIFIED
+)
+
+// SettleAs is equivalent to d.Update(disposition); d.Settle()
+func (d Delivery) SettleAs(disposition uint64) {
+ d.Update(disposition)
+ d.Settle()
+}
+
+// Accept accepts and settles a delivery.
+func (d Delivery) Accept() { d.SettleAs(Accepted) }
+
+// Reject rejects and settles a delivery
+func (d Delivery) Reject() { d.SettleAs(Rejected) }
+
+// Release releases and settles a delivery
+// If delivered is true the delivery count for the message will be increased.
+func (d Delivery) Release(delivered bool) {
+ if delivered {
+ d.SettleAs(Modified)
+ } else {
+ d.SettleAs(Released)
+ }
+}
+
+type DeliveryTag struct{ pn C.pn_delivery_tag_t }
+
+func (t DeliveryTag) String() string { return C.GoStringN(t.pn.start, C.int(t.pn.size)) }
+
+func (l Link) Recv(buf []byte) int {
+ if len(buf) == 0 {
+ return 0
+ }
+ return int(C.pn_link_recv(l.pn, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
+}
+
+func (l Link) SendBytes(bytes []byte) int {
+ return int(C.pn_link_send(l.pn, cPtr(bytes), cLen(bytes)))
+}
+
+func pnTag(tag string) C.pn_delivery_tag_t {
+ bytes := []byte(tag)
+ return C.pn_dtag(cPtr(bytes), cLen(bytes))
+}
+
+func (l Link) Delivery(tag string) Delivery {
+ return Delivery{C.pn_delivery(l.pn, pnTag(tag))}
+}
+
+func (l Link) Connection() Connection { return l.Session().Connection() }
+
+// Human-readable link description including name, source, target and direction.
+func (l Link) String() string {
+ switch {
+ case l.IsNil():
+ return fmt.Sprintf("<nil-link>")
+ case l.IsSender():
+ return fmt.Sprintf("%s(%s->%s)", l.Name(), l.Source().Address(), l.Target().Address())
+ default:
+ return fmt.Sprintf("%s(%s<-%s)", l.Name(), l.Target().Address(), l.Source().Address())
+ }
+}
+
+func (l Link) Type() string {
+ if l.IsSender() {
+ return "sender-link"
+ } else {
+ return "receiver-link"
+ }
+}
+
+// IsDrain calls pn_link_get_drain(), it conflicts with pn_link_drain() under the normal mapping.
+func (l Link) IsDrain() bool {
+ return bool(C.pn_link_get_drain(l.pn))
+}
+
+func cPtr(b []byte) *C.char {
+ if len(b) == 0 {
+ return nil
+ }
+ return (*C.char)(unsafe.Pointer(&b[0]))
+}
+
+func cLen(b []byte) C.size_t {
+ return C.size_t(len(b))
+}
+
+func (s Session) Sender(name string) Link {
+ cname := C.CString(name)
+ defer C.free(unsafe.Pointer(cname))
+ return Link{C.pn_sender(s.pn, cname)}
+}
+
+func (s Session) Receiver(name string) Link {
+ cname := C.CString(name)
+ defer C.free(unsafe.Pointer(cname))
+ return Link{C.pn_receiver(s.pn, cname)}
+}
+
+func (t Transport) String() string {
+ return fmt.Sprintf("(Transport)(%p)", t.CPtr())
+}
+
+// Unique (per process) string identifier for a connection, useful for debugging.
+func (c Connection) String() string {
+ // Use the transport address to match the default transport logs from PN_TRACE.
+ return fmt.Sprintf("(Connection)(%p)", c.Transport().CPtr())
+}
+
+func (c Connection) Type() string {
+ return "connection"
+}
+
+// Head functions don't follow the normal naming conventions so missed by the generator.
+
+func (c Connection) LinkHead(s State) Link {
+ return Link{C.pn_link_head(c.pn, C.pn_state_t(s))}
+}
+
+func (c Connection) SessionHead(s State) Session {
+ return Session{C.pn_session_head(c.pn, C.pn_state_t(s))}
+}
+
+func (c Connection) Links(state State) (links []Link) {
+ for l := c.LinkHead(state); !l.IsNil(); l = l.Next(state) {
+ links = append(links, l)
+ }
+ return
+}
+
+func (c Connection) Sessions(state State) (sessions []Session) {
+ for s := c.SessionHead(state); !s.IsNil(); s = s.Next(state) {
+ sessions = append(sessions, s)
+ }
+ return
+}
+
+// SetPassword takes []byte not string because it is impossible to erase a string
+// from memory reliably. Proton will not keep the password in memory longer than
+// needed, the caller should overwrite their copy on return.
+//
+// The password must not contain embedded nul characters, a trailing nul is ignored.
+func (c Connection) SetPassword(password []byte) {
+ if len(password) == 0 || password[len(password)-1] != 0 {
+ password = append(password, 0) // Proton requires a terminating null.
+ }
+ C.pn_connection_set_password(c.pn, (*C.char)(unsafe.Pointer(&password[0])))
+}
+
+func (s Session) String() string {
+ return fmt.Sprintf("(Session)(%p)", s.pn) // TODO aconway 2016-09-12: should print channel number.
+}
+
+func (s Session) Type() string { return "session" }
+
+// Error returns an instance of amqp.Error or nil.
+func (c Condition) Error() error {
+ if c.IsNil() || !c.IsSet() {
+ return nil
+ }
+ return amqp.Error{Name: c.Name(), Description: c.Description()}
+}
+
+// Set a Go error into a condition.
+// If it is not an amqp.Condition use the error type as name, error string as description.
+func (c Condition) SetError(err error) {
+ if err != nil {
+ if cond, ok := err.(amqp.Error); ok {
+ c.SetName(cond.Name)
+ c.SetDescription(cond.Description)
+ } else {
+ c.SetName(reflect.TypeOf(err).Name())
+ c.SetDescription(err.Error())
+ }
+ }
+}
+
+func (c Connection) Session() (Session, error) {
+ s := Session{C.pn_session(c.pn)}
+ if s.IsNil() {
+ return s, Connection(c).Error()
+ }
+ return s, nil
+}
+
+// pnTime converts Go time.Time to Proton millisecond Unix time.
+//
+// Note: t.isZero() is converted to C.pn_timestamp_t(0) and vice-versa. These
+// are used as "not set" sentinel values by the Go and Proton APIs, so it is
+// better to conserve the "zeroness" even though they don't represent the same
+// time instant.
+//
+func pnTime(t time.Time) (pnt C.pn_timestamp_t) {
+ if !t.IsZero() {
+ pnt = C.pn_timestamp_t(t.Unix()*1000 + int64(t.Nanosecond())/int64(time.Millisecond))
+ }
+ return
+}
+
+// goTime converts a pn_timestamp_t to a Go time.Time.
+//
+// Note: C.pn_timestamp_t(0) is converted to a zero time.Time and
+// vice-versa. These are used as "not set" sentinel values by the Go and Proton
+// APIs, so it is better to conserve the "zeroness" even though they don't
+// represent the same time instant.
+//
+func goTime(pnt C.pn_timestamp_t) (t time.Time) {
+ if pnt != 0 {
+ t = time.Unix(int64(pnt/1000), int64(pnt%1000)*int64(time.Millisecond))
+ }
+ return
+}
+
+// Special treatment for Transport.Head, return value is unsafe.Pointer not string
+func (t Transport) Head() unsafe.Pointer {
+ return unsafe.Pointer(C.pn_transport_head(t.pn))
+}
+
+// Special treatment for Transport.Tail, return value is unsafe.Pointer not string
+func (t Transport) Tail() unsafe.Pointer {
+ return unsafe.Pointer(C.pn_transport_tail(t.pn))
+}
+
+// Special treatment for Transport.Push, takes []byte instead of char*, size
+func (t Transport) Push(bytes []byte) int {
+ return int(C.pn_transport_push(t.pn, (*C.char)(unsafe.Pointer(&bytes[0])), C.size_t(len(bytes))))
+}
+
+// Get the SASL object for the transport.
+func (t Transport) SASL() SASL {
+ return SASL{C.pn_sasl(t.pn)}
+}
+
+// Do we support extended SASL negotiation?
+// All implementations of Proton support ANONYMOUS and EXTERNAL on both
+// client and server sides and PLAIN on the client side.
+//
+// Extended SASL implememtations use an external library (Cyrus SASL)
+// to support other mechanisms beyond these basic ones.
+func SASLExtended() bool {
+ return bool(C.pn_sasl_extended())
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[23/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fixes to
Delivery and Codec
Posted by ac...@apache.org.
PROTON-1537: [ruby] Fixes to Delivery and Codec
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/72074d42
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/72074d42
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/72074d42
Branch: refs/heads/go1
Commit: 72074d42a444eceaac2362a55badb29314e1c615
Parents: c172383
Author: Alan Conway <ac...@redhat.com>
Authored: Sat Dec 9 14:14:44 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Dec 13 13:16:48 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/codec/data.rb | 2 +-
proton-c/bindings/ruby/lib/core/delivery.rb | 31 +++---
proton-c/bindings/ruby/lib/core/tracker.rb | 14 +--
proton-c/bindings/ruby/lib/core/transfer.rb | 3 +
proton-c/bindings/ruby/lib/handler/adapter.rb | 6 +-
proton-c/bindings/ruby/lib/types/array.rb | 2 +-
proton-c/bindings/ruby/lib/types/hash.rb | 2 +-
proton-c/bindings/ruby/lib/util/wrapper.rb | 3 +-
proton-c/bindings/ruby/tests/test_delivery.rb | 106 +++++++++++++++++++++
proton-c/bindings/ruby/tests/test_interop.rb | 3 +-
proton-c/bindings/ruby/tests/test_tools.rb | 13 +++
11 files changed, 157 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/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 86af3a1..1573b5c 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -120,7 +120,7 @@ module Qpid::Proton
def expect(code)
unless code == self.code
- raise TypeError, "expected #{Cproton.pn_type_name(code)}, got #{Cproton.pn_type_name(code)}"
+ raise TypeError, "expected #{Cproton.pn_type_name(code)}, got #{Cproton.pn_type_name(self.code)}"
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/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
index b240784..ba89097 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -31,29 +31,34 @@ module Qpid::Proton
# Release a message, indicating to the sender that it was not processed
# but may be delivered again to this or another receiver.
#
- # @param mods [Hash] Instructions to the sender to modify re-delivery.
+ # @param opts [Hash] Instructions to the sender to modify re-delivery.
# To allow re-delivery with no modifications at all use +release(nil)+
#
- # @option mods [Boolean] :failed Instruct the sender to increase
+ # @option opts [Boolean] :failed (true) Instruct the sender to increase
# {Message#delivery_count} so future receivers will know there was a
# previous failed delivery.
#
- # @option mods [Boolean] :undeliverable Instruct the sender that this
+ # @option opts [Boolean] :undeliverable (false) Instruct the sender that this
# message should never be re-delivered to this receiver, although it may be
# delivered other receivers.
#
- # @option mods [Hash] :annotations Instruct the sender to update the
- # {Message#annotations} with these +key=>value+ pairs before re-delivery.
- def release(mods = {:failed=>true})
- mods = { :failed => true } if mods == true # Backwards compatibility
- if !mods || mods.empty?
- settle(RELEASED)
- else
+ # @option opts [Hash] :annotations Instruct the sender to update the
+ # {Message#annotations} with these +key=>value+ pairs before re-delivery,
+ # replacing existing entries in {Message#annotations} with the same key.
+ def release(opts = nil)
+ opts = { :failed => false } if (opts == false) # deprecated
+ failed = !opts || opts.fetch(:failed, true)
+ undeliverable = opts && opts[:undeliverable]
+ annotations = opts && opts[:annotations]
+ annotations = nil if annotations && annotations.empty?
+ if failed || undeliverable || annotations
d = Cproton.pn_delivery_local(@impl)
- Cproton.pn_disposition_set_failed(mods[:failed])
- Cproton.pn_disposition_set_undeliverable(mods[:undeliverable])
- Data.from_object(Cproton.pn_disposition_annotations(d), mods[:annotations]) if mods.key? :annotations
+ Cproton.pn_disposition_set_failed(d, true) if failed
+ Cproton.pn_disposition_set_undeliverable(d, true) if undeliverable
+ Codec::Data.from_object(Cproton.pn_disposition_annotations(d), annotations) if annotations
settle(MODIFIED)
+ else
+ settle(RELEASED)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/lib/core/tracker.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/tracker.rb b/proton-c/bindings/ruby/lib/core/tracker.rb
index 79620de..cf04be9 100644
--- a/proton-c/bindings/ruby/lib/core/tracker.rb
+++ b/proton-c/bindings/ruby/lib/core/tracker.rb
@@ -23,14 +23,16 @@ module Qpid::Proton
# @return [Sender] The parent {Sender} link.
def sender() link; end
- # Re-delivery modifications provided by the receiver in {Delivery#release}
- # @return [Hash] See the {Delivery#release} +mods+ parameter.
+ # Re-delivery modifications sent by the receiver in {Delivery#release}
+ # @return [Hash] See the {Delivery#release} +opts+ parameter.
+ # @return [nil] If no modifications were requested by the receiver.
def modifications()
- return {} unless (state == MODIFIED) && (d = Cproton.pn_delivery_remote(@impl))
+ return nil if (state != MODIFIED)
+ d = Cproton.pn_delivery_remote(@impl)
{
- :failed => Cproton.pn_disposition_get_failed(d),
- :undeliverable => Cproton.pn_disposition_get_undeliverable(d),
- :annotations => Data.to_object(Cproton.pn_disposition_annotations(d))
+ :failed => Cproton.pn_disposition_is_failed(d),
+ :undeliverable => Cproton.pn_disposition_is_undeliverable(d),
+ :annotations => Codec::Data.to_object(Cproton.pn_disposition_annotations(d))
}
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index 57e8b55..cdf3419 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -112,7 +112,10 @@ module Qpid::Proton
def settle(state = nil)
update(state) unless state.nil?
Cproton.pn_delivery_settle(@impl)
+ @inspect = inspect # Save the inspect string, the delivery pointer will go bad.
end
+ def inspect() @inspect || super; end
+ def to_s() inspect; end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/lib/handler/adapter.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/adapter.rb b/proton-c/bindings/ruby/lib/handler/adapter.rb
index 8fe9bc5..25dd8c0 100644
--- a/proton-c/bindings/ruby/lib/handler/adapter.rb
+++ b/proton-c/bindings/ruby/lib/handler/adapter.rb
@@ -122,9 +122,8 @@ module Qpid::Proton::Handler
d.release(true)
end
end
- elsif d.updated? && d.settled?
- delegate(:on_settled, event)
end
+ delegate(:on_settled, event) if d.settled?
add_credit(event)
else # Outgoing message
t = event.tracker
@@ -132,7 +131,8 @@ module Qpid::Proton::Handler
case t.remote_state
when Qpid::Proton::Delivery::ACCEPTED then delegate(:on_accepted, event)
when Qpid::Proton::Delivery::REJECTED then delegate(:on_rejected, event)
- when Qpid::Proton::Delivery::RELEASED, Qpid::Proton::Delivery::MODIFIED then delegate(:on_released, event)
+ when Qpid::Proton::Delivery::RELEASED then delegate(:on_released, event)
+ when Qpid::Proton::Delivery::MODIFIED then delegate(:on_modified, event)
end
delegate(:on_settled, event) if t.settled?
t.settle if @opts[:auto_settle]
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/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 3051f31..d00a86b 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -18,7 +18,7 @@
#--
# Patch the Array class to provide methods for adding its contents
-# to a Qpid::Proton::Data instance.
+# to a Qpid::Proton::Codec::Data instance.
#++
module Qpid::Proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index 736bb8f..f70cbdb 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -18,7 +18,7 @@
#--
# Patch the Hash class to provide methods for adding its contents
-# to a Qpid::Proton::Data instance.
+# to a Qpid::Proton::Codec::Data instance.
#++
# @private
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/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
index 347a9a5..08d1794 100644
--- a/proton-c/bindings/ruby/lib/util/wrapper.rb
+++ b/proton-c/bindings/ruby/lib/util/wrapper.rb
@@ -124,6 +124,7 @@ module Qpid::Proton
attr_accessor :impl
def inspect
+ return "#{self.class}<nil>" unless @impl
pstr = Cproton.pn_string("")
begin
Cproton.pn_inspect(@impl, pstr)
@@ -133,7 +134,7 @@ module Qpid::Proton
end
end
- alias to_s inspect
+ def to_s() inspect; end
def self.registry
@registry ||= {}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/tests/test_delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_delivery.rb b/proton-c/bindings/ruby/tests/test_delivery.rb
new file mode 100644
index 0000000..334450a
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_delivery.rb
@@ -0,0 +1,106 @@
+# 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 'minitest/autorun'
+require 'qpid_proton'
+require 'test_tools'
+include Qpid::Proton
+
+# Test Delivery and Tracker
+class TestDelivery < Minitest::Test
+
+ # Duck-typed handler
+ class NoAutoHandler
+ @@options = {:auto_settle=>false, :auto_accept=>false}
+ def options() @@options; end
+ end
+
+ class SendHandler < NoAutoHandler
+ def initialize(to_send)
+ @unsent = to_send
+ end
+
+ def on_connection_opened(event)
+ @outcomes = []
+ @sender = event.connection.open_sender("x")
+ @unsettled = {} # Awaiting remote settlement
+ end
+
+ attr_reader :outcomes, :unsent, :unsettled
+
+ def on_sendable(event)
+ return if @unsent.empty?
+ m = Message.new(@unsent.shift)
+ tracker = event.sender.send(m)
+ @unsettled[tracker] = m
+ end
+
+ def outcome(event)
+ t = event.tracker
+ m = @unsettled.delete(t)
+ @outcomes << [m.body, event.method, t.id, t.state, t.modifications]
+ event.connection.close if @unsettled.empty?
+ end
+
+ def on_accepted(event) outcome(event); end
+ def on_rejected(event) outcome(event); end
+ def on_released(event) outcome(event); end
+ def on_modified(event) outcome(event); end
+ end
+
+ class ReceiveHandler < NoAutoHandler
+ def initialize
+ @received = []
+ end
+
+ attr_reader :received
+
+ def on_message(event)
+ @received << event.message.body
+ case event.message.body
+ when "accept" then event.delivery.accept
+ when "reject" then event.delivery.reject
+ when "release-really" then event.delivery.release({:failed=>false}) # AMQP RELEASED
+ when "release" then event.delivery.release # AMQP MODIFIED{ :failed => true }
+ when "modify" then event.delivery.release({:undeliverable => true, :annotations => {:x => 42 }})
+ when "modify-empty" then event.delivery.release({:failed => false, :undeliverable => false, :annotations => {}})
+ when "modify-nil" then event.delivery.release({:failed => false, :undeliverable => false, :annotations => nil})
+ else raise event.inspect
+ end
+ end
+ end
+
+ def test_outcomes
+ rh = ReceiveHandler.new
+ sh = SendHandler.new(["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"])
+ c = TestContainer.new(nil, { :handler => rh }, __method__)
+ c.connect(c.url, {:handler => sh})
+ c.run
+ o = sh.outcomes
+ assert_equal ["accept", :on_accepted, "1", Transfer::ACCEPTED, nil], o.shift
+ assert_equal ["reject", :on_rejected, "2", Transfer::REJECTED, nil], o.shift
+ assert_equal ["release-really", :on_released, "3", Transfer::RELEASED, nil], o.shift
+ assert_equal ["release", :on_modified, "4", Transfer::MODIFIED, {:failed=>true, :undeliverable=>false, :annotations=>nil}], o.shift
+ assert_equal ["modify", :on_modified, "5", Transfer::MODIFIED, {:failed=>true, :undeliverable=>true, :annotations=>{:x => 42}}], o.shift
+ assert_equal ["modify-empty", :on_released, "6", Transfer::RELEASED, nil], o.shift
+ assert_equal ["modify-nil", :on_released, "7", Transfer::RELEASED, nil], o.shift
+ assert_empty o
+ assert_equal ["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil"], rh.received
+ assert_empty sh.unsettled
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/tests/test_interop.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_interop.rb b/proton-c/bindings/ruby/tests/test_interop.rb
index 0a13a3d..326b481 100755
--- a/proton-c/bindings/ruby/tests/test_interop.rb
+++ b/proton-c/bindings/ruby/tests/test_interop.rb
@@ -15,10 +15,9 @@ end
class InteropTest < MiniTest::Test
include Qpid::Proton
- Data = Codec::Data
def setup
- @data = Data.new
+ @data = Codec::Data.new
@message = Message.new
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/72074d42/proton-c/bindings/ruby/tests/test_tools.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_tools.rb b/proton-c/bindings/ruby/tests/test_tools.rb
index 2dc13b3..bc9c1d9 100644
--- a/proton-c/bindings/ruby/tests/test_tools.rb
+++ b/proton-c/bindings/ruby/tests/test_tools.rb
@@ -116,3 +116,16 @@ class DriverPair < Array
end
end
+
+# Container that listens on a random port for a single connection
+class TestContainer < Container
+
+ def initialize(handler, lopts=nil, id=nil)
+ super handler, id
+ @server = TCPServer.open(0)
+ @listener = listen_io(@server, ListenOnceHandler.new(lopts))
+ end
+
+ def port() @server.addr[1]; end
+ def url() "amqp://:#{port}"; end
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[30/50] [abbrv] qpid-proton git commit: PROTON-1537: [ruby] Fix all
-W2 warnings in self-tests
Posted by ac...@apache.org.
PROTON-1537: [ruby] Fix all -W2 warnings in self-tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f252b2ff
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f252b2ff
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f252b2ff
Branch: refs/heads/go1
Commit: f252b2ff7fb17783bbdf5167d542ee722cc48bbd
Parents: 1e256cf
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Dec 14 14:59:29 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 09:59:47 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/codec/data.rb | 2 +-
proton-c/bindings/ruby/lib/core/connection.rb | 7 +-----
proton-c/bindings/ruby/lib/core/container.rb | 3 +++
proton-c/bindings/ruby/lib/core/delivery.rb | 18 ++++++++------
proton-c/bindings/ruby/lib/core/event.rb | 11 ++++-----
proton-c/bindings/ruby/lib/core/sender.rb | 6 ++---
proton-c/bindings/ruby/lib/core/ssl.rb | 4 ---
proton-c/bindings/ruby/lib/core/ssl_domain.rb | 10 +++-----
proton-c/bindings/ruby/lib/core/terminus.rb | 8 +++---
proton-c/bindings/ruby/lib/core/transfer.rb | 1 +
proton-c/bindings/ruby/lib/core/transport.rb | 10 ++++----
proton-c/bindings/ruby/lib/core/url.rb | 1 -
.../bindings/ruby/lib/messenger/messenger.rb | 11 ++++-----
proton-c/bindings/ruby/lib/util/deprecation.rb | 2 +-
.../bindings/ruby/lib/util/error_handler.rb | 26 +++-----------------
15 files changed, 45 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 1573b5c..ec74756 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -75,7 +75,7 @@ module Qpid::Proton
}
end
- proton_caller :clear, :rewind, :next, :prev, :enter, :exit, :type
+ proton_caller :clear, :rewind, :next, :prev, :enter, :exit
def enter_exit()
enter
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 2b97f41..b9b5746 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -146,11 +146,6 @@ module Qpid::Proton
end
end
- # @private Generate a unique link name, internal use only.
- def link_name()
- @link_prefix + "/" + (@link_count += 1).to_s(16)
- end
-
# Closes the local end of the connection. The remote end may or may not be closed.
# @param error [Condition] Optional error condition to send with the close.
def close(error=nil)
@@ -259,7 +254,7 @@ module Qpid::Proton
# @private Generate a unique link name, internal use only.
def link_name()
- @link_prefix + "/" + (@link_count += 1).to_s(16)
+ @link_prefix + "/" + (@link_count += 1).to_s(32)
end
protected
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 f8c8c16..242356f 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -45,9 +45,12 @@ module Qpid::Proton
def initialize(io, handler, container)
super
+ @closing = @closed = nil
env = ENV['PN_TRACE_EVT']
if env && ["true", "1", "yes", "on"].include?(env.downcase)
@log_prefix = "[0x#{object_id.to_s(16)}](PN_LISTENER_"
+ else
+ @log_prefix = nil
end
dispatch(:on_open);
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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
index fd5c43a..cedce98 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -18,6 +18,8 @@
module Qpid::Proton
# Allow a {Receiver} to indicate the status of a received message to the {Sender}
class Delivery < Transfer
+ def initialize(*args) super; @message = nil; end
+
# @return [Receiver] The parent {Receiver} link.
def receiver() link; end
@@ -80,15 +82,15 @@ module Qpid::Proton
# @raise [UnderflowError] if the message is incomplete (check with {#complete?}
# @raise [::ArgumentError] if the delivery is not the current delivery on a receiving link.
def message
- return @message if @message
- raise AbortedError, "message aborted by sender" if aborted?
- raise UnderflowError, "incoming message incomplete" if partial?
- raise ArgumentError, "no incoming message" unless readable?
- @message = Message.new
- @message.decode(link.receive(pending))
- link.advance
+ unless @message
+ raise AbortedError, "message aborted by sender" if aborted?
+ raise UnderflowError, "incoming message incomplete" if partial?
+ raise ArgumentError, "no incoming message" unless readable?
+ @message = Message.new
+ @message.decode(link.receive(pending))
+ link.advance
+ end
@message
end
-
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb b/proton-c/bindings/ruby/lib/core/event.rb
index ee0fc02..d75cfff 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -125,12 +125,11 @@ module Qpid::Proton
# @return [Delivery, nil] delivery for this event
def delivery()
- return @delivery if @delivery
- case context
- when Delivery then @delivery = @context
- # deprecated: for backwards compat allow a Tracker to be treated as a Delivery
- when Tracker then @delivery = Delivery.new(context.impl)
- end
+ @delivery ||= case context
+ when Delivery then @delivery = @context
+ # deprecated: for backwards compat allow a Tracker to be treated as a Delivery
+ when Tracker then @delivery = Delivery.new(context.impl)
+ end
end
# @return [Tracker, nil] delivery for this event
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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
index 4c7324c..c1ba1f8 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -27,9 +27,6 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
- # @private
- can_raise_error :stream, :error_class => Qpid::Proton::LinkError
-
# Hint to the remote receiver about the number of messages available.
# The receiver may use this to optimize credit flow, or may ignore it.
# @param n [Integer] The number of deliveries potentially available.
@@ -71,6 +68,9 @@ module Qpid::Proton
def initialize(*arg) super; @tag_count = 0; end
def next_tag() (@tag_count += 1).to_s(32); end
+
+ # @private
+ can_raise_error :stream, :error_class => Qpid::Proton::LinkError
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 ec4f14d..bc4460a 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -66,8 +66,6 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
- can_raise_error :peer_hostname=, :error_class => SSLError
-
# Returns whether SSL is supported.
#
# @return [Boolean] True if SSL support is available.
@@ -155,7 +153,5 @@ module Qpid::Proton
raise SSLError.new if error < 0
return name
end
-
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/ssl_domain.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl_domain.rb b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
index 2a3940d..31a472f 100644
--- a/proton-c/bindings/ruby/lib/core/ssl_domain.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
@@ -42,11 +42,6 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
- can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
- can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
- can_raise_error :peer_authentication, :error_class => Qpid::Proton::SSLError
- can_raise_error :allow_unsecured_client, :error_class => Qpid::Proton::SSLError
-
# @private
attr_reader :impl
@@ -150,6 +145,9 @@ module Qpid::Proton
Cproton.pn_ssl_domain_allow_unsecured_client(@impl);
end
+ can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
+ can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
+ can_raise_error :peer_authentication, :error_class => Qpid::Proton::SSLError
+ can_raise_error :allow_unsecured_client, :error_class => Qpid::Proton::SSLError
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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
index 82ac9f7..d3181db 100644
--- a/proton-c/bindings/ruby/lib/core/terminus.rb
+++ b/proton-c/bindings/ruby/lib/core/terminus.rb
@@ -131,10 +131,6 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
- can_raise_error [:type=, :address=, :durability=, :expiry_policy=,
- :timeout=, :dynamic=, :distribution_mode=, :copy],
- :error_class => Qpid::Proton::LinkError
-
# @private
attr_reader :impl
@@ -211,6 +207,8 @@ module Qpid::Proton
Cproton.pn_terminus_copy(@impl,source.impl)
end
+ can_raise_error([:type=, :address=, :durability=, :expiry_policy=,
+ :timeout=, :dynamic=, :distribution_mode=, :copy],
+ :error_class => Qpid::Proton::LinkError)
end
-
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb b/proton-c/bindings/ruby/lib/core/transfer.rb
index 17f3b82..4fc21a9 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -36,6 +36,7 @@ module Qpid::Proton
def initialize(impl)
@impl = impl
+ @inspect = nil
self.class.store_instance(self, :pn_delivery_attachments)
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 64a8011..9b36335 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -201,11 +201,6 @@ module Qpid::Proton
# @private
include Util::ErrorHandler
- can_raise_error :process, :error_class => TransportError
- can_raise_error :close_tail, :error_class => TransportError
- can_raise_error :pending, :error_class => TransportError, :below => Error::EOS
- can_raise_error :close_head, :error_class => TransportError
-
# @private
def self.wrap(impl)
return nil if impl.nil?
@@ -413,5 +408,10 @@ module Qpid::Proton
# Direct use of the transport is deprecated.
self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? :idle_timeout
end
+
+ can_raise_error :process, :error_class => TransportError
+ can_raise_error :close_tail, :error_class => TransportError
+ can_raise_error :pending, :error_class => TransportError, :below => Error::EOS
+ can_raise_error :close_head, :error_class => TransportError
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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
index 1103e06..4fa59b6 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -27,7 +27,6 @@ module Qpid::Proton
alias user username
attr_reader :password
attr_reader :host
- attr_reader :port
attr_reader :path
# Parse a string, return a new URL
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index 7b992e2..912d159 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -58,11 +58,6 @@ module Qpid::Proton::Messenger
include Qpid::Proton::Util::ErrorHandler
include Qpid::Proton::Util::Deprecation
- can_raise_error [: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
@@ -699,6 +694,10 @@ module Qpid::Proton::Messenger
!window.nil? && window.is_a?(Numeric)
end
- end
+ can_raise_error [:send, :receive, :password=, :start, :stop,
+ :perform_put, :perform_get, :interrupt,
+ :route, :rewrite, :accept, :reject,
+ :incoming_window=, :outgoing_window=]
+ end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
index 8e96cd6..d9d0563 100644
--- a/proton-c/bindings/ruby/lib/util/deprecation.rb
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -39,7 +39,7 @@ module Qpid::Proton::Util
end
def self.included(other)
- other.__send__ :extend, ClassMethods
+ other.extend ClassMethods
end
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/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 58545fb..9280fb0 100644
--- a/proton-c/bindings/ruby/lib/util/error_handler.rb
+++ b/proton-c/bindings/ruby/lib/util/error_handler.rb
@@ -23,35 +23,15 @@ module Qpid::Proton::Util
# @private
module ErrorHandler
- def self.included(base)
- base.extend(self)
-
- unless defined? base.to_be_wrapped
- class << base
- @@to_be_wrapped = []
- end
- end
-
- define_method :method_added do |name|
- if (!@@to_be_wrapped.nil?) && (@@to_be_wrapped.include? name)
- @@to_be_wrapped.delete name
- create_exception_handler_wrapper(name)
- end
- end
- end
+ def self.included(other) other.extend(self); end
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
- unless self.method_defined? method_name
- @@to_be_wrapped ||= []
- @@to_be_wrapped << method_name
- else
- create_exception_handler_wrapper(method_name, error_class, below)
- end
+ raise "missing method #{method_name.inspect}" unless method_defined?(method_name) || private_method_defined?(method_name)
+ create_exception_handler_wrapper(method_name, error_class, below)
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[34/50] [abbrv] qpid-proton git commit: PROTON-1720: [ruby] Add
missing connection options, update Connection API.
Posted by ac...@apache.org.
PROTON-1720: [ruby] Add missing connection options, update Connection API.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/055f3dc6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/055f3dc6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/055f3dc6
Branch: refs/heads/go1
Commit: 055f3dc6b94332c353bf3e93aa7318209a2d9e6d
Parents: c4d5fde
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 15 16:53:30 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 17:37:05 2017 -0500
----------------------------------------------------------------------
examples/ruby/server.rb | 4 +-
proton-c/bindings/ruby/lib/core/connection.rb | 121 +++++++++++--------
.../bindings/ruby/lib/core/connection_driver.rb | 1 -
proton-c/bindings/ruby/lib/core/container.rb | 3 +-
proton-c/bindings/ruby/lib/core/message.rb | 6 +-
proton-c/bindings/ruby/lib/core/transport.rb | 54 ++-------
proton-c/bindings/ruby/lib/reactor/container.rb | 2 +-
proton-c/bindings/ruby/lib/types/array.rb | 6 +-
proton-c/bindings/ruby/lib/types/hash.rb | 13 +-
proton-c/bindings/ruby/lib/util/deprecation.rb | 7 +-
.../bindings/ruby/tests/old_examples/server.rb | 4 +-
proton-c/bindings/ruby/tests/test_container.rb | 63 +++++++++-
12 files changed, 171 insertions(+), 113 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/examples/ruby/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/server.rb b/examples/ruby/server.rb
index 7a4832b..7538d61 100644
--- a/examples/ruby/server.rb
+++ b/examples/ruby/server.rb
@@ -36,8 +36,8 @@ class Server < Qpid::Proton::MessagingHandler
end
def on_connection_open(connection)
- if connection.remote_offered_capabilities &&
- connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
+ if connection.offered_capabilities &&
+ connection.offered_capabilities.contain?("ANONYMOUS-RELAY")
@relay = connection.open_sender({:target => nil})
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 b9b5746..f9a80a7 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -20,32 +20,17 @@ module Qpid::Proton
# An AMQP connection.
class Connection < Endpoint
- include Util::Deprecation
-
- # @private
PROTON_METHOD_PREFIX = "pn_connection"
- # @private
include Util::Wrapper
+ include Util::Deprecation
- # @!attribute hostname
- # @return [String] The AMQP hostname for the connection.
- proton_set_get :hostname
-
- # @!attribute user
- # @return [String] User name used for authentication (outgoing connection) or the authenticated user name (incoming connection)
- proton_set_get :user
-
- private
-
- proton_set :password
- attr_accessor :overrides
- attr_accessor :session_policy
-
+ # @private
def self.wrap(impl)
return nil if impl.nil?
self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl)
end
+ # @private
def initialize(impl = Cproton.pn_connection)
super()
@impl = impl
@@ -56,7 +41,19 @@ module Qpid::Proton
self.class.store_instance(self, :pn_connection_attachments)
end
- public
+ # @return [String] The AMQP hostname for the connection.
+ def virtual_host() Cproton.pn_connection_remote_hostname(@impl); end
+ deprecated_alias :remote_hostname, :virtual_host
+
+ # @!attribute hostname
+ # @deprecated use {#virtual_host}
+ proton_set_get :hostname
+
+ # @return [String] User name used for authentication (outgoing connection)
+ # or the authenticated user name (incoming connection)
+ def user()
+ Cproton.pn_connection_get_user(impl) or (connection.transport && connection.transport.user)
+ end
# @deprecated no replacement
def overrides?() deprecated __method__; false; end
@@ -68,49 +65,54 @@ module Qpid::Proton
def connection() self; end
# @return [Transport, nil] transport bound to this connection, or nil if unbound.
- #
def transport() Transport.wrap(Cproton.pn_connection_transport(@impl)); end
- # @return AMQP container ID advertised by the remote peer
- def remote_container_id() Cproton.pn_connection_remote_container(@impl); end
-
- alias remote_container remote_container_id
+ # @return AMQP container ID advertised by the remote peer.
+ # To get the local container ID use {#container} and {Container#id}
+ def container_id() Cproton.pn_connection_remote_container(@impl); end
+ deprecated_alias :remote_container, :container_id
# @return [Container] the container managing this connection
attr_reader :container
- # @return AMQP container ID for the local end of the connection
- def container_id() Cproton.pn_connection_get_container(@impl); end
-
- # @return [String] hostname used by the remote end of the connection
- def remote_hostname() Cproton.pn_connection_remote_hostname(@impl); end
-
# @return [Array<Symbol>] offered capabilities provided by the remote peer
- def remote_offered_capabilities
+ def offered_capabilities
Codec::Data.to_object(Cproton.pn_connection_remote_offered_capabilities(@impl))
end
+ deprecated_alias :remote_offered_capabilities, :offered_capabilities
# @return [Array<Symbol>] desired capabilities provided by the remote peer
- def remote_desired_capabilities
+ def desired_capabilities
Codec::Data.to_object(Cproton.pn_connection_remote_desired_capabilities(@impl))
end
+ deprecated_alias :remote_desired_capabilities, :desired_capabilities
# @return [Hash] connection-properties provided by the remote peer
- def remote_properties
- Codec::Data.to_object(Cproton.pn_connection_remote_properites(@impl))
+ def properties
+ Codec::Data.to_object(Cproton.pn_connection_remote_properties(@impl))
end
+ deprecated_alias :remote_properties, :properties
# Open the local end of the connection.
#
# @option opts [MessagingHandler] :handler handler for events related to this connection.
- # @option opts [String] :user user-name for authentication.
- # @option opts [String] :password password for authentication.
- # @option opts [Numeric] :idle_timeout seconds before closing an idle connection
- # @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.
- # @option opts [String] :sasl_allowed_mechs the allowed SASL mechanisms for use on the connection.
- # @option opts [String] :container_id AMQP container ID, normally provided by {Container}
+ #
+ # @option opts [String] :user User name for authentication
+ # @option opts [String] :password Authentication secret
+ # @option opts [String] :virtual_host Virtual host name
+ # @option opts [String] :container_id (provided by {Container}) override advertised container-id
+ #
+ # @option opts [Hash<Symbol=>Object>] :properties Application-defined properties
+ # @option opts [Array<Symbol>] :offered_capabilities Extensions the endpoint supports
+ # @option opts [Array<Symbol>] :desired_capabilities Extensions the endpoint can use
+ #
+ # @option opts [Numeric] :idle_timeout Seconds before closing an idle connection
+ # @option opts [Integer] :max_sessions Limit the number of active sessions
+ # @option opts [Integer] :max_frame_size Limit the size of AMQP frames
+ #
+ # @option opts [Boolean] :sasl_enabled (false) Enable or disable SASL.
+ # @option opts [Boolean] :sasl_allow_insecure_mechs (false) Allow mechanisms send secrets in clear text
+ # @option opts [String] :sasl_allowed_mechs SASL mechanisms allowed by this end of the connection
#
def open(opts=nil)
return if local_active?
@@ -129,23 +131,44 @@ module Qpid::Proton
Cproton.pn_connection_set_container(@impl, cid)
Cproton.pn_connection_set_user(@impl, opts[:user]) if opts[:user]
Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password]
- @link_prefix = opts[:link_prefix] || container_id
- Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl), opts[:offered_capabilities])
- Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl), opts[:desired_capabilities])
- Codec::Data.from_object(Cproton.pn_connection_properties(@impl), opts[:properties])
+ Cproton.pn_connection_set_hostname(@impl, opts[:virtual_host]) if opts[:virtual_host]
+ @link_prefix = opts[:link_prefix] || cid
+ Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl),
+ Types.symbol_array(opts[:offered_capabilities]))
+ Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl),
+ Types.symbol_array(opts[:desired_capabilities]))
+ Codec::Data.from_object(Cproton.pn_connection_properties(@impl),
+ Types.symbol_keys(opts[:properties]))
end
# Idle-timeout advertised by the remote peer, in seconds.
- # Set by {Connection#open} with the +:idle_timeout+ option.
# @return [Numeric] Idle-timeout advertised by the remote peer, in seconds.
- # @return [nil] if The peer does not advertise an idle time-out
- # @option :idle_timeout (see {#open})
+ # @return [nil] if the peer does not advertise an idle time-out
def idle_timeout()
if transport && (t = transport.remote_idle_timeout)
Rational(t, 1000) # More precise than Float
end
end
+ # Session limit advertised by the remote peer. See {Connection#open :max_sessions}
+ # @return [Integer] maximum number of sessions per connection allowed by remote peer.
+ # @return [nil] no specific limit is set.
+ def max_sessions()
+ raise StateError, "connection not bound to transport" unless transport
+ max = transport.remote_channel_max
+ return max.zero? ? nil : max
+ end
+
+ # Maximum frame size, in bytes, advertised by the remote peer.
+ # See {Connection#open :max_frame_size}
+ # @return [Integer] maximum frame size
+ # @return [nil] no limit
+ def max_frame_size()
+ raise StateError, "connection not bound to transport" unless transport
+ max = transport.remote_max_frame
+ return max.zero? ? nil : max
+ end
+
# Closes the local end of the connection. The remote end may or may not be closed.
# @param error [Condition] Optional error condition to send with the close.
def close(error=nil)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index 2ce132e..12dcb68 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -181,7 +181,6 @@ module Qpid::Proton
case e.method # Events that affect the driver
when :on_transport_tail_closed then close_read
when :on_transport_head_closed then close_write
- when :on_transport_authenticated then connection.user = transport.user
end
e.dispatch @adapter
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 5dc9d60..9d9463e 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -125,7 +125,8 @@ module Qpid::Proton
@handler = args[0] unless @id
else raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..2"
end
- @adapter = Handler::Adapter.adapt(@handler)
+ # Use an empty messaging adapter to give default behaviour if there's no global handler.
+ @adapter = Handler::Adapter.adapt(@handler) || Handler::MessagingAdapter.new(nil)
@id = (@id || SecureRandom.uuid).freeze
# Implementation note:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 8b13de2..9afaa0a 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -73,8 +73,10 @@ module Qpid::Proton
# @private
def pre_encode
# encode elements from the message
- Codec::Data.from_object(Cproton::pn_message_properties(@impl), !@properties.empty? && @properties)
- Codec::Data.from_object(Cproton::pn_message_instructions(@impl), !@instructions.empty? && @instructions)
+ Codec::Data.from_object(Cproton::pn_message_properties(@impl),
+ !@properties.empty? && Types.symbol_keys!(@properties))
+ Codec::Data.from_object(Cproton::pn_message_instructions(@impl),
+ !@instructions.empty? && Types.symbol_keys!(@instructions))
if @annotations # Make sure keys are symbols
@annotations.keys.each do |k|
@annotations[k.to_sym] = @annotations.delete(k) unless k.is_a? Symbol
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 9b36335..eb5fb01 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -18,49 +18,7 @@
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
- #
+ # @deprecated all important features are available from {#Connection}
class Transport
include Util::Deprecation
@@ -78,6 +36,7 @@ module Qpid::Proton
# Log driver related events; i.e., initialization, end of stream, etc.
TRACE_DRV = Cproton::PN_TRACE_DRV
+ proton_get :user
# @!attribute channel_max
#
@@ -94,8 +53,8 @@ module Qpid::Proton
# @!attribute max_frame_size
#
# @return [Integer] The maximum frame size.
- #
- proton_set_get :max_frame_size
+ proton_set_get :max_frame
+ proton_get :remote_max_frame
# @!attribute [r] remote_max_frame_size
#
@@ -394,14 +353,15 @@ module Qpid::Proton
end
# @private
+ # Options are documented {Connection#open}, keep that consistent with this
def apply opts
sasl if opts[:sasl_enabled] # Explicitly enabled
unless opts.include?(:sasl_enabled) && !opts[:sasl_enabled] # Not explicitly disabled
sasl.allowed_mechs = opts[:sasl_allowed_mechs] if opts.include? :sasl_allowed_mechs
sasl.allow_insecure_mechs = opts[:sasl_allow_insecure_mechs] if opts.include? :sasl_allow_insecure_mechs
end
- self.channel_max= opts[:channel_max] if opts.include? :channel_max
- self.max_frame_size= opts[:max_frame_size] if opts.include? :max_frame_size
+ self.channel_max= opts[:max_sessions] if opts.include? :max_sessions
+ self.max_frame = opts[:max_frame_size] if opts.include? :max_frame_size
# NOTE: The idle_timeout option is in Numeric *seconds*, can be Integer, Float or Rational.
# This is consistent with idiomatic ruby.
# The transport #idle_timeout property is in *milliseconds* passed direct to C.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 22cb0e8..98c35e2 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -31,7 +31,7 @@ module Qpid::Proton
# @deprecated use {Qpid::Proton::Container}
def initialize(handlers, opts=nil)
deprecated Qpid::Proton::Reactor::Container, Qpid::Proton::Container
- h = handlers || (opts && opts[:global_handler])
+ h = handlers || (opts && opts[:global_handler]) || Handler::ReactorMessagingAdapter.new(nil)
id = opts && opts[:container_id]
super(h, id)
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/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 7a20adb..d7e15e6 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -51,7 +51,11 @@ module Qpid::Proton
@type, @descriptor = type, descriptor
raise ArgumentError, "no type specified for array" if @type.nil?
super elements if elements
- @proton_array_header = ArrayHeader.new(@type, @descriptor) # Deprecated
+ end
+
+ # @deprecated backwards compatibility {UniformArray}
+ def proton_array_header
+ @proton_array_header ||= ArrayHeader.new(@type, @descriptor) # Deprecated
end
# @return [Type] Array elements must be convertible to this AMQP type
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index 2d78f74..2702ab2 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -23,7 +23,6 @@
# @private
class Hash # :nodoc:
-
# @deprecated
def proton_data_put(data)
@@ -37,3 +36,15 @@ class Hash # :nodoc:
data.map
end
end
+
+module Qpid::Proton::Types
+ # @private
+ def self.symbol_keys(h)
+ h && h.reduce({}) { |x, (k, v)| x[k.to_sym] = v; x }
+ end
+
+ # @private
+ def self.symbol_array(a)
+ a && UniformArray.new(SYMBOL, a.collect { |v| v.to_sym })
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
index d9d0563..4980a9e 100644
--- a/proton-c/bindings/ruby/lib/util/deprecation.rb
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -20,10 +20,13 @@ module Qpid::Proton::Util
module Deprecation
MATCH_DIR = /#{File.dirname(File.dirname(__FILE__))}/
+ DEPRECATE_FULL_TRACE = false
+
def self.deprecated(old, new=nil)
replace = new ? "use `#{new}`" : "internal use only"
- line = caller.find { |l| not MATCH_DIR.match(l) }
- warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{line}"
+
+ from = DEPRECATE_FULL_TRACE ? caller(2).join("\n") : caller.find { |l| not MATCH_DIR.match(l) }
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{from}"
end
def deprecated(*arg) Deprecation.deprecated(*arg); end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/proton-c/bindings/ruby/tests/old_examples/server.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/old_examples/server.rb b/proton-c/bindings/ruby/tests/old_examples/server.rb
index 265a63d..1908c24 100644
--- a/proton-c/bindings/ruby/tests/old_examples/server.rb
+++ b/proton-c/bindings/ruby/tests/old_examples/server.rb
@@ -36,8 +36,8 @@ class Server < Qpid::Proton::Handler::MessagingHandler
end
def on_connection_opened(event)
- if event.connection.remote_offered_capabilities &&
- event.connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
+ if event.connection.offered_capabilities &&
+ event.connection.offered_capabilities.contain?("ANONYMOUS-RELAY")
@relay = @container.create_sender(@conn, nil)
end
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/055f3dc6/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index d8bd52c..82c34e2 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -75,7 +75,7 @@ class ContainerTest < Minitest::Test
end
class CloseOnOpenHandler < TestHandler
- def on_connection_open(c) c.close; end
+ def on_connection_open(c) super; c.close; end
end
def test_auto_stop_one
@@ -159,6 +159,61 @@ class ContainerTest < Minitest::Test
assert_match(/badconnect.example.com:999/, c.transport.condition.description)
end
+ # Verify that connection options are sent to the peer and available as Connection methods
+ def test_connection_options
+ # Note: user, password and sasl_xxx options are tested by ContainerSASLTest below
+ server_handler = Class.new(MessagingHandler) do
+ def on_error(e) raise e.inspect; end
+ def on_connection_open(c) @connection = c
+ c.open({
+ :virtual_host => "server.to.client",
+ :properties => { :server => :client },
+ :offered_capabilities => [ :s1 ],
+ :desired_capabilities => [ :s2 ],
+ :container_id => "box",
+ })
+ c.close
+ end
+ attr_reader :connection
+ end.new
+ # Transport options must be provided to the listener, by Connection#open it is too late
+ cont = TestContainer.new(nil, {
+ :handler => server_handler,
+ :idle_timeout => 88,
+ :max_sessions =>1000,
+ :max_frame_size => 8888,
+ })
+ client = cont.connect(cont.url,
+ {:virtual_host => "client.to.server",
+ :properties => { :foo => :bar, "str" => "str" },
+ :offered_capabilities => [:c1 ],
+ :desired_capabilities => ["c2" ],
+ :idle_timeout => 42,
+ :max_sessions =>100,
+ :max_frame_size => 4096,
+ :container_id => "bowl"
+ })
+ cont.run
+ c = server_handler.connection
+ assert_equal "client.to.server", c.virtual_host
+ assert_equal({ :foo => :bar, :str => "str" }, c.properties)
+ assert_equal([:c1], c.offered_capabilities)
+ assert_equal([:c2], c.desired_capabilities)
+ assert_equal 21, c.idle_timeout # Proton divides by 2
+ assert_equal 100, c.max_sessions
+ assert_equal 4096, c.max_frame_size
+ assert_equal "bowl", c.container_id
+
+ c = client
+ assert_equal "server.to.client", c.virtual_host
+ assert_equal({ :server => :client }, c.properties)
+ assert_equal([:s1], c.offered_capabilities)
+ assert_equal([:s2], c.desired_capabilities)
+ assert_equal "box", c.container_id
+ assert_equal 8888, c.max_frame_size
+ assert_equal 44, c.idle_timeout # Proton divides by 2
+ assert_equal 100, c.max_sessions
+ end
end
@@ -184,7 +239,7 @@ class ContainerSASLTest < Minitest::Test
if connection == @client
connection.close
else
- @auth_user = connection.transport.sasl.user
+ @auth_user = connection.user
end
end
end
@@ -231,7 +286,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
def test_sasl_anonymous()
s = SASLHandler.new("amqp://", {:sasl_allowed_mechs => "ANONYMOUS"})
TestContainer.new(s, {:sasl_allowed_mechs => "ANONYMOUS"}, __method__).run
- assert_nil(s.connections[0].user)
+ assert_equal "anonymous", s.connections[0].user
end
def test_sasl_plain_url()
@@ -239,7 +294,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
# Use default realm with URL, should authenticate with "default_password"
opts = {:sasl_allowed_mechs => "PLAIN", :sasl_allow_insecure_mechs => true}
s = SASLHandler.new("amqp://user:default_password@", opts)
- TestContainer.new(s, opts).run
+ TestContainer.new(s, opts, __method__).run
assert_equal(2, s.connections.size)
assert_equal("user", s.auth_user)
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[40/50] [abbrv] qpid-proton git commit: PROTON-1717 [C proactor] Make
changes backward compatible.
Posted by ac...@apache.org.
PROTON-1717 [C proactor] Make changes backward compatible.
Restore and deprecate original signatures for pn_proactor_connect and pn_listener_accept.
Introduce pn_proactor_connect2 and pn_listener_accept2 taking a transport parameter.
Update all examples & tests to use the un-deprecated functions.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3311dd60
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3311dd60
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3311dd60
Branch: refs/heads/go1
Commit: 3311dd602d228e960019a54128e1e6674247778f
Parents: b9f9402
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Dec 19 14:02:33 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Dec 19 14:02:33 2017 -0500
----------------------------------------------------------------------
examples/c/broker.c | 23 ++++-----
examples/c/direct.c | 2 +-
examples/c/example_test.py | 4 +-
examples/c/receive.c | 2 +-
examples/c/send-abort.c | 2 +-
examples/c/send-ssl.c | 26 +++++++---
examples/c/send.c | 2 +-
.../cpp/src/proactor_container_impl.cpp | 4 +-
proton-c/include/proton/event.h | 2 +-
proton-c/include/proton/listener.h | 17 +++++--
proton-c/include/proton/proactor.h | 11 +++--
proton-c/src/proactor/epoll.c | 6 +--
proton-c/src/proactor/libuv.c | 4 +-
proton-c/src/proactor/proactor-internal.c | 13 +++++
proton-c/src/proactor/win_iocp.c | 4 +-
proton-c/src/tests/proactor.c | 50 ++++++++++----------
16 files changed, 105 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/broker.c
----------------------------------------------------------------------
diff --git a/examples/c/broker.c b/examples/c/broker.c
index d5a3eef..c2efed8 100644
--- a/examples/c/broker.c
+++ b/examples/c/broker.c
@@ -290,26 +290,21 @@ static void handle(broker_t* b, pn_event_t* e) {
fflush(stdout);
break;
- case PN_LISTENER_ACCEPT:
- pn_listener_accept(pn_event_listener(e), NULL, NULL);
- break;
-
- case PN_CONNECTION_INIT:
- pn_connection_set_container(c, b->container_id);
- break;
-
- case PN_CONNECTION_BOUND: {
- /* Allow anonymous connections by SASL */
- pn_transport_t *t = pn_connection_transport(c);
+ case PN_LISTENER_ACCEPT: {
+ /* Configure a transport to allow SSL and SASL connections. See ssl_domain setup in main() */
+ pn_transport_t *t = pn_transport();
pn_transport_require_auth(t, false);
pn_sasl_allowed_mechs(pn_sasl(t), "ANONYMOUS");
- /* Accept SSL connections if possible, but also plain connections.
- See the call to pn_ssl_domain_allow_unsecured_client() in main() */
if (b->ssl_domain) {
- pn_ssl_init(pn_ssl(pn_event_transport(e)), b->ssl_domain, NULL);
+ pn_ssl_init(pn_ssl(t), b->ssl_domain, NULL);
}
+ pn_listener_accept2(pn_event_listener(e), NULL, t);
break;
}
+ case PN_CONNECTION_INIT:
+ pn_connection_set_container(c, b->container_id);
+ break;
+
case PN_CONNECTION_REMOTE_OPEN: {
pn_connection_open(pn_event_connection(e)); /* Complete the open */
break;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/direct.c b/examples/c/direct.c
index cf5db68..3313ab2 100644
--- a/examples/c/direct.c
+++ b/examples/c/direct.c
@@ -234,7 +234,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
break;
case PN_LISTENER_ACCEPT:
- pn_listener_accept(pn_event_listener(event), NULL, NULL);
+ pn_listener_accept2(pn_event_listener(event), NULL, NULL);
break;
case PN_CONNECTION_INIT:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/example_test.py
----------------------------------------------------------------------
diff --git a/examples/c/example_test.py b/examples/c/example_test.py
index 782728e..1e25c76 100644
--- a/examples/c/example_test.py
+++ b/examples/c/example_test.py
@@ -119,7 +119,9 @@ class CExampleTest(ProcTestCase):
def test_send_ssl_receive(self):
"""Send first then receive"""
with Broker(self) as b:
- self.assertEqual(send_expect(), self.runex("send-ssl", b.port))
+ got = self.runex("send-ssl", b.port)
+ self.assertIn("secure connection:", got)
+ self.assertIn(send_expect(), got)
self.assertMultiLineEqual(receive_expect(), self.runex("receive", b.port))
if __name__ == "__main__":
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/receive.c
----------------------------------------------------------------------
diff --git a/examples/c/receive.c b/examples/c/receive.c
index 8b25115..0d0c988 100644
--- a/examples/c/receive.c
+++ b/examples/c/receive.c
@@ -193,7 +193,7 @@ int main(int argc, char **argv) {
/* Create the proactor and connect */
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, NULL, NULL, addr);
+ pn_proactor_connect2(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
return exit_code;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/send-abort.c
----------------------------------------------------------------------
diff --git a/examples/c/send-abort.c b/examples/c/send-abort.c
index 240d459..cc88ff0 100644
--- a/examples/c/send-abort.c
+++ b/examples/c/send-abort.c
@@ -218,7 +218,7 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, NULL, NULL, addr);
+ pn_proactor_connect2(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
free(app.message_buffer.start);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/send-ssl.c
----------------------------------------------------------------------
diff --git a/examples/c/send-ssl.c b/examples/c/send-ssl.c
index cc8c6d0..5d3404c 100644
--- a/examples/c/send-ssl.c
+++ b/examples/c/send-ssl.c
@@ -126,10 +126,14 @@ static bool handle(app_data_t* app, pn_event_t* event) {
}
}
- case PN_CONNECTION_BOUND: {
- int err = pn_ssl_init(pn_ssl(pn_event_transport(event)), app->ssl_domain, NULL);
- if (err) fprintf(stderr, "error encoding message: %s\n", pn_code(err));
- break;
+ case PN_CONNECTION_REMOTE_OPEN: {
+ pn_ssl_t *ssl = pn_ssl(pn_event_transport(event));
+ if (ssl) {
+ char name[1024];
+ pn_ssl_get_protocol_name(ssl, name, sizeof(name));
+ printf("secure connection: %s\n", name);
+ fflush(stdout);
+ }
}
case PN_LINK_FLOW: {
@@ -211,7 +215,8 @@ void run(app_data_t *app) {
int main(int argc, char **argv) {
struct app_data_t app = {0};
char addr[PN_MAX_ADDR];
-
+ pn_transport_t *t = NULL;
+
app.container_id = argv[0]; /* Should be unique */
app.host = (argc > 1) ? argv[1] : "";
app.port = (argc > 2) ? argv[2] : "amqp";
@@ -221,7 +226,16 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, NULL, NULL, addr);
+
+ /* Configure a transport for SSL. The transport will be freed by the proactor. */
+ t = pn_transport();
+ int err = pn_ssl_init(pn_ssl(t), app.ssl_domain, NULL);
+ if (err) {
+ fprintf(stderr, "error initializing SSL: %s\n", pn_code(err));
+ return 1;
+ }
+ pn_proactor_connect2(app.proactor, NULL, t, addr);
+
run(&app);
pn_ssl_domain_free(app.ssl_domain);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/examples/c/send.c
----------------------------------------------------------------------
diff --git a/examples/c/send.c b/examples/c/send.c
index d667828..9e8cc4a 100644
--- a/examples/c/send.c
+++ b/examples/c/send.c
@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
app.proactor = pn_proactor();
pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
- pn_proactor_connect(app.proactor, NULL, NULL, addr);
+ pn_proactor_connect2(app.proactor, NULL, NULL, addr);
run(&app);
pn_proactor_free(app.proactor);
free(app.message_buffer.start);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index 25efde6..3e68c44 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -209,7 +209,7 @@ pn_connection_t* container::impl::make_connection_lh(
void container::impl::start_connection(const url& url, pn_connection_t *pnc) {
char caddr[PN_MAX_ADDR];
pn_proactor_addr(caddr, sizeof(caddr), url.host().c_str(), url.port().c_str());
- pn_proactor_connect(proactor_, pnc, NULL, caddr); // Takes ownership of pnc
+ pn_proactor_connect2(proactor_, pnc, NULL, caddr); // Takes ownership of pnc
}
void container::impl::reconnect(pn_connection_t* pnc) {
@@ -531,7 +531,7 @@ bool container::impl::handle(pn_event_t* event) {
cc.listener_context_ = &lc;
cc.handler = opts.handler();
cc.work_queue_ = new container::impl::connection_work_queue(*container_.impl_, c);
- pn_listener_accept(l, c, NULL);
+ pn_listener_accept2(l, c, NULL);
return false;
}
case PN_LISTENER_CLOSE: {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/include/proton/event.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/event.h b/proton-c/include/proton/event.h
index 206828b..611b65c 100644
--- a/proton-c/include/proton/event.h
+++ b/proton-c/include/proton/event.h
@@ -309,7 +309,7 @@ typedef enum {
PN_CONNECTION_WAKE,
/**
- * Indicates the listener has an incoming connection, call pn_listener_accept()
+ * Indicates the listener has an incoming connection, call pn_listener_accept2()
* to accept it.
* Events of this type point to the @ref pn_listener_t.
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/include/proton/listener.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/listener.h b/proton-c/include/proton/listener.h
index ebe3614..9ad9ecb 100644
--- a/proton-c/include/proton/listener.h
+++ b/proton-c/include/proton/listener.h
@@ -56,16 +56,25 @@ PNP_EXTERN pn_listener_t *pn_listener(void);
PNP_EXTERN void pn_listener_free(pn_listener_t *l);
/**
- * Accept an incoming connection request on @p transport bound to @p connection.
+ * Accept an incoming connection request using @p transport and @p connection,
+ * which can be configured before the call.
+ *
* Call after a @ref PN_LISTENER_ACCEPT event.
*
+ * Errors are returned as @ref PN_TRANSPORT_CLOSED events by pn_proactor_wait().
+ *
* @param[in] listener the listener
* @param[in] connection If NULL a new connection is created.
- * Memory management is the same as for pn_proactor_connect()
+ * Memory management is the same as for pn_proactor_connect2()
* @param[in] transport If NULL a new transport is created.
- * Memory management is the same as for pn_proactor_connect()
+ * Memory management is the same as for pn_proactor_connect2()
+ */
+PNP_EXTERN void pn_listener_accept2(pn_listener_t *listener, pn_connection_t *connection, pn_transport_t *transport);
+
+/**
+ * @deprecated Equivalent to pn_listener_accept2(listener, connection, NULL)
*/
-PNP_EXTERN void pn_listener_accept(pn_listener_t *listener, pn_connection_t *connection, pn_transport_t *transport);
+PNP_EXTERN void pn_listener_accept(pn_listener_t* listener, pn_connection_t *connection);
/**
* Get the error condition for a listener.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/include/proton/proactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/proactor.h b/proton-c/include/proton/proactor.h
index 1d32668..3e47d99 100644
--- a/proton-c/include/proton/proactor.h
+++ b/proton-c/include/proton/proactor.h
@@ -74,7 +74,7 @@ extern "C" {
#define PN_MAX_ADDR 1060
/**
- * Format a host:port address string for pn_proactor_connect() or pn_proactor_listen()
+ * Format a host:port address string for pn_proactor_connect2() or pn_proactor_listen2()
*
* @param[out] addr address is copied to this buffer, with trailing '\0'
* @param[in] size size of addr buffer
@@ -119,7 +119,12 @@ PNP_EXTERN void pn_proactor_free(pn_proactor_t *proactor);
* An empty port will connect to the standard AMQP port (5672).
*
*/
-PNP_EXTERN void pn_proactor_connect(pn_proactor_t *proactor, pn_connection_t *connection, pn_transport_t *transport, const char *addr);
+PNP_EXTERN void pn_proactor_connect2(pn_proactor_t *proactor, pn_connection_t *connection, pn_transport_t *transport, const char *addr);
+
+/**
+ * @deprecated Equivalent to pn_proactor_connect2(proactor, connection, NULL, addr)
+ */
+PNP_EXTERN void pn_proactor_connect(pn_proactor_t *proactor, pn_connection_t *connection, const char *addr);
/**
* Start listening for incoming connections.
@@ -250,7 +255,7 @@ PNP_EXTERN void pn_proactor_cancel_timeout(pn_proactor_t *proactor);
* and so on) remain intact, but the transport is closed and unbound. The
* proactor will not return any more events for this connection. The caller must
* call pn_connection_free(), either directly or indirectly by re-using @p
- * connection in another call to pn_proactor_connect() or pn_proactor_listen().
+ * connection in another call to pn_proactor_connect2() or pn_proactor_listen2().
*
* @note **Not thread-safe**. Call this function from a connection
* event handler.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/src/proactor/epoll.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/epoll.c b/proton-c/src/proactor/epoll.c
index ff515b1..84986f2 100644
--- a/proton-c/src/proactor/epoll.c
+++ b/proton-c/src/proactor/epoll.c
@@ -1294,7 +1294,7 @@ static bool wake_if_inactive(pn_proactor_t *p) {
return false;
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
+void pn_proactor_connect2(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
const char *err = pconnection_setup(pc, p, c, t, false, addr);
@@ -1537,7 +1537,7 @@ static void listener_begin_close(pn_listener_t* l) {
unlock(&l->rearm_mutex);
}
}
- /* Close all sockets waiting for a pn_listener_accept() */
+ /* Close all sockets waiting for a pn_listener_accept2() */
if (l->unclaimed) l->pending_count++;
acceptor_t *a = listener_list_next(&l->pending_acceptors);
while (a) {
@@ -1697,7 +1697,7 @@ pn_record_t *pn_listener_attachments(pn_listener_t *l) {
return l->attachments;
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
+void pn_listener_accept2(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
const char *err = pconnection_setup(pc, pn_listener_proactor(l), c, t, true, "");
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 6f13040..7be83fe 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -1115,7 +1115,7 @@ void pn_proactor_cancel_timeout(pn_proactor_t *p) {
uv_mutex_unlock(&p->lock);
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
+void pn_proactor_connect2(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
pconnection_t *pc = pconnection(p, c, t, false);
assert(pc); /* TODO aconway 2017-03-31: memory safety */
pn_connection_open(pc->driver.connection); /* Auto-open */
@@ -1270,7 +1270,7 @@ pn_record_t *pn_listener_attachments(pn_listener_t *l) {
return l->attachments;
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
+void pn_listener_accept2(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
uv_mutex_lock(&l->lock);
pconnection_t *pc = pconnection(l->work.proactor, c, t, true);
assert(pc);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/src/proactor/proactor-internal.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/proactor-internal.c b/proton-c/src/proactor/proactor-internal.c
index d870e77..f3f834a 100644
--- a/proton-c/src/proactor/proactor-internal.c
+++ b/proton-c/src/proactor/proactor-internal.c
@@ -22,6 +22,7 @@
#include "proactor-internal.h"
#include <proton/error.h>
+#include <proton/listener.h>
#include <proton/proactor.h>
#include <stdio.h>
@@ -83,3 +84,15 @@ void pni_proactor_set_cond(
msg, what, nonull(host), nonull(port));
}
}
+
+// Backwards compatibility signatures.
+
+void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr) {
+ pn_proactor_connect2(p, c, NULL, addr);
+}
+
+void pn_listener_accept(pn_listener_t *l, pn_connection_t *c) {
+ pn_listener_accept2(l, c, NULL);
+}
+
+
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index 679b045..0be4b51 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -2715,7 +2715,7 @@ static void connect_step_done(pconnection_t *pc, connect_result_t *result) {
}
}
-void pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
+void pn_proactor_connect2(pn_proactor_t *p, pn_connection_t *c, pn_transport_t *t, const char *addr) {
pconnection_t *pc = (pconnection_t*) pn_class_new(&pconnection_class, sizeof(pconnection_t));
assert(pc); // TODO: memory safety
const char *err = pconnection_setup(pc, p, c, t, false, addr);
@@ -3156,7 +3156,7 @@ static void recycle_result(accept_result_t *accept_result) {
}
}
-void pn_listener_accept(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
+void pn_listener_accept2(pn_listener_t *l, pn_connection_t *c, pn_transport_t *t) {
accept_result_t *accept_result = NULL;
DWORD err = 0;
psocket_t *ps = NULL;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3311dd60/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index 332a73a..844cf95 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -207,7 +207,7 @@ static pn_event_type_t common_handler(test_handler_t *th, pn_event_t *e) {
case PN_LISTENER_ACCEPT:
last_accepted = pn_connection();
- pn_listener_accept(l, last_accepted, NULL);
+ pn_listener_accept2(l, last_accepted, NULL);
pn_listener_close(l); /* Only accept one connection */
return PN_EVENT_NONE;
@@ -257,7 +257,7 @@ static pn_event_type_t listen_handler(test_handler_t *th, pn_event_t *e) {
case PN_LISTENER_ACCEPT:
/* No automatic listener close/free for tests that accept multiple connections */
last_accepted = pn_connection();
- pn_listener_accept(pn_event_listener(e), last_accepted, NULL);
+ pn_listener_accept2(pn_event_listener(e), last_accepted, NULL);
/* No automatic close */
return PN_EVENT_NONE;
@@ -285,7 +285,7 @@ static void test_client_server(test_t *t) {
test_proactor_t tps[] ={ test_proactor(t, open_close_handler), test_proactor(t, common_handler) };
test_listener_t l = test_listen(&tps[1], localhost);
/* Connect and wait for close at both ends */
- pn_proactor_connect(tps[0].proactor, NULL, NULL, l.port.host_port);
+ pn_proactor_connect2(tps[0].proactor, NULL, NULL, l.port.host_port);
TEST_PROACTORS_RUN_UNTIL(tps, PN_TRANSPORT_CLOSED);
TEST_PROACTORS_RUN_UNTIL(tps, PN_TRANSPORT_CLOSED);
TEST_PROACTORS_DESTROY(tps);
@@ -312,7 +312,7 @@ static void test_connection_wake(test_t *t) {
pn_connection_t *c = pn_connection();
pn_incref(c); /* Keep a reference for wake() after free */
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_CHECK(t, pn_proactor_get(client) == NULL); /* Should be idle */
pn_connection_wake(c);
@@ -325,7 +325,7 @@ static void test_connection_wake(test_t *t) {
/* Verify we don't get a wake after close even if they happen together */
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c2, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c2);
pn_proactor_disconnect(client, NULL);
@@ -361,7 +361,7 @@ static void test_abort(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_abort_handler) };
pn_proactor_t *client = tps[0].proactor;
test_listener_t l = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, NULL, NULL, l.port.host_port);
+ pn_proactor_connect2(client, NULL, NULL, l.port.host_port);
/* server transport closes */
if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps))) {
@@ -420,7 +420,7 @@ static void test_refuse(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, open_close_handler), test_proactor(t, listen_refuse_handler) };
pn_proactor_t *client = tps[0].proactor;
test_listener_t l = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, NULL, NULL, l.port.host_port);
+ pn_proactor_connect2(client, NULL, NULL, l.port.host_port);
/* client transport closes */
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps)); /* client */
@@ -458,7 +458,7 @@ static void test_inactive(test_t *t) {
/* Listen, connect, disconnect */
test_listener_t l = test_listen(&tps[1], localhost);
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_WAKE, TEST_PROACTORS_RUN(tps));
@@ -475,7 +475,7 @@ static void test_inactive(test_t *t) {
/* Connect, set-timer, disconnect */
pn_proactor_set_timeout(client, 1000000);
c = pn_connection();
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_wake(c);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_WAKE, TEST_PROACTORS_RUN(tps));
@@ -503,7 +503,7 @@ static void test_errors(test_t *t) {
/* Invalid connect/listen service name */
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, NULL, "127.0.0.1:xxx");
+ pn_proactor_connect2(client, c, NULL, "127.0.0.1:xxx");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, "xxx", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -516,7 +516,7 @@ static void test_errors(test_t *t) {
/* Invalid connect/listen host name */
c = pn_connection();
- pn_proactor_connect(client, c, NULL, "nosuch.example.com:");
+ pn_proactor_connect2(client, c, NULL, "nosuch.example.com:");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, "nosuch", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -544,7 +544,7 @@ static void test_errors(test_t *t) {
/* Connect with no listener */
c = pn_connection();
- pn_proactor_connect(client, c, NULL, port.host_port);
+ pn_proactor_connect2(client, c, NULL, port.host_port);
if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps))) {
TEST_COND_DESC(t, "refused", last_condition);
TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, TEST_PROACTORS_RUN(tps));
@@ -573,7 +573,7 @@ static pn_event_type_t transport_close_connection_handler(test_handler_t *th, pn
*/
static void test_proton_1586(test_t *t) {
test_proactor_t tps[] = { test_proactor(t, transport_close_connection_handler) };
- pn_proactor_connect(tps[0].proactor, NULL, NULL, ":yyy");
+ pn_proactor_connect2(tps[0].proactor, NULL, NULL, ":yyy");
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_DESC(t, ":yyy", last_condition);
test_handler_clear(&tps[0].handler, 0); /* Clear events */
@@ -598,7 +598,7 @@ static void test_ipv4_ipv6(test_t *t) {
TEST_PROACTORS_DRAIN(tps);
#define EXPECT_CONNECT(TP, HOST) do { \
- pn_proactor_connect(client, NULL, NULL, test_port_use_host(&(TP), (HOST))); \
+ pn_proactor_connect2(client, NULL, NULL, test_port_use_host(&(TP), (HOST))); \
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps)); \
TEST_COND_EMPTY(t, last_condition); \
TEST_PROACTORS_DRAIN(tps); \
@@ -645,12 +645,12 @@ static void test_release_free(test_t *t) {
test_listener_t l = test_listen(&tps[1], localhost);
/* leave one connection to the proactor */
- pn_proactor_connect(client, NULL, NULL, l.port.host_port);
+ pn_proactor_connect2(client, NULL, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
/* release c1 and free immediately */
pn_connection_t *c1 = pn_connection();
- pn_proactor_connect(client, c1, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c1, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_release_connection(c1); /* We free but socket should still be cleaned up */
pn_connection_free(c1);
@@ -659,7 +659,7 @@ static void test_release_free(test_t *t) {
/* release c2 and but don't free till after proactor free */
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c2, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_release_connection(c2);
TEST_CHECK(t, pn_proactor_get(client) == NULL); /* Should be idle */
@@ -750,7 +750,7 @@ static void test_ssl(test_t *t) {
test_listener_t l = test_listen(server, localhost);
/* Basic SSL connection */
- pn_proactor_connect(client->proactor, NULL, NULL, l.port.host_port);
+ pn_proactor_connect2(client->proactor, NULL, NULL, l.port.host_port);
/* Open ok at both ends */
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_COND_EMPTY(t, last_condition);
@@ -764,7 +764,7 @@ static void test_ssl(test_t *t) {
TEST_INT_EQUAL(t, 0, pn_ssl_domain_set_peer_authentication(cd, PN_SSL_VERIFY_PEER_NAME, NULL));
pn_connection_t *c = pn_connection();
pn_connection_set_hostname(c, "test_server");
- pn_proactor_connect(client->proactor, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client->proactor, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_COND_EMPTY(t, last_condition);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
@@ -775,7 +775,7 @@ static void test_ssl(test_t *t) {
/* Verify peer with bad hostname */
c = pn_connection();
pn_connection_set_hostname(c, "wrongname");
- pn_proactor_connect(client->proactor, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client->proactor, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, TEST_PROACTORS_RUN(tps));
TEST_COND_NAME(t, "amqp:connection:framing-error", last_condition);
TEST_COND_DESC(t, "SSL", last_condition);
@@ -854,7 +854,7 @@ static void test_netaddr(test_t *t) {
/* Use IPv4 to get consistent results all platforms */
test_listener_t l = test_listen(&tps[1], "127.0.0.1");
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
if (!TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps))) {
TEST_COND_EMPTY(t, last_condition); /* Show the last condition */
return; /* don't continue if connection is closed */
@@ -910,10 +910,10 @@ static void test_disconnect(test_t *t) {
/* Only wait for one connection to remote-open before disconnect */
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_connection_t *c2 = pn_connection();
- pn_proactor_connect(client, c2, NULL, l2.port.host_port);
+ pn_proactor_connect2(client, c2, NULL, l2.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
TEST_PROACTORS_DRAIN(tps);
@@ -945,7 +945,7 @@ static void test_disconnect(test_t *t) {
/* Make sure the proactors are still functional */
test_listener_t l3 = test_listen(&tps[1], localhost);
- pn_proactor_connect(client, NULL, NULL, l3.port.host_port);
+ pn_proactor_connect2(client, NULL, NULL, l3.port.host_port);
TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, TEST_PROACTORS_RUN(tps));
pn_proactor_disconnect(client, NULL);
@@ -1042,7 +1042,7 @@ static void test_message_stream(test_t *t) {
pn_message_free(m);
pn_connection_t *c = pn_connection();
- pn_proactor_connect(client, c, NULL, l.port.host_port);
+ pn_proactor_connect2(client, c, NULL, l.port.host_port);
pn_session_t *ssn = pn_session(c);
pn_session_open(ssn);
pn_link_t *snd = pn_sender(ssn, "x");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[41/50] [abbrv] qpid-proton git commit: PROTON-1669: bump the .so
minor versions
Posted by ac...@apache.org.
PROTON-1669: bump the .so minor versions
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5e4242c2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5e4242c2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5e4242c2
Branch: refs/heads/go1
Commit: 5e4242c29663f2398219d1c21d93789ef2870c27
Parents: 3311dd6
Author: Robbie Gemmell <ro...@apache.org>
Authored: Tue Dec 19 19:36:32 2017 +0000
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Tue Dec 19 19:36:32 2017 +0000
----------------------------------------------------------------------
proton-c/versions.cmake | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5e4242c2/proton-c/versions.cmake
----------------------------------------------------------------------
diff --git a/proton-c/versions.cmake b/proton-c/versions.cmake
index cfa7253..da4d676 100644
--- a/proton-c/versions.cmake
+++ b/proton-c/versions.cmake
@@ -1,19 +1,19 @@
set(PN_LIB_CORE_MAJOR_VERSION 10)
-set(PN_LIB_CORE_MINOR_VERSION 1)
+set(PN_LIB_CORE_MINOR_VERSION 2)
set(PN_LIB_CORE_PATCH_VERSION 0)
set(PN_LIB_CORE_VERSION "${PN_LIB_CORE_MAJOR_VERSION}.${PN_LIB_CORE_MINOR_VERSION}.${PN_LIB_CORE_PATCH_VERSION}")
set(PN_LIB_PROACTOR_MAJOR_VERSION 1)
-set(PN_LIB_PROACTOR_MINOR_VERSION 0)
+set(PN_LIB_PROACTOR_MINOR_VERSION 1)
set(PN_LIB_PROACTOR_PATCH_VERSION 0)
set(PN_LIB_PROACTOR_VERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}.${PN_LIB_PROACTOR_MINOR_VERSION}.${PN_LIB_PROACTOR_PATCH_VERSION}")
set(PN_LIB_LEGACY_MAJOR_VERSION 11)
-set(PN_LIB_LEGACY_MINOR_VERSION 0)
+set(PN_LIB_LEGACY_MINOR_VERSION 1)
set(PN_LIB_LEGACY_PATCH_VERSION 0)
set(PN_LIB_LEGACY_VERSION "${PN_LIB_LEGACY_MAJOR_VERSION}.${PN_LIB_LEGACY_MINOR_VERSION}.${PN_LIB_LEGACY_PATCH_VERSION}")
set(PN_LIB_CPP_MAJOR_VERSION 11)
-set(PN_LIB_CPP_MINOR_VERSION 0)
+set(PN_LIB_CPP_MINOR_VERSION 1)
set(PN_LIB_CPP_PATCH_VERSION 0)
set(PN_LIB_CPP_VERSION "${PN_LIB_CPP_MAJOR_VERSION}.${PN_LIB_CPP_MINOR_VERSION}.${PN_LIB_CPP_PATCH_VERSION}")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[13/50] [abbrv] qpid-proton git commit: PROTON-1651: Fix typos found
by way of spell check (Thanks, Jiri)
Posted by ac...@apache.org.
PROTON-1651: Fix typos found by way of spell check (Thanks, Jiri)
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e22ca536
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e22ca536
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e22ca536
Branch: refs/heads/go1
Commit: e22ca536c69e840bbe9816029a5903408c9a2570
Parents: 5c746ce
Author: Justin Ross <jr...@apache.org>
Authored: Fri Dec 8 12:48:35 2017 -0800
Committer: Justin Ross <jr...@apache.org>
Committed: Fri Dec 8 12:59:19 2017 -0800
----------------------------------------------------------------------
bin/record-coverage.sh | 2 +-
docs/markdown/index.md | 2 +-
docs/markdown/messenger/message-disposition.md | 2 +-
examples/c/direct.c | 2 +-
examples/c/example_test.py | 2 +-
examples/c/send-abort.c | 2 +-
examples/c/send-ssl.c | 2 +-
examples/c/send.c | 2 +-
examples/cpp/README.dox | 2 +-
examples/cpp/encode_decode.cpp | 2 +-
examples/cpp/example_test.py | 2 +-
examples/cpp/flow_control.cpp | 2 +-
examples/cpp/multithreaded_client.cpp | 4 +--
.../cpp/multithreaded_client_flow_control.cpp | 4 +--
examples/cpp/ssl_client_cert.cpp | 2 +-
examples/cpp/tutorial.dox | 2 +-
examples/go/README.md | 2 +-
examples/go/electron/broker.go | 2 +-
examples/go/electron/send.go | 2 +-
examples/go/proton/broker.go | 4 +--
examples/python/README | 4 +--
examples/python/sync_client.py | 2 +-
.../bindings/cpp/include/proton/container.hpp | 2 +-
.../bindings/cpp/include/proton/message.hpp | 2 +-
.../cpp/include/proton/source_options.hpp | 2 +-
.../bindings/cpp/include/proton/tracker.hpp | 4 +--
proton-c/bindings/cpp/include/proton/uuid.hpp | 4 +--
proton-c/bindings/cpp/src/interop_test.cpp | 6 ++---
proton-c/bindings/cpp/src/messaging_adapter.cpp | 4 +--
.../cpp/src/proactor_container_impl.cpp | 6 ++---
proton-c/bindings/cpp/src/test_port.hpp | 2 +-
proton-c/bindings/cpp/src/uuid.cpp | 2 +-
proton-c/bindings/go/genwrap.go | 2 +-
.../bindings/go/src/qpid.apache.org/README.md | 2 +-
.../go/src/qpid.apache.org/amqp/message.go | 4 +--
.../go/src/qpid.apache.org/amqp/types.go | 2 +-
.../go/src/qpid.apache.org/amqp/types_test.go | 26 ++++++++++----------
.../go/src/qpid.apache.org/amqp/url_test.go | 2 +-
.../src/qpid.apache.org/electron/connection.go | 2 +-
.../qpid.apache.org/electron/electron_test.go | 2 +-
.../go/src/qpid.apache.org/electron/receiver.go | 2 +-
.../go/src/qpid.apache.org/electron/time.go | 2 +-
.../go/src/qpid.apache.org/proton/engine.go | 6 ++---
.../go/src/qpid.apache.org/proton/handlers.go | 2 +-
.../go/src/qpid.apache.org/proton/message.go | 4 +--
.../go/src/qpid.apache.org/proton/wrappers.go | 4 +--
proton-c/bindings/javascript/README | 10 ++++----
proton-c/bindings/javascript/data-uuid.js | 6 ++---
proton-c/bindings/javascript/data.js | 14 +++++------
proton-c/bindings/javascript/message.js | 6 ++---
proton-c/bindings/javascript/messenger.js | 6 ++---
proton-c/bindings/javascript/module.js | 2 +-
proton-c/bindings/perl/lib/qpid/proton/Data.pm | 6 ++---
proton-c/bindings/perl/tests/hash_helper.t | 2 +-
proton-c/bindings/perl/tests/message.t | 4 +--
proton-c/bindings/python/docs/overview.rst | 4 +--
proton-c/bindings/python/docs/tutorial.rst | 4 +--
proton-c/bindings/python/proton/__init__.py | 12 ++++-----
proton-c/bindings/python/proton/handlers.py | 8 +++---
proton-c/bindings/python/proton/reactor.py | 12 ++++-----
proton-c/bindings/python/proton/utils.py | 4 +--
proton-c/bindings/python/setup.py.in | 2 +-
proton-c/include/proton/codec.h | 14 +++++------
proton-c/include/proton/connection.h | 14 +++++------
proton-c/include/proton/connection_driver.h | 4 +--
proton-c/include/proton/delivery.h | 4 +--
proton-c/include/proton/event.h | 4 +--
proton-c/include/proton/link.h | 2 +-
proton-c/include/proton/log.h | 4 +--
proton-c/include/proton/message.h | 4 +--
proton-c/include/proton/messenger.h | 10 ++++----
proton-c/include/proton/reactor.h | 2 +-
proton-c/include/proton/sasl.h | 2 +-
proton-c/include/proton/selectable.h | 4 +--
proton-c/include/proton/terminus.h | 2 +-
proton-c/include/proton/transport.h | 14 +++++------
proton-c/include/proton/type_compat.h | 2 +-
proton-c/mllib/dom.py | 2 +-
proton-c/src/core/transport.c | 2 +-
proton-c/src/libqpid-proton-proactor.pc.in | 2 +-
proton-c/src/proactor/epoll.c | 6 ++---
proton-c/src/proactor/libuv.c | 2 +-
proton-c/src/proactor/win_iocp.c | 4 +--
proton-c/src/reactor/connection.c | 2 +-
proton-c/src/sasl/sasl.c | 2 +-
proton-c/src/ssl/schannel.c | 4 +--
proton-c/src/tests/proactor.c | 8 +++---
proton-c/src/tests/refcount.c | 2 +-
proton-c/src/tests/test_port.h | 2 +-
proton-c/src/tests/test_tools.h | 2 +-
tests/javascript/codec.js | 2 +-
tests/javascript/message.js | 4 +--
tests/perf/README.txt | 2 +-
tests/perf/quick_perf.py | 2 +-
tests/python/proton_tests/codec.py | 2 +-
tests/python/proton_tests/engine.py | 4 +--
tests/python/proton_tests/message.py | 2 +-
tests/python/proton_tests/messenger.py | 2 +-
tests/python/proton_tests/sasl.py | 4 +--
tests/python/proton_tests/ssl.py | 4 +--
tests/tools/apps/c/reactor-recv.c | 4 +--
tools/check_abi/README.md | 2 +-
tools/cmake/Modules/WindowsC99SymbolCheck.py | 2 +-
tools/py/proctest.py | 2 +-
104 files changed, 207 insertions(+), 207 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/bin/record-coverage.sh
----------------------------------------------------------------------
diff --git a/bin/record-coverage.sh b/bin/record-coverage.sh
index f161e6d..3d1aa1d 100755
--- a/bin/record-coverage.sh
+++ b/bin/record-coverage.sh
@@ -12,7 +12,7 @@
# - The second is the build tree: this is optional and if not specified is assumed to be the
# current directory.
#
-# The output is in the form of an html report which will be found in the generated html direectory.
+# The output is in the form of an html report which will be found in the generated html directory.
# - There will also be a number of intermediate files left in the current directory.
#
# The typical way to use it would be to use the "Coverage" build type to get instrumented
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/docs/markdown/index.md
----------------------------------------------------------------------
diff --git a/docs/markdown/index.md b/docs/markdown/index.md
index 5262c44..0f0a8e3 100644
--- a/docs/markdown/index.md
+++ b/docs/markdown/index.md
@@ -18,7 +18,7 @@ globally federated topologies
Proton is multi-lingual:
-- Proton-C - a C implementation with lanuage bindings in Python, Php, Perl,
+- Proton-C - a C implementation with language bindings in Python, Php, Perl,
Ruby, and Java (via JNI).
- Proton-J - a pure Java implementation
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/docs/markdown/messenger/message-disposition.md
----------------------------------------------------------------------
diff --git a/docs/markdown/messenger/message-disposition.md b/docs/markdown/messenger/message-disposition.md
index bf66d2e..70d551f 100644
--- a/docs/markdown/messenger/message-disposition.md
+++ b/docs/markdown/messenger/message-disposition.md
@@ -58,7 +58,7 @@ must set a positive size for its incoming window:
pn_messenger_set_incoming_window(messenger, N);
-You can implicity accept messages by simply letting enough
+You can implicitly accept messages by simply letting enough
new messages arrive. As older messages pass beyond the threshold
of your incoming window size, they will be automatically
accepted. Thus, if you want to automatically accept all
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/c/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/direct.c b/examples/c/direct.c
index 219cd60..104a4a1 100644
--- a/examples/c/direct.c
+++ b/examples/c/direct.c
@@ -207,7 +207,7 @@ static void handle_send(app_data_t* app, pn_event_t* event) {
}
case PN_DELIVERY: {
- /* We received acknowledgedment from the peer that a message was delivered. */
+ /* We received acknowledgement from the peer that a message was delivered. */
pn_delivery_t* d = pn_event_delivery(event);
if (pn_delivery_remote_state(d) == PN_ACCEPTED) {
if (++app->acknowledged == app->message_count) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/c/example_test.py
----------------------------------------------------------------------
diff --git a/examples/c/example_test.py b/examples/c/example_test.py
index 5c97e46..782728e 100644
--- a/examples/c/example_test.py
+++ b/examples/c/example_test.py
@@ -58,7 +58,7 @@ class Broker(object):
class CExampleTest(ProcTestCase):
def runex(self, name, port, messages=MESSAGES):
- """Run an example with standard arugments, return output"""
+ """Run an example with standard arguments, return output"""
return self.proc([name, "", str(port), "xtest", str(messages)]).wait_exit()
def test_send_receive(self):
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/c/send-abort.c
----------------------------------------------------------------------
diff --git a/examples/c/send-abort.c b/examples/c/send-abort.c
index defbee5..2894ebe 100644
--- a/examples/c/send-abort.c
+++ b/examples/c/send-abort.c
@@ -156,7 +156,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
}
case PN_DELIVERY: {
- /* We received acknowledgedment from the peer that a message was delivered. */
+ /* We received acknowledgement from the peer that a message was delivered. */
pn_delivery_t* d = pn_event_delivery(event);
fprintf(stderr, "Aborted deliveries should not receive delivery events. Delivery state %d\n", (int)pn_delivery_remote_state(d));
pn_connection_close(pn_event_connection(event));
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/c/send-ssl.c
----------------------------------------------------------------------
diff --git a/examples/c/send-ssl.c b/examples/c/send-ssl.c
index 4fc80c3..e307fa4 100644
--- a/examples/c/send-ssl.c
+++ b/examples/c/send-ssl.c
@@ -149,7 +149,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
}
case PN_DELIVERY: {
- /* We received acknowledgedment from the peer that a message was delivered. */
+ /* We received acknowledgement from the peer that a message was delivered. */
pn_delivery_t* d = pn_event_delivery(event);
if (pn_delivery_remote_state(d) == PN_ACCEPTED) {
if (++app->acknowledged == app->message_count) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/c/send.c
----------------------------------------------------------------------
diff --git a/examples/c/send.c b/examples/c/send.c
index 1af74f8..2f48877 100644
--- a/examples/c/send.c
+++ b/examples/c/send.c
@@ -126,7 +126,7 @@ static bool handle(app_data_t* app, pn_event_t* event) {
}
case PN_DELIVERY: {
- /* We received acknowledgedment from the peer that a message was delivered. */
+ /* We received acknowledgement from the peer that a message was delivered. */
pn_delivery_t* d = pn_event_delivery(event);
if (pn_delivery_remote_state(d) == PN_ACCEPTED) {
if (++app->acknowledged == app->message_count) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/README.dox
----------------------------------------------------------------------
diff --git a/examples/cpp/README.dox b/examples/cpp/README.dox
index b475b2a..a5228d3 100644
--- a/examples/cpp/README.dox
+++ b/examples/cpp/README.dox
@@ -103,7 +103,7 @@ alternatives.
/** @example broker.cpp
A broker using the `proton::container`. You can use this to run other examples
-that reqiure an intermediary, or you can use any AMQP 1.0 broker. This broker
+that require an intermediary, or you can use any AMQP 1.0 broker. This broker
creates queues automatically when a client tries to send or subscribe.
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/encode_decode.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/encode_decode.cpp b/examples/cpp/encode_decode.cpp
index 862d1dd..cd6169a 100644
--- a/examples/cpp/encode_decode.cpp
+++ b/examples/cpp/encode_decode.cpp
@@ -175,7 +175,7 @@ int main(int, char**) {
// print_next prints the next value from values by recursively descending into complex values.
//
-// NOTE this is for example puroses only: There is a built in ostream operator<< for values.
+// NOTE this is for example purposes only: There is a built in ostream operator<< for values.
//
//
static void print_next(proton::codec::decoder& d) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 5d8d45f..8be3352 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -159,7 +159,7 @@ class ContainerExampleTest(BrokerTestCase):
want="""success: Example 1: simple credit
success: Example 2: basic drain
success: Example 3: drain without credit
-success: Exmaple 4: high/low watermark
+success: Example 4: high/low watermark
"""
with TestPort() as tp:
self.assertMultiLineEqual(want, self.proc(["flow_control", "--address", tp.addr, "--quiet"]).wait_exit())
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/flow_control.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/flow_control.cpp b/examples/cpp/flow_control.cpp
index 3773454..f27b6f4 100644
--- a/examples/cpp/flow_control.cpp
+++ b/examples/cpp/flow_control.cpp
@@ -163,7 +163,7 @@ class flow_receiver : public proton::messaging_handler {
return;
}
- verify(received == 25 && r.credit() == 0, "Exmaple 4: high/low watermark");
+ verify(received == 25 && r.credit() == 0, "Example 4: high/low watermark");
r.connection().close();
break;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/multithreaded_client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/multithreaded_client.cpp b/examples/cpp/multithreaded_client.cpp
index c9e6607..78085e2 100644
--- a/examples/cpp/multithreaded_client.cpp
+++ b/examples/cpp/multithreaded_client.cpp
@@ -47,7 +47,7 @@
#include <string>
#include <thread>
-// Lock output from threads to avoid scramblin
+// Lock output from threads to avoid scrambling
std::mutex out_lock;
#define OUT(x) do { std::lock_guard<std::mutex> l(out_lock); x; } while (false)
@@ -100,7 +100,7 @@ class client : public proton::messaging_handler {
return work_queue_;
}
- // == messaging_handler overrides, only called in proton hander thread
+ // == messaging_handler overrides, only called in proton handler thread
// Note: this example creates a connection when the container starts.
// To create connections after the container has started, use
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/multithreaded_client_flow_control.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/multithreaded_client_flow_control.cpp b/examples/cpp/multithreaded_client_flow_control.cpp
index 427b9c8..db652f8 100644
--- a/examples/cpp/multithreaded_client_flow_control.cpp
+++ b/examples/cpp/multithreaded_client_flow_control.cpp
@@ -57,7 +57,7 @@
#include <string>
#include <thread>
-// Lock output from threads to avoid scramblin
+// Lock output from threads to avoid scrambling
std::mutex out_lock;
#define OUT(x) do { std::lock_guard<std::mutex> l(out_lock); x; } while (false)
@@ -106,7 +106,7 @@ class sender : private proton::messaging_handler {
return work_queue_;
}
- // == messaging_handler overrides, only called in proton hander thread
+ // == messaging_handler overrides, only called in proton handler thread
void on_sender_open(proton::sender& s) override {
// Make sure sender_ and work_queue_ are set atomically
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index 96ee122..32a9a1d 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -96,7 +96,7 @@ class hello_world_direct : public proton::messaging_handler {
// Configure client.
ssl_certificate client_cert = platform_certificate("tclient", "tclientpw");
std::string server_CA = platform_CA("tserver");
- // Since the test certifcate's credentials are unlikely to match this host's name, downgrade the verification
+ // Since the test certificate's credentials are unlikely to match this host's name, downgrade the verification
// from VERIFY_PEER_NAME to VERIFY_PEER.
ssl_client_options ssl_cli(client_cert, server_CA, proton::ssl::VERIFY_PEER);
connection_options client_opts;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/cpp/tutorial.dox
----------------------------------------------------------------------
diff --git a/examples/cpp/tutorial.dox b/examples/cpp/tutorial.dox
index f49b9e3..0b72d9d 100644
--- a/examples/cpp/tutorial.dox
+++ b/examples/cpp/tutorial.dox
@@ -1,7 +1,7 @@
// -*-markdown-*-
// NOTE: doxygen can include markdown pages directly but there seems to be a bug
// that shows messed-up line numbers in \skip \until code extracts. This file
-// is markdown wrapped in a doxygen comment - which works. The file is best viewed/editied
+// is markdown wrapped in a doxygen comment - which works. The file is best viewed/edited
// as markdown.
/**
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/go/README.md
----------------------------------------------------------------------
diff --git a/examples/go/README.md b/examples/go/README.md
index eaf6639..e8bb8f5 100644
--- a/examples/go/README.md
+++ b/examples/go/README.md
@@ -118,7 +118,7 @@ messages and the sender link for available credit.
[electron/broker.go](electron/broker.go) does not need any "upside-down"
event-driven code, it is implemented as straightforward loops. The broker is a
loop listening for connections. Each connection is a loop accepting for incoming
-sender or recdiver links. Each receiving link is a loop that receives a message
+sender or receiver links. Each receiving link is a loop that receives a message
and pushes it to a queue. Each sending link is a loop that pops a message from
a queue and sends it.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/go/electron/broker.go
----------------------------------------------------------------------
diff --git a/examples/go/electron/broker.go b/examples/go/electron/broker.go
index 64d7120..6df4e16 100644
--- a/examples/go/electron/broker.go
+++ b/examples/go/electron/broker.go
@@ -111,7 +111,7 @@ func (b *broker) run() error {
}
}
-// State for a broker connectoin
+// State for a broker connection
type connection struct {
broker *broker
connection electron.Connection
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/go/electron/send.go
----------------------------------------------------------------------
diff --git a/examples/go/electron/send.go b/examples/go/electron/send.go
index ac4e367..7e7481d 100644
--- a/examples/go/electron/send.go
+++ b/examples/go/electron/send.go
@@ -64,7 +64,7 @@ func main() {
wait.Add(len(urls)) // Wait for one goroutine per URL.
container := electron.NewContainer(fmt.Sprintf("send[%v]", os.Getpid()))
- connections := make(chan electron.Connection, len(urls)) // Connctions to close on exit
+ connections := make(chan electron.Connection, len(urls)) // Connections to close on exit
// Start a goroutine for each URL to send messages.
for _, urlStr := range urls {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/go/proton/broker.go
----------------------------------------------------------------------
diff --git a/examples/go/proton/broker.go b/examples/go/proton/broker.go
index 8291ca9..8a243e8 100644
--- a/examples/go/proton/broker.go
+++ b/examples/go/proton/broker.go
@@ -24,7 +24,7 @@ under the License.
// messages to queues or subscribe to receive messages from them.
//
-// TODO: show how to handle acknowledgedments from receivers and put rejected or
+// TODO: show how to handle acknowledgements from receivers and put rejected or
// un-acknowledged messages back on their queues.
package main
@@ -44,7 +44,7 @@ import (
func usage() {
fmt.Fprintf(os.Stderr, `
Usage: %s
-A simple broker-like demo. Queues are created automatically for sender or receiver addrsses.
+A simple broker-like demo. Queues are created automatically for sender or receiver addresses.
`, os.Args[0])
flag.PrintDefaults()
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/python/README
----------------------------------------------------------------------
diff --git a/examples/python/README b/examples/python/README
index 9051187..41a6bbd 100644
--- a/examples/python/README
+++ b/examples/python/README
@@ -16,7 +16,7 @@ helloworld.py
Basic example that connects to an intermediary on localhost:5672,
establishes a subscription from the 'examples' node on that
intermediary, then creates a sending link to the same node and sends
-one message. On receving the message back via the subcription, the
+one message. On receiving the message back via the subscription, the
connection is closed.
helloworld_blocking.py
@@ -79,7 +79,7 @@ db_ctrl.py
A utility for setting up the database tables for the two examples
above. Takes two arguments, the action to perform and the name of the
-database on which to perfom it. The database used by db_send.py is
+database on which to perform it. The database used by db_send.py is
src_db, that by db_recv.py is dst_db. The valid actions are 'init',
which creates the table, 'list' which displays the contents and
'insert' which inserts records from standard-in and is used to
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/examples/python/sync_client.py
----------------------------------------------------------------------
diff --git a/examples/python/sync_client.py b/examples/python/sync_client.py
index 0b7b045..7b86e29 100755
--- a/examples/python/sync_client.py
+++ b/examples/python/sync_client.py
@@ -20,7 +20,7 @@
"""
Demonstrates the client side of the synchronous request-response pattern
-(also known as RPC or Remote Procecure Call) using proton.
+(also known as RPC or Remote Procedure Call) using proton.
"""
from __future__ import print_function, unicode_literals
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index e80acbe..9733f78 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -265,7 +265,7 @@ class PN_CPP_CLASS_EXTERN container {
PN_CPP_EXTERN std::string id() const;
/// Connection options applied to outgoing connections. These are
- /// applied first and then overriden by any options provided in
+ /// applied first and then overridden by any options provided in
/// `connect()` or `messaging_handler::on_connection_open()`.
PN_CPP_EXTERN void client_connection_options(const connection_options& conn_opts);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 2273076..50e12e4 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -302,7 +302,7 @@ class message {
/// be modified in place.
PN_CPP_EXTERN annotation_map& message_annotations();
- /// Examine the meessage annotations map.
+ /// Examine the message annotations map.
PN_CPP_EXTERN const annotation_map& message_annotations() const;
/// Get the delivery annotations map. It can
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/include/proton/source_options.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/source_options.hpp b/proton-c/bindings/cpp/include/proton/source_options.hpp
index 5b527ad..dd9d9d0 100644
--- a/proton-c/bindings/cpp/include/proton/source_options.hpp
+++ b/proton-c/bindings/cpp/include/proton/source_options.hpp
@@ -63,7 +63,7 @@ class source_options {
/// ignored.
PN_CPP_EXTERN source_options& dynamic(bool);
- /// Control whether messsages are browsed or consumed. The
+ /// Control whether messages are browsed or consumed. The
/// default is source::MOVE, meaning consumed.
PN_CPP_EXTERN source_options& distribution_mode(enum source::distribution_mode);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/include/proton/tracker.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/tracker.hpp b/proton-c/bindings/cpp/include/proton/tracker.hpp
index b3e6811..8c3a58d 100644
--- a/proton-c/bindings/cpp/include/proton/tracker.hpp
+++ b/proton-c/bindings/cpp/include/proton/tracker.hpp
@@ -49,9 +49,9 @@ class tracker : public transfer {
/// Get the sender for this tracker.
PN_CPP_EXTERN class sender sender() const;
- // @cond INTERNAL
+ /// @cond INTERNAL
friend class internal::factory<tracker>;
- // @endcond
+ /// @endcond
};
} // proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/include/proton/uuid.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/uuid.hpp b/proton-c/bindings/cpp/include/proton/uuid.hpp
index 464d7a7..66578df 100644
--- a/proton-c/bindings/cpp/include/proton/uuid.hpp
+++ b/proton-c/bindings/cpp/include/proton/uuid.hpp
@@ -52,12 +52,12 @@ class uuid : public byte_array<16> {
PN_CPP_EXTERN static uuid random();
/// UUID standard string format: 8-4-4-4-12 (36 chars, 32
- /// alphanumeric chars and 4 hypens).
+ /// alphanumeric chars and 4 hyphens).
PN_CPP_EXTERN std::string str() const;
};
/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric chars
-/// and 4 hypens).
+/// and 4 hyphens).
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const uuid&);
} // proton
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/src/interop_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/interop_test.cpp b/proton-c/bindings/cpp/src/interop_test.cpp
index de6ae63..a253a37 100644
--- a/proton-c/bindings/cpp/src/interop_test.cpp
+++ b/proton-c/bindings/cpp/src/interop_test.cpp
@@ -57,8 +57,8 @@ void test_data_ostream() {
ASSERT_EQUAL("true, false, 42, 42, -42, 12345, -12345, 12345, -12345, 0.125, 0.125", str(dt));
}
-// Test extracting to exact AMQP types works corectly, extrating to invalid types fails.
-void test_decoder_primitves_exact() {
+// Test extracting to exact AMQP types works correctly, extracting to invalid types fails.
+void test_decoder_primitives_exact() {
value dv;
decoder d(dv);
d.decode(read("primitives"));
@@ -109,7 +109,7 @@ int main(int argc, char** argv) {
tests_dir = argv[1];
RUN_TEST(failed, test_data_ostream());
- RUN_TEST(failed, test_decoder_primitves_exact());
+ RUN_TEST(failed, test_decoder_primitives_exact());
RUN_TEST(failed, test_encoder_primitives());
return failed;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/src/messaging_adapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.cpp b/proton-c/bindings/cpp/src/messaging_adapter.cpp
index 2ba053c..dad8dd2 100644
--- a/proton-c/bindings/cpp/src/messaging_adapter.cpp
+++ b/proton-c/bindings/cpp/src/messaging_adapter.cpp
@@ -175,7 +175,7 @@ void on_delivery(messaging_handler& handler, pn_event_t* event) {
}
}
-bool is_remote_unititialised(pn_state_t state) {
+bool is_remote_uninitialized(pn_state_t state) {
return state & PN_REMOTE_UNINIT;
}
@@ -275,7 +275,7 @@ void on_transport_closed(messaging_handler& handler, pn_event_t* event) {
// If the connection isn't open generate on_transport_open event
// because we didn't generate it yet and the events won't match.
pn_connection_t *conn = pn_event_connection(event);
- if (!conn || is_remote_unititialised(pn_connection_state(conn))) {
+ if (!conn || is_remote_uninitialized(pn_connection_state(conn))) {
handler.on_transport_open(t);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index a55cdcb..491b69b 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -198,13 +198,13 @@ pn_connection_t* container::impl::make_connection_lh(
// Takes ownership of pnc
//
-// NOTE: After the call to start_connecton() pnc is active in a proactor thread,
+// NOTE: After the call to start_connection() pnc is active in a proactor thread,
// and may even have been freed already. It is undefined to use pnc (or any
// object belonging to it) except in appropriate handlers.
//
// SUBTLE NOTE: There must not be any proton::object wrappers in scope when
-// start_connecton() is called. The wrapper destructor will call pn_decref()
-// after start_connecton() which is undefined!
+// start_connection() is called. The wrapper destructor will call pn_decref()
+// after start_connection() which is undefined!
//
void container::impl::start_connection(const url& url, pn_connection_t *pnc) {
char caddr[PN_MAX_ADDR];
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/src/test_port.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_port.hpp b/proton-c/bindings/cpp/src/test_port.hpp
index 5d2fada..cc592fa 100644
--- a/proton-c/bindings/cpp/src/test_port.hpp
+++ b/proton-c/bindings/cpp/src/test_port.hpp
@@ -150,7 +150,7 @@ class test_port {
std::string url(const std::string& host="") const {
std::ostringstream url;
- url << "amp://" << host << ":" << port_;
+ url << "amqp://" << host << ":" << port_;
return url.str();
}
};
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/cpp/src/uuid.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/uuid.cpp b/proton-c/bindings/cpp/src/uuid.cpp
index 7e0af2c..861d707 100644
--- a/proton-c/bindings/cpp/src/uuid.cpp
+++ b/proton-c/bindings/cpp/src/uuid.cpp
@@ -85,7 +85,7 @@ uuid uuid::random() {
return bytes;
}
-/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hypens)
+/// UUID standard format: 8-4-4-4-12 (36 chars, 32 alphanumeric and 4 hyphens)
std::ostream& operator<<(std::ostream& o, const uuid& u) {
ios_guard restore_flags(o);
o << std::hex << std::setfill('0');
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/genwrap.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/genwrap.go b/proton-c/bindings/go/genwrap.go
index 0bf13fa..45b5066 100644
--- a/proton-c/bindings/go/genwrap.go
+++ b/proton-c/bindings/go/genwrap.go
@@ -267,7 +267,7 @@ var (
func event(out io.Writer) {
event_h := readHeader("event")
- // Event is implented by hand in wrappers.go
+ // Event is implemented by hand in wrappers.go
// Get all the pn_event_type_t enum values
var etypes []eventType
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/README.md b/proton-c/bindings/go/src/qpid.apache.org/README.md
index 0977787..5292454 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/README.md
+++ b/proton-c/bindings/go/src/qpid.apache.org/README.md
@@ -6,7 +6,7 @@ available at: <http://godoc.org/?q=qpid.apache.org>
They require the
[proton-C library and header files](http://qpid.apache.org/proton) to be
-installed. On many platforms it is avaialable pre-packaged, for example on
+installed. On many platforms it is available pre-packaged, for example on
Fedora
dnf install qpid-proton-c-devel
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
index 0e13cb9..389fa37 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/message.go
@@ -99,7 +99,7 @@ type Message interface {
ContentEncoding() string
SetContentEncoding(string)
- // ExpiryTime indicates an absoulte time when the message may be dropped.
+ // ExpiryTime indicates an absolute time when the message may be dropped.
// A Zero time (i.e. t.isZero() == true) indicates a message never expires.
ExpiryTime() time.Time
SetExpiryTime(time.Time)
@@ -146,7 +146,7 @@ type Message interface {
// Unmarshal the message body into the value pointed to by v. See amqp.Unmarshal() for details.
Unmarshal(interface{})
- // Body value resulting from the default unmarshalling of message body as interface{}
+ // Body value resulting from the default unmarshaling of message body as interface{}
Body() interface{}
// Encode encodes the message as AMQP data. If buffer is non-nil and is large enough
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
index 29cf866..a1fe2ac 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
@@ -165,7 +165,7 @@ func (l List) GoString() string {
// pnTime converts Go time.Time to Proton millisecond Unix time.
func pnTime(t time.Time) C.pn_timestamp_t {
secs := t.Unix()
- // Note: sub-second accuracy is not guaraunteed if the Unix time in
+ // Note: sub-second accuracy is not guaranteed if the Unix time in
// nanoseconds cannot be represented by an int64 (sometime around year 2260)
msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
return C.pn_timestamp_t(secs*1000 + msecs)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/amqp/types_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/types_test.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/types_test.go
index e79ea1b..efa6e59 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/types_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/types_test.go
@@ -33,13 +33,13 @@ func checkEqual(want interface{}, got interface{}) error {
return nil
}
-func checkUnmarshal(marshalled []byte, v interface{}) error {
- got, err := Unmarshal(marshalled, v)
+func checkUnmarshal(marshaled []byte, v interface{}) error {
+ got, err := Unmarshal(marshaled, v)
if err != nil {
return err
}
- if got != len(marshalled) {
- return fmt.Errorf("Wanted to Unmarshal %v bytes, got %v", len(marshalled), got)
+ if got != len(marshaled) {
+ return fmt.Errorf("Wanted to Unmarshal %v bytes, got %v", len(marshaled), got)
}
return nil
}
@@ -139,7 +139,7 @@ func TestTypesRoundTrip(t *testing.T) {
// Round trip from T to T where T is the type of the value.
func TestTypesRoundTripAll(t *testing.T) {
for _, x := range allValues {
- marshalled, err := Marshal(x, nil)
+ marshaled, err := Marshal(x, nil)
if err != nil {
t.Error(err)
}
@@ -147,7 +147,7 @@ func TestTypesRoundTripAll(t *testing.T) {
continue
}
vp := reflect.New(reflect.TypeOf(x)) // v points to a Zero of the same type as x
- if err := checkUnmarshal(marshalled, vp.Interface()); err != nil {
+ if err := checkUnmarshal(marshaled, vp.Interface()); err != nil {
t.Error(err)
}
v := vp.Elem().Interface()
@@ -168,11 +168,11 @@ func TestTypesPrint(t *testing.T) {
func TestDescribed(t *testing.T) {
want := Described{"D", "V"}
- marshalled, _ := Marshal(want, nil)
+ marshaled, _ := Marshal(want, nil)
// Unmarshal to Described type
var d Described
- if err := checkUnmarshal(marshalled, &d); err != nil {
+ if err := checkUnmarshal(marshaled, &d); err != nil {
t.Error(err)
}
if err := checkEqual(want, d); err != nil {
@@ -181,7 +181,7 @@ func TestDescribed(t *testing.T) {
// Unmarshal to interface{}
var i interface{}
- if err := checkUnmarshal(marshalled, &i); err != nil {
+ if err := checkUnmarshal(marshaled, &i); err != nil {
t.Error(err)
}
if _, ok := i.(Described); !ok {
@@ -193,7 +193,7 @@ func TestDescribed(t *testing.T) {
// Unmarshal value only (drop descriptor) to the value type
var s string
- if err := checkUnmarshal(marshalled, &s); err != nil {
+ if err := checkUnmarshal(marshaled, &s); err != nil {
t.Error(err)
}
if err := checkEqual(want.Value, s); err != nil {
@@ -202,15 +202,15 @@ func TestDescribed(t *testing.T) {
// Nested described types
want = Described{Described{int64(123), true}, "foo"}
- marshalled, _ = Marshal(want, nil)
- if err := checkUnmarshal(marshalled, &d); err != nil {
+ marshaled, _ = Marshal(want, nil)
+ if err := checkUnmarshal(marshaled, &d); err != nil {
t.Error(err)
}
if err := checkEqual(want, d); err != nil {
t.Error(err)
}
// Nested to interface
- if err := checkUnmarshal(marshalled, &i); err != nil {
+ if err := checkUnmarshal(marshaled, &i); err != nil {
t.Error(err)
}
if err := checkEqual(want, i); err != nil {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/amqp/url_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/url_test.go b/proton-c/bindings/go/src/qpid.apache.org/amqp/url_test.go
index f52d4bf..192e2fb 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/url_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/url_test.go
@@ -33,7 +33,7 @@ func ExampleParseURL() {
"/path",
"",
":1234",
- // Taken out becasue the go 1.4 URL parser isn't the same as later
+ // Taken out because the go 1.4 URL parser isn't the same as later
//"[::1]",
//"[::1",
// Output would be:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/electron/connection.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/connection.go b/proton-c/bindings/go/src/qpid.apache.org/electron/connection.go
index 2749b2b..731e64d 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/connection.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/connection.go
@@ -130,7 +130,7 @@ func VirtualHost(virtualHost string) ConnectionOption {
// connection. Only applies to outbound client connection.
//
// The connection will erase its copy of the password from memory as soon as it
-// has been used to authenticate. If you are concerned about paswords staying in
+// has been used to authenticate. If you are concerned about passwords staying in
// memory you should never store them as strings, and should overwrite your
// copy as soon as you are done with it.
//
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go b/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
index d8862b9..74759f5 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/electron_test.go
@@ -151,7 +151,7 @@ func TestClientSendServerReceive(t *testing.T) {
}
}()
- // Server recieve
+ // Server receive
rm, err := r[i].Receive()
if err != nil {
t.Fatal(err)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/electron/receiver.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/receiver.go b/proton-c/bindings/go/src/qpid.apache.org/electron/receiver.go
index 781fd7c..26b46a8 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/receiver.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/receiver.go
@@ -91,7 +91,7 @@ func newReceiver(ls linkSettings) *receiver {
return r
}
-// Call in proton gorotine. Max additional credit we can request.
+// Call in proton goroutine. Max additional credit we can request.
func (r *receiver) maxFlow() int { return cap(r.buffer) - len(r.buffer) - r.pLink.Credit() }
func (r *receiver) flow(credit int) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/electron/time.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/time.go b/proton-c/bindings/go/src/qpid.apache.org/electron/time.go
index 51bfbc5..52f0cee 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/time.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/time.go
@@ -33,7 +33,7 @@ import (
// If timeout > 0 and there is no result available before the timeout, they
// return a zero or nil value and Timeout as an error.
//
-// If timeout == 0 they will return a result if one is immediatley available or
+// If timeout == 0 they will return a result if one is immediately available or
// nil/zero and Timeout as an error if not.
//
// If timeout == Forever the function will return only when there is a result or
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
index c0f0093..d28a09f 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/engine.go
@@ -89,7 +89,7 @@ type Injecter interface {
// invalid. The handler methods will tell you when a value is no longer valid. For
// example after a LinkClosed event, that link is no longer valid. If you do
// Link.Close() yourself (in a handler or injected function) the link remains valid
-// until the corresponing LinkClosed event is received by the handler.
+// until the corresponding LinkClosed event is received by the handler.
//
// Engine.Close() will take care of cleaning up any remaining values when you are
// done with the Engine. All values associated with a engine become invalid when you
@@ -217,7 +217,7 @@ func (eng *Engine) InjectWait(f func() error) error {
}
// Server puts the Engine in server mode, meaning it will auto-detect security settings on
-// the incoming connnection such as use of SASL and SSL.
+// the incoming connection such as use of SASL and SSL.
// Must be called before Run()
//
func (eng *Engine) Server() { eng.Transport().SetServer() }
@@ -319,7 +319,7 @@ func (eng *Engine) Run() error {
eng.tick() // Start ticking if needed
// Channels for read and write buffers going in and out of the read/write goroutines.
- // The channels are unbuffered: we want to exchange buffers in seuquence.
+ // The channels are unbuffered: we want to exchange buffers in sequence.
readsIn, writesIn := make(chan []byte), make(chan []byte)
readsOut, writesOut := make(chan []byte), make(chan []byte)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/proton/handlers.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/handlers.go b/proton-c/bindings/go/src/qpid.apache.org/proton/handlers.go
index 961136e..f101548 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/handlers.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/handlers.go
@@ -244,7 +244,7 @@ func (d flowcontroller) HandleEvent(e Event) {
}
}
-// MessagingAdapter implments a EventHandler and delegates to a MessagingHandler.
+// MessagingAdapter implements a EventHandler and delegates to a MessagingHandler.
// You can modify the exported fields before you pass the MessagingAdapter to
// a Engine.
type MessagingAdapter struct {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/message.go b/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
index 2336483..fbb1d48 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
@@ -35,7 +35,7 @@ import (
// Equivalent to !d.isNil && d.Readable() && !d.Partial()
func (d Delivery) HasMessage() bool { return !d.IsNil() && d.Readable() && !d.Partial() }
-// Message decodes the message containined in a delivery.
+// Message decodes the message contained in a delivery.
//
// Must be called in the correct link context with this delivery as the current message,
// handling an MMessage event is always a safe context to call this function.
@@ -75,7 +75,7 @@ func (link Link) Send(m amqp.Message) (Delivery, error) {
delivery := link.Delivery(nextTag())
bytes, err := m.Encode(nil)
if err != nil {
- return Delivery{}, fmt.Errorf("cannot send mesage %s", err)
+ return Delivery{}, fmt.Errorf("cannot send message %s", err)
}
result := link.SendBytes(bytes)
link.Advance()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers.go b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers.go
index 09f3e65..a7b7fb2 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/proton/wrappers.go
@@ -168,10 +168,10 @@ func (s State) RemoteUninit() bool { return s.Has(SRemoteUninit) }
func (s State) RemoteActive() bool { return s.Has(SRemoteActive) }
func (s State) RemoteClosed() bool { return s.Has(SRemoteClosed) }
-// Return a State containig just the local flags
+// Return a State containing just the local flags
func (s State) Local() State { return State(s & C.PN_LOCAL_MASK) }
-// Return a State containig just the remote flags
+// Return a State containing just the remote flags
func (s State) Remote() State { return State(s & C.PN_REMOTE_MASK) }
// Endpoint is the common interface for Connection, Link and Session.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/README
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/README b/proton-c/bindings/javascript/README
index 2dea949..9ec37d0 100644
--- a/proton-c/bindings/javascript/README
+++ b/proton-c/bindings/javascript/README
@@ -269,7 +269,7 @@ illustrates how to do asynchronous request/response based applications.
Aside from the asynchronous aspects the rest of the API is essentially the same
as the Python binding aside from minor things such as camel casing method names etc.
-Serialisation/Deserialisation, Types etc.
+Serialisation/Deserialization, Types etc.
=========================================
The JavaScript binding tries to be as simple, intuitive and natural as possible
@@ -358,7 +358,7 @@ message.body = ['Rod', 'Jane', 'Freddy', {cat: true, donkey: 'hee haw'}];
// attempt to use the correct type such that message.body = 2147483647; would be
// sent as an AMQP integer, but because of the way JavaScript coerces integers
// message.body = 2147483647.0; would also be sent as an AMQP integer because
-// 2147483647.0 gets transparently conveted to 2147483647 by the interpreter, so
+// 2147483647.0 gets transparently converted to 2147483647 by the interpreter, so
// to explicitly send this as an AMQP float we'd need to do:
// message.body = 2147483647.0.float();
@@ -398,15 +398,15 @@ JSON
====
As well as allowing native JavaScript Objects and Arrays to be transparently
-serialised and deserialised via the AMQP type system it is also possible to
-serialise/deserialise as JSON.
+serialised and deserialized via the AMQP type system it is also possible to
+serialise/deserialize as JSON.
message.setAddress('amqp://localhost');
message.setContentType('application/json');
message.body = {array: [1, 2, 3, 4], object: {name: "John Smith", age: 65}};
On the wire the above will be encoded as an opaque binary in an AMQP data section
-but will be deserialised into a JavaScript Object in exactly the same was as the
+but will be deserialized into a JavaScript Object in exactly the same was as the
previous examples that use the AMQP type system.
SUPPORT
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/data-uuid.js
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/data-uuid.js b/proton-c/bindings/javascript/data-uuid.js
index 4fee84a..18bc96a 100644
--- a/proton-c/bindings/javascript/data-uuid.js
+++ b/proton-c/bindings/javascript/data-uuid.js
@@ -27,7 +27,7 @@
/**
* Create a proton.Data.Uuid which is a type 4 UUID.
* @classdesc
- * This class represents a type 4 UUID, wich may use crypto libraries to generate
+ * This class represents a type 4 UUID, which may use crypto libraries to generate
* the UUID if supported by the platform (e.g. node.js or a modern browser)
* @constructor proton.Data.Uuid
* @param {number|Array|string} u a UUID. If null a type 4 UUID is generated wich may use crypto if
@@ -37,7 +37,7 @@
* @property {Array} uuid is the compact array form of the UUID.
*/
Data['Uuid'] = function(u) { // Data.Uuid Constructor.
- // Helper to copy from emscriptem allocated storage into JavaScript Array.
+ // Helper to copy from emscripten allocated storage into JavaScript Array.
function _p2a(p) {
var uuid = new Array(16);
for (var i = 0; i < 16; i++) {
@@ -46,7 +46,7 @@ Data['Uuid'] = function(u) { // Data.Uuid Constructor.
return uuid;
};
- if (!u) { // Generate UUID using emscriptem's uuid_generate implementation.
+ if (!u) { // Generate UUID using emscripten's uuid_generate implementation.
var sp = Runtime.stackSave();
var p = allocate(16, 'i8', ALLOC_STACK); // Create temporary pointer storage.
_uuid_generate(p); // Generate UUID into allocated pointer.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/data.js
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/data.js b/proton-c/bindings/javascript/data.js
index 061d2bd..05e537b 100644
--- a/proton-c/bindings/javascript/data.js
+++ b/proton-c/bindings/javascript/data.js
@@ -204,7 +204,7 @@ Data.isBoolean = function(o) {
// We use the dot notation rather than associative array form for protected
// methods so they are visible to this "package", but the Closure compiler will
-// minify and obfuscate names, effectively making a defacto "protected" method.
+// minify and obfuscate names, effectively making a de facto "protected" method.
/**
* This helper method checks the supplied error code, converts it into an
@@ -317,7 +317,7 @@ _Data_['exit'] = function() {
/**
* Look up a value by name. N.B. Need to use getObject() to retrieve the actual
- * value after lookup suceeds.
+ * value after lookup succeeds.
* @method lookup
* @memberof! proton.Data#
* @param {string} name the name of the property to look up.
@@ -1298,7 +1298,7 @@ _Data_['putMAP'] = function(object) {
* Deserialise from an AMQP Map into a Native JavaScript Object.
* @method getMAP
* @memberof! proton.Data#
- * @returns {object} the deserialised Native JavaScript Object.
+ * @returns {object} the deserialized Native JavaScript Object.
*/
_Data_['getMAP'] = function() {
if (this['enter']()) {
@@ -1335,7 +1335,7 @@ _Data_['putLIST'] = function(array) {
* Deserialise from an AMQP List into a Native JavaScript Array.
* @method getLIST
* @memberof! proton.Data#
- * @returns {Array} the deserialised Native JavaScript Array.
+ * @returns {Array} the deserialized Native JavaScript Array.
*/
_Data_['getLIST'] = function() {
if (this['enter']()) {
@@ -1366,7 +1366,7 @@ _Data_['putDESCRIBED'] = function(d) {
* Deserialise from an AMQP Described into a proton.Data.Described.
* @method getDESCRIBED
* @memberof! proton.Data#
- * @returns {proton.Data.Described} the deserialised proton.Data.Described.
+ * @returns {proton.Data.Described} the deserialized proton.Data.Described.
*/
_Data_['getDESCRIBED'] = function() {
if (this['enter']()) {
@@ -1434,7 +1434,7 @@ _Data_['putARRAY'] = function(a) {
* Deserialise from an AMQP Array into a proton.Data.Array.
* @method getARRAY
* @memberof! proton.Data#
- * @returns {proton.Data.Array} the deserialised proton.Data.Array.
+ * @returns {proton.Data.Array} the deserialized proton.Data.Array.
*/
_Data_['getARRAY'] = function() {
var metadata = this['getARRAYNODE']();
@@ -1571,7 +1571,7 @@ _Data_['putObject'] = function(obj) {
/**
* @method getObject
* @memberof! proton.Data#
- * @returns {object} the JavaScript Object or primitive being deserialised.
+ * @returns {object} the JavaScript Object or primitive being deserialized.
*/
_Data_['getObject'] = function() {
var type = Data['TypeNames'][this.type()];
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/message.js
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/message.js b/proton-c/bindings/javascript/message.js
index 40b15f2..3ca9598 100644
--- a/proton-c/bindings/javascript/message.js
+++ b/proton-c/bindings/javascript/message.js
@@ -42,7 +42,7 @@ Module['Message'] = function() { // Message Constructor.
// ************************* Public properties ****************************
- // Intitialise with an empty Object so we can set properties in a natural way.
+ // Initialize with an empty Object so we can set properties in a natural way.
// message.properties.prop1 = "foo";
// message.properties.prop2 = "bar";
this['properties'] = {};
@@ -70,7 +70,7 @@ Message['DEFAULT_PRIORITY'] = 4; /** Default priority for messages.*/
// We use the dot notation rather than associative array form for protected
// methods so they are visible to this "package", but the Closure compiler will
-// minify and obfuscate names, effectively making a defacto "protected" method.
+// minify and obfuscate names, effectively making a de facto "protected" method.
/**
* This helper method checks the supplied error code, converts it into an
@@ -196,7 +196,7 @@ _Message_._postDecode = function(decodeBinaryAsString) {
* Free the Message.
* <p>
* N.B. This method has to be called explicitly in JavaScript as we can't
- * intercept finalisers, so we need to remember to free before removing refs.
+ * intercept finalizers, so we need to remember to free before removing refs.
* @method free
* @memberof! proton.Message#
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/messenger.js
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/messenger.js b/proton-c/bindings/javascript/messenger.js
index 5c96cb5..5f1df2e 100644
--- a/proton-c/bindings/javascript/messenger.js
+++ b/proton-c/bindings/javascript/messenger.js
@@ -63,7 +63,7 @@
* Sending & Receiving Messages
* ============================
* </pre>
- * The {@link proton.Messenger} class works in conjuction with the {@link proton.Message} class.
+ * The {@link proton.Messenger} class works in conjunction with the {@link proton.Message} class.
* The {@link proton.Message} class is a mutable holder of message content.
* <p>
* The put method copies its Message to the outgoing queue, and may
@@ -141,7 +141,7 @@ var _Messenger_ = Module['Messenger'].prototype;
// We use the dot notation rather than associative array form for protected
// methods so they are visible to this "package", but the Closure compiler will
-// minify and obfuscate names, effectively making a defacto "protected" method.
+// minify and obfuscate names, effectively making a de facto "protected" method.
/**
* This helper method checks the supplied error code, converts it into an
@@ -319,7 +319,7 @@ _Messenger_['isBlocking'] = function() {
* by the Messenger. Call the stop method before destroying the Messenger.
* <p>
* N.B. This method has to be called explicitly in JavaScript as we can't
- * intercept finalisers, so we need to remember to free before removing refs.
+ * intercept finalizers, so we need to remember to free before removing refs.
* @method free
* @memberof! proton.Messenger#
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/javascript/module.js
----------------------------------------------------------------------
diff --git a/proton-c/bindings/javascript/module.js b/proton-c/bindings/javascript/module.js
index 3603de3..1eac6cc 100644
--- a/proton-c/bindings/javascript/module.js
+++ b/proton-c/bindings/javascript/module.js
@@ -327,7 +327,7 @@ Module.EventDispatch = new function() { // Note the use of new to create a Singl
* actually free and remove the selectable is deferred until next
* time round the (internal JavaScript) event loop. This turned out
* to be necessary because in some cases the ws WebSocket library
- * calls the onclose callback (concurrently!!) before the onmessage
+ * calls the on_close callback (concurrently!!) before the on_message
* callback exits, which could result in _pn_selectable_free being
* called whilst _pn_selectable_writable is executing, which is bad!!
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/perl/lib/qpid/proton/Data.pm
----------------------------------------------------------------------
diff --git a/proton-c/bindings/perl/lib/qpid/proton/Data.pm b/proton-c/bindings/perl/lib/qpid/proton/Data.pm
index 494a8f3..dccf2fc 100644
--- a/proton-c/bindings/perl/lib/qpid/proton/Data.pm
+++ b/proton-c/bindings/perl/lib/qpid/proton/Data.pm
@@ -30,7 +30,7 @@ qpid::proton::Data
The B<Data> class provides an interface for decoding, extract, creating and
encoding arbitrary AMQP data. A B<Data> object contains a tree of AMQP values.
Leaf nodes in this tree correspond to scalars in the AMQP type system such as
-B<INT> or B<STRING>. Integerior nodes in this tree correspond to compound values
+B<INT> or B<STRING>. Interior nodes in this tree correspond to compound values
in the AMQP type system such as B<LIST>, B<MAP>, B<ARRAY> or B<DESCRIBED>. The
root node of the tree is the B<Data> object itself and can have an arbitrary
number of children.
@@ -41,8 +41,8 @@ and/or added by using the B<next>, B<prev>, B<enter> and B<exit> methods to
navigate to the desired location in the tree and using the supplied variety of
mutator and accessor methods to access or add a value of the desired type.
-The mutator methods will always add a vlaue I<after> the current node in the
-tree. If the current node has a next sibling the mutaor method will overwrite
+The mutator methods will always add a value I<after> the current node in the
+tree. If the current node has a next sibling the mutator method will overwrite
the value on this node. If there is no current node or the current node has no
next sibling then one will be added. The accessor methods always set the
add/modified node to the current node. The accessor methods read the value of
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/perl/tests/hash_helper.t
----------------------------------------------------------------------
diff --git a/proton-c/bindings/perl/tests/hash_helper.t b/proton-c/bindings/perl/tests/hash_helper.t
index 8f1ea3d..45277a6 100644
--- a/proton-c/bindings/perl/tests/hash_helper.t
+++ b/proton-c/bindings/perl/tests/hash_helper.t
@@ -34,7 +34,7 @@ my $result;
# raises an error when getting a hash from a null data object
#=============================================================================
dies_ok(sub {qpid::proton::get_map_from(undef);},
- "Raises an error when getting a hash froma null data object");
+ "Raises an error when getting a hash from a null data object");
#=============================================================================
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/perl/tests/message.t
----------------------------------------------------------------------
diff --git a/proton-c/bindings/perl/tests/message.t b/proton-c/bindings/perl/tests/message.t
index ee55361..d907207 100644
--- a/proton-c/bindings/perl/tests/message.t
+++ b/proton-c/bindings/perl/tests/message.t
@@ -58,7 +58,7 @@ dies_ok(sub {$message->set_ttl(0 - $ttl)}, 'TTL cannot be negative');
$message->set_ttl(0);
ok($message->get_ttl() == 0, 'TTL can be zero');
$message->set_ttl($ttl);
-ok($message->get_ttl() == $ttl, 'TTL can be postive');
+ok($message->get_ttl() == $ttl, 'TTL can be positive');
# first acquirer
$message->set_first_acquirer(1);
@@ -76,7 +76,7 @@ dies_ok(sub {$message->set_delivery_count(0 - $delivery_count)},
$message->set_delivery_count(0);
ok($message->get_delivery_count() == 0, 'Delivery count can be zero');
$message->set_delivery_count($delivery_count);
-ok ($message->get_delivery_count() == $delivery_count, 'Delivery count can be postiive');
+ok ($message->get_delivery_count() == $delivery_count, 'Delivery count can be positive');
# message id
my $message_id = random_string(16);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/docs/overview.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/overview.rst b/proton-c/bindings/python/docs/overview.rst
index f82deb2..b11e163 100644
--- a/proton-c/bindings/python/docs/overview.rst
+++ b/proton-c/bindings/python/docs/overview.rst
@@ -44,11 +44,11 @@ The :py:class:`~proton.reactor.Container` class is a convenient entry
point into the API, allowing connections and links to be
established. Applications are structured as one or more event
handlers. Handlers can be set at Container, Connection, or Link
-scope. Messages are sent by establishing an approprate sender and
+scope. Messages are sent by establishing an appropriate sender and
invoking its :py:meth:`~proton.Sender.send()` method. This is
typically done when the sender is sendable, a condition indicated by
the :py:meth:`~proton.handlers.MessagingHandler.on_sendable()` event, to
-avoid execessive build up of messages. Messages can be received by
+avoid excessive build up of messages. Messages can be received by
establishing an appropriate receiver and handling the
:py:meth:`~proton.handlers.MessagingHandler.on_message()` event.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/docs/tutorial.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/tutorial.rst b/proton-c/bindings/python/docs/tutorial.rst
index ee8a12f..95cde3a 100644
--- a/proton-c/bindings/python/docs/tutorial.rst
+++ b/proton-c/bindings/python/docs/tutorial.rst
@@ -237,7 +237,7 @@ The code here is not too different from the simple receiver
example. When we receive a request however, we look at the
:py:attr:`~proton.Message.reply_to` address on the
:py:class:`~proton.Message` and create a sender for that over which to
-send the response. We'll cache the senders incase we get further
+send the response. We'll cache the senders in case we get further
requests with the same reply_to.
Now let's create a simple client to test this service out.
@@ -291,7 +291,7 @@ When creating the receiver, we specify a Selector object as an
option. The options argument can take a single object or a
list. Another option that is sometimes of interest when using a broker
is the ability to 'browse' the messages on a queue, rather than
-consumig them. This is done in AMQP by specifying a distribution mode
+consuming them. This is done in AMQP by specifying a distribution mode
of 'copy' (instead of 'move' which is the expected default for
queues). An example of that is shown next:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/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 0dda550..5c4dea7 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -162,7 +162,7 @@ class Timeout(ProtonException):
class Interrupt(ProtonException):
"""
- An interrupt exception indicaes that a blocking operation was interrupted.
+ An interrupt exception indicates that a blocking operation was interrupted.
"""
pass
@@ -176,7 +176,7 @@ class MessengerException(ProtonException):
class MessageException(ProtonException):
"""
The MessageException class is the root of the message exception
- hierarhcy. All exceptions generated by the Message class derive from
+ hierarchy. All exceptions generated by the Message class derive from
this exception.
"""
pass
@@ -247,7 +247,7 @@ class Messenger(object):
Sending & Receiving Messages
============================
- The L{Messenger} class works in conjuction with the L{Message} class. The
+ The L{Messenger} class works in conjunction with the L{Message} class. The
L{Message} class is a mutable holder of message content.
The L{put} method copies its L{Message} to the outgoing queue, and may
@@ -2836,7 +2836,7 @@ class Link(Wrapper, Endpoint):
@property
def credit(self):
- """The amount of oustanding credit on this link."""
+ """The amount of outstanding credit on this link."""
return pn_link_credit(self._impl)
@property
@@ -3268,7 +3268,7 @@ class Delivery(Wrapper):
def settle(self):
"""
- Settles the delivery locally. This indicates the aplication
+ Settles the delivery locally. This indicates the application
considers the delivery complete and does not wish to receive any
further events about it. Every delivery should be settled locally.
"""
@@ -4167,7 +4167,7 @@ class Url(object):
<scheme>://<user>:<password>@<host>:<port>/<path>
- All components can be None if not specifeid in the URL string.
+ All components can be None if not specified in the URL string.
The port can be specified as a service name, e.g. 'amqp' in the
URL string but Url.port always gives the integer value.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/proton/handlers.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/handlers.py b/proton-c/bindings/python/proton/handlers.py
index 55e02b1..8ecf6da 100644
--- a/proton-c/bindings/python/proton/handlers.py
+++ b/proton-c/bindings/python/proton/handlers.py
@@ -88,7 +88,7 @@ class OutgoingMessageHandler(Handler):
def on_settled(self, event):
"""
Called when the remote peer has settled the outgoing
- message. This is the point at which it shouod never be
+ message. This is the point at which it should never be
retransmitted.
"""
if self.delegate != None:
@@ -184,7 +184,7 @@ class IncomingMessageHandler(Handler, Acking):
"""
Called when a message is received. The message itself can be
obtained as a property on the event. For the purpose of
- refering to this message in further actions (e.g. if
+ referring to this message in further actions (e.g. if
explicitly accepting it, the ``delivery`` should be used, also
obtainable via a property on the event.
"""
@@ -518,7 +518,7 @@ class MessagingHandler(Handler, Acking):
def on_settled(self, event):
"""
Called when the remote peer has settled the outgoing
- message. This is the point at which it shouod never be
+ message. This is the point at which it should never be
retransmitted.
"""
pass
@@ -526,7 +526,7 @@ class MessagingHandler(Handler, Acking):
"""
Called when a message is received. The message itself can be
obtained as a property on the event. For the purpose of
- refering to this message in further actions (e.g. if
+ referring to this message in further actions (e.g. if
explicitly accepting it, the ``delivery`` should be used, also
obtainable via a property on the event.
"""
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index b8bd96f..0fa1c4b 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -203,7 +203,7 @@ class Reactor(Wrapper):
def connection_to_host(self, host, port, handler=None):
"""Create an outgoing Connection that will be managed by the reactor.
- The reator's pn_iohandler will create a socket connection to the host
+ The reactor's pn_iohandler will create a socket connection to the host
once the connection is opened.
"""
conn = self.connection(handler)
@@ -274,7 +274,7 @@ class EventInjector(object):
def close(self):
"""
Request that this EventInjector be closed. Existing events
- will be dispctahed on the reactors event dispactch thread,
+ will be dispatched on the reactors event dispatch thread,
then this will be removed from the set of interest.
"""
self._closed = True
@@ -665,7 +665,7 @@ class SSLConfig(object):
class Container(Reactor):
"""A representation of the AMQP concept of a 'container', which
- lossely speaking is something that establishes links to or from
+ loosely speaking is something that establishes links to or from
another container, over which messages are transfered. This is
an extension to the Reactor class that adds convenience methods
for creating connections and sender- or receiver- links.
@@ -709,7 +709,7 @@ class Container(Reactor):
socket is alive.
@param ssl_domain: SSL configuration in the form of an
- instance of proton.SSLdomain.
+ instance of proton.SSLDomain.
@param handler: a connection scoped handler that will be
called to process any events in the scope of this connection
@@ -795,7 +795,7 @@ class Container(Reactor):
specified as the second argument (or as a keyword
argument). The source address can also be specified if
desired. (2) Alternatively a URL can be passed as the first
- argument. In this case a new connection will be establised on
+ argument. In this case a new connection will be established on
which the link will be attached. If a path is specified and
the target is not, then the path of the URL is used as the
target address.
@@ -836,7 +836,7 @@ class Container(Reactor):
specified as the second argument (or as a keyword
argument). The target address can also be specified if
desired. (2) Alternatively a URL can be passed as the first
- argument. In this case a new connection will be establised on
+ argument. In this case a new connection will be established on
which the link will be attached. If a path is specified and
the source is not, then the path of the URL is used as the
target address.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/proton/utils.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/utils.py b/proton-c/bindings/python/proton/utils.py
index c9a3654..cf36bbe 100644
--- a/proton-c/bindings/python/proton/utils.py
+++ b/proton-c/bindings/python/proton/utils.py
@@ -336,7 +336,7 @@ class AtomicCount(object):
class SyncRequestResponse(IncomingMessageHandler):
"""
- Implementation of the synchronous request-responce (aka RPC) pattern.
+ Implementation of the synchronous request-response (aka RPC) pattern.
@ivar address: Address for all requests, may be None.
@ivar connection: Connection for requests and responses.
"""
@@ -351,7 +351,7 @@ class SyncRequestResponse(IncomingMessageHandler):
@param connection: A L{BlockingConnection}
@param address: Address for all requests.
If not specified, each request must have the address property set.
- Sucessive messages may have different addresses.
+ Successive messages may have different addresses.
"""
super(SyncRequestResponse, self).__init__()
self.connection = connection
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/bindings/python/setup.py.in
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py.in b/proton-c/bindings/python/setup.py.in
index dd6a3a8..7513315 100755
--- a/proton-c/bindings/python/setup.py.in
+++ b/proton-c/bindings/python/setup.py.in
@@ -38,7 +38,7 @@ qpid-proton requires installed to make this setup work.
From the Python side, this scripts overrides 1 command - build_ext - and it adds a
new one. The latter - Configure - is called from the former to setup/discover what's
-in the system. The rest of the comands and steps are done normally without any kind
+in the system. The rest of the commands and steps are done normally without any kind
of monkey patching.
"""
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/codec.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/codec.h b/proton-c/include/proton/codec.h
index bcbbbf0..1755f53 100644
--- a/proton-c/include/proton/codec.h
+++ b/proton-c/include/proton/codec.h
@@ -191,7 +191,7 @@ typedef enum {
PN_EXTERN const char *pn_type_name(pn_type_t type);
/**
- * A descriminated union that holds any scalar AMQP value. The type
+ * A discriminated union that holds any scalar AMQP value. The type
* field indicates the AMQP type of the value, and the union may be
* used to access the value for a given type.
*
@@ -389,7 +389,7 @@ PN_EXTERN void pn_data_free(pn_data_t *data);
PN_EXTERN int pn_data_errno(pn_data_t *data);
/**
- * Access the current error for a givn pn_data_t.
+ * Access the current error for a given pn_data_t.
*
* Every pn_data_t has an error descriptor that is created with the
* pn_data_t and dies with the pn_data_t. The error descriptor is
@@ -425,7 +425,7 @@ PN_EXTERN void pn_data_clear(pn_data_t *data);
/**
* Returns the total number of nodes contained in a pn_data_t object.
* This includes all parents, children, siblings, grandchildren, etc.
- * In other words the count of all ancesters and descendents of the
+ * In other words the count of all ancestors and descendants of the
* current node, along with the current node if there is one.
*
* @param data a pn_data_t object
@@ -518,7 +518,7 @@ PN_EXTERN int pn_data_print(pn_data_t *data);
* @param data a pn_data_t object
* @param bytes a buffer to write the output to
* @param size a pointer to the size of the buffer
- * @return zero on succes, or an error on failure
+ * @return zero on success, or an error on failure
*/
PN_EXTERN int pn_data_format(pn_data_t *data, char *bytes, size_t *size);
@@ -1208,7 +1208,7 @@ PN_EXTERN pn_atom_t pn_data_get_atom(pn_data_t *data);
* data object will be lost.
*
* @param data a pn_data_t object
- * @param src the sourc pn_data_t to copy from
+ * @param src the source pn_data_t to copy from
* @return zero on success or an error code on failure
*/
PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src);
@@ -1217,7 +1217,7 @@ PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src);
* Append the contents of another pn_data_t object.
*
* @param data a pn_data_t object
- * @param src the sourc pn_data_t to append from
+ * @param src the source pn_data_t to append from
* @return zero on success or an error code on failure
*/
PN_EXTERN int pn_data_append(pn_data_t *data, pn_data_t *src);
@@ -1227,7 +1227,7 @@ PN_EXTERN int pn_data_append(pn_data_t *data, pn_data_t *src);
* object.
*
* @param data a pn_data_t object
- * @param src the sourc pn_data_t to append from
+ * @param src the source pn_data_t to append from
* @param limit the maximum number of values to append
* @return zero on success or an error code on failure
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/connection.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/connection.h b/proton-c/include/proton/connection.h
index 4984040..ff6c68c 100644
--- a/proton-c/include/proton/connection.h
+++ b/proton-c/include/proton/connection.h
@@ -294,10 +294,10 @@ PN_EXTERN void pn_connection_set_container(pn_connection_t *connection, const ch
* Set the authentication username for a client connection
*
* It is necessary to set the username and password before binding the connection
- * to a trasnport and it isn't allowed to change them after the binding.
+ * to a transport and it isn't allowed to change them after the binding.
*
* If not set then no authentication will be negotiated unless the client
- * sasl layer is explicitly created (this would be for sometting like Kerberos
+ * sasl layer is explicitly created (this would be for something like Kerberos
* where the credentials are implicit in the environment, or to explicitly use
* the ANONYMOUS SASL mechanism)
*
@@ -310,7 +310,7 @@ PN_EXTERN void pn_connection_set_user(pn_connection_t *connection, const char *u
* Set the authentication password for a client connection
*
* It is necessary to set the username and password before binding the connection
- * to a trasnport and it isn't allowed to change them after the binding.
+ * to a transport and it isn't allowed to change them after the binding.
*
* Note that the password is write only and has no accessor as the underlying
* implementation should be zeroing the password after use to avoid the password
@@ -393,7 +393,7 @@ PN_EXTERN const char *pn_connection_remote_hostname(pn_connection_t *connection)
*
* This operation will return a pointer to a ::pn_data_t object that
* is valid until the connection object is freed. Any data contained
- * by the ::pn_data_t object will be sent as the offered capabilites
+ * by the ::pn_data_t object will be sent as the offered capabilities
* for the parent connection object. Note that this MUST take the form
* of an array of symbols to be valid.
*
@@ -411,7 +411,7 @@ PN_EXTERN pn_data_t *pn_connection_offered_capabilities(pn_connection_t *connect
*
* This operation will return a pointer to a ::pn_data_t object that
* is valid until the connection object is freed. Any data contained
- * by the ::pn_data_t object will be sent as the desired capabilites
+ * by the ::pn_data_t object will be sent as the desired capabilities
* for the parent connection object. Note that this MUST take the form
* of an array of symbols to be valid.
*
@@ -441,7 +441,7 @@ PN_EXTERN pn_data_t *pn_connection_desired_capabilities(pn_connection_t *connect
PN_EXTERN pn_data_t *pn_connection_properties(pn_connection_t *connection);
/**
- * Access the AMQP offered capabilites supplied by the remote
+ * Access the AMQP offered capabilities supplied by the remote
* connection endpoint.
*
* This operation will return a pointer to a ::pn_data_t object that
@@ -455,7 +455,7 @@ PN_EXTERN pn_data_t *pn_connection_properties(pn_connection_t *connection);
PN_EXTERN pn_data_t *pn_connection_remote_offered_capabilities(pn_connection_t *connection);
/**
- * Access the AMQP desired capabilites supplied by the remote
+ * Access the AMQP desired capabilities supplied by the remote
* connection endpoint.
*
* This operation will return a pointer to a ::pn_data_t object that
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/connection_driver.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/connection_driver.h b/proton-c/include/proton/connection_driver.h
index d0ad150..8e39551 100644
--- a/proton-c/include/proton/connection_driver.h
+++ b/proton-c/include/proton/connection_driver.h
@@ -241,13 +241,13 @@ PN_EXTERN pn_connection_driver_t* pn_event_batch_connection_driver(pn_event_batc
/**
* The write side of the transport is closed, it will no longer produce bytes to write to
- * external IO. Synonynm for PN_TRANSPORT_HEAD_CLOSED
+ * external IO. Synonym for PN_TRANSPORT_HEAD_CLOSED
*/
#define PN_TRANSPORT_WRITE_CLOSED PN_TRANSPORT_HEAD_CLOSED
/**
* The read side of the transport is closed, it will no longer read bytes from external
- * IO. Alisas for PN_TRANSPORT_TAIL_CLOSED
+ * IO. Alias for PN_TRANSPORT_TAIL_CLOSED
*/
#define PN_TRANSPORT_READ_CLOSED PN_TRANSPORT_TAIL_CLOSED
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/delivery.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/delivery.h b/proton-c/include/proton/delivery.h
index 8e7f421..a4dc1b6 100644
--- a/proton-c/include/proton/delivery.h
+++ b/proton-c/include/proton/delivery.h
@@ -324,8 +324,8 @@ PN_EXTERN bool pn_delivery_buffered(pn_delivery_t *delivery);
* operations. A readable delivery indicates message data is waiting
* to be read. A writable delivery indicates that message data may be
* sent. An updated delivery indicates that the delivery's disposition
- * has changed. A delivery will never be both readable and writible,
- * but it may be both readable and updated or both writiable and
+ * has changed. A delivery will never be both readable and writable,
+ * but it may be both readable and updated or both writable and
* updated.
*
* @param[in] connection the connection
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/event.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/event.h b/proton-c/include/proton/event.h
index fc2e5ea..206828b 100644
--- a/proton-c/include/proton/event.h
+++ b/proton-c/include/proton/event.h
@@ -344,7 +344,7 @@ typedef enum {
PN_PROACTOR_INACTIVE,
/**
- * The listener is listeneing.
+ * The listener is listening.
* Events of this type point to the @ref pn_listener_t.
*/
PN_LISTENER_OPEN
@@ -562,7 +562,7 @@ PN_EXTERN pn_event_t *pn_event_batch_next(pn_event_batch_t *batch);
/**
* @cond INTERNAL
*
- * pn_event_batch_next() can be re-implemented for different behaviors in different contextxs.
+ * pn_event_batch_next() can be re-implemented for different behaviors in different contexts.
*/
struct pn_event_batch_t {
pn_event_t *(*next_event)(pn_event_batch_t *batch);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e22ca536/proton-c/include/proton/link.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/link.h b/proton-c/include/proton/link.h
index 40f8f62..8099a32 100644
--- a/proton-c/include/proton/link.h
+++ b/proton-c/include/proton/link.h
@@ -476,7 +476,7 @@ typedef enum {
initially unsettled. */
PN_SND_SETTLED = 1, /**< The sender will send all deliveries settled
to the receiver. */
- PN_SND_MIXED = 2 /**< The sender may send a mixure of settled and
+ PN_SND_MIXED = 2 /**< The sender may send a mixture of settled and
unsettled deliveries. */
} pn_snd_settle_mode_t;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org