qpid_proton 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +176 -27
- data/TODO +2 -8
- data/ext/cproton/cproton.c +278 -65
- data/lib/codec/data.rb +32 -36
- data/lib/codec/mapping.rb +3 -3
- data/lib/core/connection.rb +14 -5
- data/lib/core/delivery.rb +1 -1
- data/lib/core/disposition.rb +2 -2
- data/lib/core/link.rb +10 -10
- data/lib/core/message.rb +8 -21
- data/lib/core/receiver.rb +3 -3
- data/lib/core/sasl.rb +68 -36
- data/lib/core/sender.rb +3 -3
- data/lib/core/session.rb +5 -5
- data/lib/core/ssl_domain.rb +1 -1
- data/lib/core/terminus.rb +5 -5
- data/lib/core/transport.rb +19 -17
- data/lib/core/url.rb +3 -3
- data/lib/handler/acking.rb +1 -1
- data/lib/handler/endpoint_state_handler.rb +1 -1
- data/lib/handler/messaging_handler.rb +1 -3
- data/lib/messenger/messenger.rb +3 -3
- data/lib/reactor/connector.rb +45 -28
- data/lib/reactor/container.rb +45 -47
- data/lib/reactor/reactor.rb +2 -2
- data/lib/reactor/urls.rb +6 -1
- data/lib/util/condition.rb +2 -0
- data/lib/util/engine.rb +1 -1
- data/lib/util/swig_helper.rb +1 -1
- metadata +6 -5
data/lib/core/url.rb
CHANGED
@@ -28,11 +28,13 @@ module Qpid::Proton
|
|
28
28
|
attr_reader :port
|
29
29
|
attr_reader :path
|
30
30
|
|
31
|
+
# Parse a string, return a new URL
|
32
|
+
# @param url [#to_s] the URL string
|
31
33
|
def initialize(url = nil, options = {})
|
32
34
|
options[:defaults] = true
|
33
35
|
|
34
36
|
if url
|
35
|
-
@url = Cproton.pn_url_parse(url)
|
37
|
+
@url = Cproton.pn_url_parse(url.to_s)
|
36
38
|
if @url.nil?
|
37
39
|
raise ::ArgumentError.new("invalid url: #{url}")
|
38
40
|
end
|
@@ -71,7 +73,5 @@ module Qpid::Proton
|
|
71
73
|
@host = @host || "0.0.0.0"
|
72
74
|
@port = @port || 5672
|
73
75
|
end
|
74
|
-
|
75
76
|
end
|
76
|
-
|
77
77
|
end
|
data/lib/handler/acking.rb
CHANGED
@@ -58,7 +58,7 @@ module Qpid::Proton::Handler
|
|
58
58
|
# is specified.
|
59
59
|
#
|
60
60
|
# @param delivery [Qpid::Proton::Delivery] The delivery.
|
61
|
-
# @param state [
|
61
|
+
# @param state [Integer] The delivery state.
|
62
62
|
#
|
63
63
|
def settle(delivery, state = nil)
|
64
64
|
delivery.update(state) unless state.nil?
|
@@ -119,7 +119,7 @@ module Qpid::Proton::Handler
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def on_connection_opened(event)
|
122
|
-
Qpid::Proton::Event.dispatch(@delegate, :
|
122
|
+
Qpid::Proton::Event.dispatch(@delegate, :on_connection_opened, event) if !@delegate.nil?
|
123
123
|
end
|
124
124
|
|
125
125
|
def on_session_opened(event)
|
@@ -21,15 +21,13 @@ module Qpid::Proton::Handler
|
|
21
21
|
|
22
22
|
# A general purpose handler that simplifies processing events.
|
23
23
|
#
|
24
|
-
# @example
|
25
|
-
#
|
26
24
|
class MessagingHandler < Qpid::Proton::BaseHandler
|
27
25
|
|
28
26
|
attr_reader :handlers
|
29
27
|
|
30
28
|
# Creates a new instance.
|
31
29
|
#
|
32
|
-
# @param [
|
30
|
+
# @param [Integer] prefetch
|
33
31
|
# @param [Boolean] auto_accept
|
34
32
|
# @param [Boolean] auto_settle
|
35
33
|
# @param [Boolean] peer_close_is_error
|
data/lib/messenger/messenger.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
module Qpid::Proton::Messenger
|
21
|
-
|
21
|
+
#
|
22
22
|
# The +Messenger+ class defines a high level interface for
|
23
23
|
# sending and receiving Messages. Every Messenger contains
|
24
24
|
# a single logical queue of incoming messages and a single
|
@@ -37,7 +37,7 @@ module Qpid::Proton::Messenger
|
|
37
37
|
#
|
38
38
|
# The put method copies its Message to the outgoing queue, and may
|
39
39
|
# send queued messages if it can do so without blocking. The send
|
40
|
-
# method blocks until it has sent the requested number of
|
40
|
+
# method blocks until it has sent the requested number of
|
41
41
|
# or until a timeout interrupts the attempt.
|
42
42
|
#
|
43
43
|
# Similarly, the recv method receives messages into the incoming
|
@@ -694,7 +694,7 @@ module Qpid::Proton::Messenger
|
|
694
694
|
end
|
695
695
|
|
696
696
|
def valid_window?(window)
|
697
|
-
!window.nil? &&
|
697
|
+
!window.nil? && window.is_a?(Numeric)
|
698
698
|
end
|
699
699
|
|
700
700
|
end
|
data/lib/reactor/connector.rb
CHANGED
@@ -21,16 +21,24 @@ module Qpid::Proton::Reactor
|
|
21
21
|
|
22
22
|
class Connector < Qpid::Proton::BaseHandler
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def initialize(connection, url, opts)
|
25
|
+
@connection, @opts = connection, opts
|
26
|
+
@urls = URLs.new(url) if url
|
27
|
+
opts.each do |k,v|
|
28
|
+
case k
|
29
|
+
when :url, :urls, :address
|
30
|
+
@urls = URLs.new(v) unless @urls
|
31
|
+
when :reconnect
|
32
|
+
@reconnect = v
|
33
|
+
end
|
34
|
+
end
|
35
|
+
raise ::ArgumentError.new("no url for connect") unless @urls
|
27
36
|
|
28
|
-
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@ssl_domain = nil
|
37
|
+
# TODO aconway 2017-08-17: review reconnect configuration and defaults
|
38
|
+
@reconnect = Backoff.new() unless @reconnect
|
39
|
+
@ssl_domain = SessionPerConnection.new # TODO seems this should be configurable
|
40
|
+
@connection.overrides = self
|
41
|
+
@connection.open
|
34
42
|
end
|
35
43
|
|
36
44
|
def on_connection_local_open(event)
|
@@ -38,10 +46,7 @@ module Qpid::Proton::Reactor
|
|
38
46
|
end
|
39
47
|
|
40
48
|
def on_connection_remote_open(event)
|
41
|
-
if
|
42
|
-
@reconnect.reset
|
43
|
-
@transport = nil
|
44
|
-
end
|
49
|
+
@reconnect.reset if @reconnect
|
45
50
|
end
|
46
51
|
|
47
52
|
def on_transport_tail_closed(event)
|
@@ -73,26 +78,38 @@ module Qpid::Proton::Reactor
|
|
73
78
|
end
|
74
79
|
|
75
80
|
def connect(connection)
|
76
|
-
url = @
|
81
|
+
url = @urls.next
|
82
|
+
transport = Qpid::Proton::Transport.new
|
83
|
+
@opts.each do |k,v|
|
84
|
+
case k
|
85
|
+
when :user
|
86
|
+
connection.user = v
|
87
|
+
when :password
|
88
|
+
connection.password = v
|
89
|
+
when :heartbeat
|
90
|
+
transport.idle_timeout = v.to_i
|
91
|
+
when :idle_timeout
|
92
|
+
transport.idle_timeout = v.(v*1000).to_i
|
93
|
+
when :sasl_enabled
|
94
|
+
transport.sasl if v
|
95
|
+
when :sasl_allow_insecure_mechs
|
96
|
+
transport.sasl.allow_insecure_mechs = v
|
97
|
+
when :sasl_allowed_mechs, :sasl_mechanisms
|
98
|
+
transport.sasl.allowed_mechs = v
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# TODO aconway 2017-08-11: hostname setting is incorrect, reactor only
|
77
103
|
connection.hostname = "#{url.host}:#{url.port}"
|
104
|
+
connection.user = url.username if url.username && !url.username.empty?
|
105
|
+
connection.password = url.password if url.password && !url.password.empty?
|
78
106
|
|
79
|
-
transport = Qpid::Proton::Transport.new
|
80
107
|
transport.bind(connection)
|
81
|
-
|
82
|
-
|
83
|
-
elsif (url.scheme == "amqps") && !@ssl_domain.nil?
|
108
|
+
|
109
|
+
if (url.scheme == "amqps") && @ssl_domain
|
84
110
|
@ssl = Qpid::Proton::SSL.new(transport, @ssl_domain)
|
85
|
-
@
|
86
|
-
elsif !url.username.nil?
|
87
|
-
sasl = transport.sasl
|
88
|
-
if url.username == "anonymous"
|
89
|
-
sasl.mechanisms("ANONYMOUS")
|
90
|
-
else
|
91
|
-
sasl.plain(url.username, url.password)
|
92
|
-
end
|
111
|
+
@ssl.peer_hostname = url.host
|
93
112
|
end
|
94
113
|
end
|
95
|
-
|
96
114
|
end
|
97
|
-
|
98
115
|
end
|
data/lib/reactor/container.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
module Qpid::Proton::Reactor
|
21
21
|
|
22
|
-
|
22
|
+
private
|
23
23
|
class InternalTransactionHandler < Qpid::Proton::Handler::OutgoingMessageHandler
|
24
24
|
|
25
25
|
def initialize
|
@@ -35,7 +35,7 @@ module Qpid::Proton::Reactor
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
public
|
39
39
|
# A representation of the AMQP concept of a container which, loosely
|
40
40
|
# speaking, is something that establishes links to or from another
|
41
41
|
# container on which messages are transferred.
|
@@ -43,9 +43,6 @@ module Qpid::Proton::Reactor
|
|
43
43
|
# This is an extension to the Reactor classthat adds convenience methods
|
44
44
|
# for creating instances of Qpid::Proton::Connection, Qpid::Proton::Sender
|
45
45
|
# and Qpid::Proton::Receiver.
|
46
|
-
#
|
47
|
-
# @example
|
48
|
-
#
|
49
46
|
class Container < Reactor
|
50
47
|
|
51
48
|
include Qpid::Proton::Util::Reactor
|
@@ -74,42 +71,45 @@ module Qpid::Proton::Reactor
|
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
77
|
-
#
|
74
|
+
# Initiate an AMQP connection.
|
78
75
|
#
|
79
|
-
# @param
|
76
|
+
# @param url [String] Connect to URL host:port, using user:password@ if present
|
77
|
+
# @param opts [Hash] Named options
|
78
|
+
# For backwards compatibility, can be called with a single parameter opts.
|
80
79
|
#
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
80
|
+
# @option opts [String] :url Connect to URL host:port using user:password@ if present.
|
81
|
+
# @option opts [String] :user user name for authentication if not given by URL
|
82
|
+
# @option opts [String] :password password for authentication if not given by URL
|
83
|
+
# @option opts [Numeric] :idle_timeout seconds before closing an idle connection,
|
84
|
+
# can be a fractional value.
|
85
|
+
# @option opts [Boolean] :sasl_enabled Enable or disable SASL.
|
86
|
+
# @option opts [Boolean] :sasl_allow_insecure_mechs Allow mechanisms that disclose clear text
|
87
|
+
# passwords, even over an insecure connection. By default, such mechanisms are only allowed
|
88
|
+
# when SSL is enabled.
|
89
|
+
# @option opts [String] :sasl_allowed_mechs the allowed SASL mechanisms for use on the connection.
|
90
|
+
#
|
91
|
+
# @option opts [String] :address *deprecated* use the :url option
|
92
|
+
# @option opts [Numeric] :heartbeat milliseconds before closing an idle connection.
|
93
|
+
# *deprecated* use :idle_timeout => heartbeat/1000
|
94
|
+
#
|
95
|
+
# @return [Connection] the new connection
|
96
|
+
#
|
97
|
+
def connect(url, opts = {})
|
98
|
+
# Backwards compatible with old connect(options)
|
99
|
+
if url.is_a? Hash and opts.empty?
|
100
|
+
opts = url
|
101
|
+
url = nil
|
101
102
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
conn.open
|
106
|
-
|
103
|
+
conn = self.connection(opts[:handler])
|
104
|
+
conn.container = self.container_id || generate_uuid
|
105
|
+
connector = Connector.new(conn, url, opts)
|
107
106
|
return conn
|
108
107
|
end
|
109
108
|
|
109
|
+
private
|
110
110
|
def _session(context)
|
111
111
|
if context.is_a?(Qpid::Proton::URL)
|
112
|
-
return
|
112
|
+
return _session(self.connect(:url => context))
|
113
113
|
elsif context.is_a?(Qpid::Proton::Session)
|
114
114
|
return context
|
115
115
|
elsif context.is_a?(Qpid::Proton::Connection)
|
@@ -123,16 +123,17 @@ module Qpid::Proton::Reactor
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
public
|
126
127
|
# Initiates the establishment of a link over which messages can be sent.
|
127
128
|
#
|
128
129
|
# @param context [String, URL] The context.
|
129
130
|
# @param opts [Hash] Additional options.
|
130
|
-
# @
|
131
|
-
# @
|
132
|
-
# @
|
133
|
-
# @
|
134
|
-
# @
|
135
|
-
# @
|
131
|
+
# @option opts [String, Qpid::Proton::URL] The target address.
|
132
|
+
# @option opts [String] :source The source address.
|
133
|
+
# @option opts [Boolean] :dynamic
|
134
|
+
# @option opts [Object] :handler
|
135
|
+
# @option opts [Object] :tag_generator The tag generator.
|
136
|
+
# @option opts [Hash] :options Addtional link options
|
136
137
|
#
|
137
138
|
# @return [Sender] The sender.
|
138
139
|
#
|
@@ -146,7 +147,7 @@ module Qpid::Proton::Reactor
|
|
146
147
|
target = context.path
|
147
148
|
end
|
148
149
|
|
149
|
-
session =
|
150
|
+
session = _session(context)
|
150
151
|
|
151
152
|
sender = session.sender(opts[:name] ||
|
152
153
|
id(session.connection.container,
|
@@ -155,7 +156,7 @@ module Qpid::Proton::Reactor
|
|
155
156
|
sender.target.address = target if target
|
156
157
|
sender.handler = opts[:handler] if !opts[:handler].nil?
|
157
158
|
sender.tag_generator = opts[:tag_generator] if !opts[:tag_gnenerator].nil?
|
158
|
-
|
159
|
+
_apply_link_options(opts[:options], sender)
|
159
160
|
sender.open
|
160
161
|
return sender
|
161
162
|
end
|
@@ -192,7 +193,7 @@ module Qpid::Proton::Reactor
|
|
192
193
|
source = context.path
|
193
194
|
end
|
194
195
|
|
195
|
-
session =
|
196
|
+
session = _session(context)
|
196
197
|
|
197
198
|
receiver = session.receiver(opts[:name] ||
|
198
199
|
id(session.connection.container,
|
@@ -201,7 +202,7 @@ module Qpid::Proton::Reactor
|
|
201
202
|
receiver.source.dynamic = true if opts.has_key?(:dynamic) && opts[:dynamic]
|
202
203
|
receiver.target.address = opts[:target] if !opts[:target].nil?
|
203
204
|
receiver.handler = opts[:handler] if !opts[:handler].nil?
|
204
|
-
|
205
|
+
_apply_link_options(opts[:options], receiver)
|
205
206
|
receiver.open
|
206
207
|
return receiver
|
207
208
|
end
|
@@ -236,10 +237,7 @@ module Qpid::Proton::Reactor
|
|
236
237
|
return acceptor
|
237
238
|
end
|
238
239
|
|
239
|
-
|
240
|
-
self.timeout = timeout unless timeout.nil?
|
241
|
-
self.process
|
242
|
-
end
|
240
|
+
private
|
243
241
|
|
244
242
|
def id(container, remote, local)
|
245
243
|
if !local.nil? && !remote.nil?
|
data/lib/reactor/reactor.rb
CHANGED
@@ -89,7 +89,7 @@ module Qpid::Proton::Reactor
|
|
89
89
|
|
90
90
|
# Returns the timeout period.
|
91
91
|
#
|
92
|
-
# @return [
|
92
|
+
# @return [Integer] The timeout period, in seconds.
|
93
93
|
#
|
94
94
|
def timeout
|
95
95
|
millis_to_timeout(Cproton.pn_reactor_get_timeout(@impl))
|
@@ -97,7 +97,7 @@ module Qpid::Proton::Reactor
|
|
97
97
|
|
98
98
|
# Sets the timeout period.
|
99
99
|
#
|
100
|
-
# @param timeout [
|
100
|
+
# @param timeout [Integer] The timeout, in seconds.
|
101
101
|
#
|
102
102
|
def timeout=(timeout)
|
103
103
|
Cproton.pn_reactor_set_timeout(@impl, timeout_to_millis(timeout))
|
data/lib/reactor/urls.rb
CHANGED
@@ -22,7 +22,12 @@ module Qpid::Proton::Reactor
|
|
22
22
|
class URLs
|
23
23
|
|
24
24
|
def initialize(values)
|
25
|
-
@values =
|
25
|
+
@values = values
|
26
|
+
if @values.is_a? Enumerable
|
27
|
+
@values = @values.map { |u| Qpid::Proton::URL.new(u) }
|
28
|
+
else
|
29
|
+
@values = [Qpid::Proton::URL.new(values)]
|
30
|
+
end
|
26
31
|
@iter = @values.each
|
27
32
|
end
|
28
33
|
|
data/lib/util/condition.rb
CHANGED
data/lib/util/engine.rb
CHANGED
@@ -25,7 +25,7 @@ module Qpid::Proton::Util
|
|
25
25
|
# Convenience method to receive messages from a delivery.
|
26
26
|
#
|
27
27
|
# @param delivery [Qpid::Proton::Delivery] The delivery.
|
28
|
-
# @param
|
28
|
+
# @param msg [Qpid::Proton::Message] The message to use.
|
29
29
|
#
|
30
30
|
# @return [Qpid::Proton::Message] the message
|
31
31
|
#
|
data/lib/util/swig_helper.rb
CHANGED
@@ -86,7 +86,7 @@ module Qpid::Proton::Util
|
|
86
86
|
proton_method = "#{self::PROTON_METHOD_PREFIX}_#{name}"
|
87
87
|
# drop the trailing '?' if this is a property method
|
88
88
|
proton_method = proton_method[0..-2] if proton_method.end_with? "?"
|
89
|
-
create_wrapper_method(name, proton_method)
|
89
|
+
create_wrapper_method(name, proton_method, options[:arg])
|
90
90
|
end
|
91
91
|
|
92
92
|
def proton_writer(name, options = {})
|
metadata
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qpid_proton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darryl L. Pierce
|
8
|
+
- Alan Conway
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: json
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "
|
18
|
+
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '0'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - "
|
25
|
+
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '0'
|
27
28
|
description: |
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.2.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Ruby language bindings for the Qpid Proton messaging framework
|