qpid_proton 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/cproton/cproton.c +863 -75
- data/lib/codec/data.rb +589 -815
- data/lib/codec/mapping.rb +142 -126
- data/lib/core/condition.rb +89 -0
- data/lib/core/connection.rb +188 -228
- data/lib/core/connection_driver.rb +202 -0
- data/lib/core/container.rb +366 -0
- data/lib/core/delivery.rb +76 -251
- data/lib/core/disposition.rb +21 -35
- data/lib/core/endpoint.rb +21 -53
- data/lib/core/event.rb +156 -0
- data/lib/core/exceptions.rb +109 -106
- data/lib/core/link.rb +24 -49
- data/lib/core/listener.rb +82 -0
- data/lib/core/message.rb +59 -155
- data/lib/core/messaging_handler.rb +190 -0
- data/lib/core/receiver.rb +38 -7
- data/lib/core/sasl.rb +43 -46
- data/lib/core/sender.rb +55 -32
- data/lib/core/session.rb +58 -58
- data/lib/core/ssl.rb +5 -13
- data/lib/core/ssl_details.rb +1 -2
- data/lib/core/ssl_domain.rb +5 -8
- data/lib/core/terminus.rb +62 -30
- data/lib/core/tracker.rb +45 -0
- data/lib/core/transfer.rb +121 -0
- data/lib/core/transport.rb +62 -97
- data/lib/core/uri.rb +73 -0
- data/lib/core/url.rb +11 -7
- data/lib/handler/adapter.rb +78 -0
- data/lib/handler/messaging_adapter.rb +127 -0
- data/lib/handler/messaging_handler.rb +128 -178
- data/lib/handler/reactor_messaging_adapter.rb +158 -0
- data/lib/messenger/messenger.rb +9 -8
- data/lib/messenger/subscription.rb +1 -2
- data/lib/messenger/tracker.rb +1 -2
- data/lib/messenger/tracker_status.rb +1 -2
- data/lib/qpid_proton.rb +36 -66
- data/lib/reactor/container.rb +40 -234
- data/lib/types/array.rb +73 -130
- data/lib/types/described.rb +2 -44
- data/lib/types/hash.rb +19 -56
- data/lib/types/strings.rb +1 -2
- data/lib/types/type.rb +68 -0
- data/lib/util/{handler.rb → deprecation.rb} +22 -15
- data/lib/util/error_handler.rb +4 -25
- data/lib/util/timeout.rb +1 -2
- data/lib/util/version.rb +1 -2
- data/lib/util/wrapper.rb +58 -38
- metadata +16 -33
- data/lib/core/base_handler.rb +0 -31
- data/lib/core/selectable.rb +0 -130
- data/lib/event/collector.rb +0 -148
- data/lib/event/event.rb +0 -318
- data/lib/event/event_base.rb +0 -91
- data/lib/event/event_type.rb +0 -71
- data/lib/handler/acking.rb +0 -70
- data/lib/handler/c_adaptor.rb +0 -47
- data/lib/handler/c_flow_controller.rb +0 -33
- data/lib/handler/endpoint_state_handler.rb +0 -217
- data/lib/handler/incoming_message_handler.rb +0 -74
- data/lib/handler/outgoing_message_handler.rb +0 -100
- data/lib/handler/wrapped_handler.rb +0 -76
- data/lib/reactor/acceptor.rb +0 -41
- data/lib/reactor/backoff.rb +0 -41
- data/lib/reactor/connector.rb +0 -115
- data/lib/reactor/global_overrides.rb +0 -44
- data/lib/reactor/link_option.rb +0 -90
- data/lib/reactor/reactor.rb +0 -196
- data/lib/reactor/session_per_connection.rb +0 -45
- data/lib/reactor/ssl_config.rb +0 -41
- data/lib/reactor/task.rb +0 -39
- data/lib/reactor/urls.rb +0 -45
- data/lib/util/class_wrapper.rb +0 -54
- data/lib/util/condition.rb +0 -47
- data/lib/util/constants.rb +0 -85
- data/lib/util/engine.rb +0 -82
- data/lib/util/reactor.rb +0 -32
- data/lib/util/swig_helper.rb +0 -114
- data/lib/util/uuid.rb +0 -32
data/lib/core/delivery.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
#--
|
2
1
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
2
|
# or more contributor license agreements. See the NOTICE file
|
4
3
|
# distributed with this work for additional information
|
5
4
|
# regarding copyright ownership. The ASF licenses this file
|
6
5
|
# to you under the Apache License, Version 2.0 (the
|
7
6
|
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
7
|
#
|
10
8
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
9
|
#
|
@@ -15,257 +13,84 @@
|
|
15
13
|
# KIND, either express or implied. See the License for the
|
16
14
|
# specific language governing permissions and limitations
|
17
15
|
# under the License.
|
18
|
-
#++
|
19
16
|
|
20
|
-
module Qpid::Proton
|
21
|
-
|
22
|
-
# A Delivery maintains detail on the delivery of data to an endpoint.
|
23
|
-
#
|
24
|
-
# A Delivery has a single parent Qpid::Proton::Link
|
25
|
-
#
|
26
|
-
# @example
|
27
|
-
#
|
28
|
-
# # SCENARIO: An event comes in notifying that data has been delivered to
|
29
|
-
# # the local endpoint. A Delivery object can be used to check
|
30
|
-
# # the details of the delivery.
|
31
|
-
#
|
32
|
-
# delivery = @event.delivery
|
33
|
-
# if delivery.readable? && !delivery.partial?
|
34
|
-
# # decode the incoming message
|
35
|
-
# msg = Qpid::Proton::Message.new
|
36
|
-
# msg.decode(link.receive(delivery.pending))
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
class Delivery
|
40
|
-
|
41
|
-
# @private
|
42
|
-
include Util::Wrapper
|
43
|
-
|
44
|
-
# @private
|
45
|
-
def self.wrap(impl) # :nodoc:
|
46
|
-
return nil if impl.nil?
|
47
|
-
self.fetch_instance(impl, :pn_delivery_attachments) || Delivery.new(impl)
|
48
|
-
end
|
49
|
-
|
50
|
-
# @private
|
51
|
-
def initialize(impl)
|
52
|
-
@impl = impl
|
53
|
-
@local = Disposition.new(Cproton.pn_delivery_local(impl), true)
|
54
|
-
@remote = Disposition.new(Cproton.pn_delivery_remote(impl), false)
|
55
|
-
self.class.store_instance(self, :pn_delivery_attachments)
|
56
|
-
end
|
57
|
-
|
58
|
-
# @private
|
59
|
-
include Util::SwigHelper
|
60
|
-
|
61
|
-
# @private
|
62
|
-
PROTON_METHOD_PREFIX = "pn_delivery"
|
63
|
-
|
64
|
-
# @!attribute [r] tag
|
65
|
-
#
|
66
|
-
# @return [String] The tag for the delivery.
|
67
|
-
#
|
68
|
-
proton_caller :tag
|
69
|
-
|
70
|
-
# @!attribute [r] writable?
|
71
|
-
#
|
72
|
-
# A delivery is considered writable if it is the current delivery on an
|
73
|
-
# outgoing link, and the link has positive credit.
|
74
|
-
#
|
75
|
-
# @return [Boolean] Returns if a delivery is writable.
|
76
|
-
#
|
77
|
-
proton_caller :writable?
|
78
|
-
|
79
|
-
# @!attribute [r] readable?
|
80
|
-
#
|
81
|
-
# A delivery is considered readable if it is the current delivery on an
|
82
|
-
# incoming link.
|
83
|
-
#
|
84
|
-
# @return [Boolean] Returns if a delivery is readable.
|
85
|
-
#
|
86
|
-
proton_caller :readable?
|
87
|
-
# @!attribute [r] updated?
|
88
|
-
#
|
89
|
-
# A delivery is considered updated whenever the peer communicates a new
|
90
|
-
# disposition for the dlievery. Once a delivery becomes updated, it will
|
91
|
-
# remain so until cleared.
|
92
|
-
#
|
93
|
-
# @return [Boolean] Returns if a delivery is updated.
|
94
|
-
#
|
95
|
-
# @see #clear
|
96
|
-
#
|
97
|
-
proton_caller :updated?
|
98
|
-
|
99
|
-
# @!method clear
|
100
|
-
#
|
101
|
-
# Clear the updated flag for a delivery.
|
102
|
-
#
|
103
|
-
proton_caller :clear
|
104
|
-
|
105
|
-
# @!attribute [r] pending
|
106
|
-
#
|
107
|
-
# @return [Integer] Return the amount of pending message data for the
|
108
|
-
# delivery.
|
109
|
-
#
|
110
|
-
proton_caller :pending
|
111
|
-
|
112
|
-
# @!attribute [r] partial?
|
113
|
-
#
|
114
|
-
# @return [Boolean] Returns if the delivery has only partial message data.
|
115
|
-
#
|
116
|
-
proton_caller :partial?
|
117
|
-
|
118
|
-
# @!attribute [r] settled?
|
119
|
-
#
|
120
|
-
# @return [Boolean] Returns if the delivery is remotely settled.
|
121
|
-
#
|
122
|
-
proton_caller :settled?
|
123
|
-
|
124
|
-
|
125
|
-
# @!method settle
|
126
|
-
#
|
127
|
-
# Settles a delivery.
|
128
|
-
#
|
129
|
-
# A settled delivery can never be used again.
|
130
|
-
#
|
131
|
-
proton_caller :settle
|
132
|
-
|
133
|
-
# @!method dump
|
134
|
-
#
|
135
|
-
# Utility function for printing details of a delivery.
|
136
|
-
#
|
137
|
-
proton_caller :dump
|
138
|
-
|
139
|
-
# @!attribute [r] buffered?
|
140
|
-
#
|
141
|
-
# A delivery that is buffered has not yet been written to the wire.
|
142
|
-
#
|
143
|
-
# Note that returning false does not imply that a delivery was definitely
|
144
|
-
# written to the wire. If false is returned, it is not known whether the
|
145
|
-
# delivery was actually written to the wire or not.
|
146
|
-
#
|
147
|
-
# @return [Boolean] Returns if the delivery is buffered.
|
148
|
-
#
|
149
|
-
proton_caller :buffered?
|
150
|
-
|
151
|
-
include Util::Engine
|
152
|
-
|
153
|
-
def update(state)
|
154
|
-
impl = @local.impl
|
155
|
-
object_to_data(@local.data, Cproton.pn_disposition_data(impl))
|
156
|
-
object_to_data(@local.annotations, Cproton.pn_disposition_annotations(impl))
|
157
|
-
object_to_data(@local.condition, Cproton.pn_disposition_condition(impl))
|
158
|
-
Cproton.pn_delivery_update(@impl, state)
|
159
|
-
end
|
160
|
-
|
161
|
-
# Returns the local disposition state for the delivery.
|
162
|
-
#
|
163
|
-
# @return [Disposition] The local disposition state.
|
164
|
-
#
|
165
|
-
def local_state
|
166
|
-
Cproton.pn_delivery_local_state(@impl)
|
167
|
-
end
|
168
|
-
|
169
|
-
# Returns the remote disposition state for the delivery.
|
170
|
-
#
|
171
|
-
# @return [Disposition] The remote disposition state.
|
172
|
-
#
|
173
|
-
def remote_state
|
174
|
-
Cproton.pn_delivery_remote_state(@impl)
|
175
|
-
end
|
176
|
-
|
177
|
-
# Returns the next delivery on the connection that has pending operations.
|
178
|
-
#
|
179
|
-
# @return [Delivery, nil] The next delivery, or nil if there are none.
|
180
|
-
#
|
181
|
-
# @see Connection#work_head
|
182
|
-
#
|
183
|
-
def work_next
|
184
|
-
Delivery.wrap(Cproton.pn_work_next(@impl))
|
185
|
-
end
|
186
|
-
|
187
|
-
# Returns the parent link.
|
188
|
-
#
|
189
|
-
# @return [Link] The parent link.
|
190
|
-
#
|
191
|
-
def link
|
192
|
-
Link.wrap(Cproton.pn_delivery_link(@impl))
|
193
|
-
end
|
194
|
-
|
195
|
-
# Returns the parent session.
|
196
|
-
#
|
197
|
-
# @return [Session] The session.
|
198
|
-
#
|
199
|
-
def session
|
200
|
-
self.link.session
|
201
|
-
end
|
202
|
-
|
203
|
-
# Returns the parent connection.
|
204
|
-
#
|
205
|
-
# @return [Connection] The connection.
|
206
|
-
#
|
207
|
-
def connection
|
208
|
-
self.session.connection
|
209
|
-
end
|
210
17
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
#
|
220
|
-
def
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
# @
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
#
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
#
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
18
|
+
module Qpid::Proton
|
19
|
+
# Allow a {Receiver} to indicate the status of a received message to the {Sender}
|
20
|
+
class Delivery < Transfer
|
21
|
+
def initialize(*args) super; @message = nil; end
|
22
|
+
|
23
|
+
# @return [Receiver] The parent {Receiver} link.
|
24
|
+
def receiver() link; end
|
25
|
+
|
26
|
+
# Accept the receiveed message.
|
27
|
+
def accept() settle ACCEPTED; end
|
28
|
+
|
29
|
+
# Reject a message, indicating to the sender that is invalid and should
|
30
|
+
# never be delivered again to this or any other receiver.
|
31
|
+
def reject() settle REJECTED; end
|
32
|
+
|
33
|
+
# Release a message, indicating to the sender that it was not processed
|
34
|
+
# but may be delivered again to this or another receiver.
|
35
|
+
#
|
36
|
+
# @param opts [Hash] Instructions to the sender to modify re-delivery.
|
37
|
+
# To allow re-delivery with no modifications at all use +release(nil)+
|
38
|
+
#
|
39
|
+
# @option opts [Boolean] :failed (true) Instruct the sender to increase
|
40
|
+
# {Message#delivery_count} so future receivers will know there was a
|
41
|
+
# previous failed delivery.
|
42
|
+
#
|
43
|
+
# @option opts [Boolean] :undeliverable (false) Instruct the sender that this
|
44
|
+
# message should never be re-delivered to this receiver, although it may be
|
45
|
+
# delivered other receivers.
|
46
|
+
#
|
47
|
+
# @option opts [Hash] :annotations Instruct the sender to update the
|
48
|
+
# {Message#annotations} with these +key=>value+ pairs before re-delivery,
|
49
|
+
# replacing existing entries in {Message#annotations} with the same key.
|
50
|
+
def release(opts = nil)
|
51
|
+
opts = { :failed => false } if (opts == false) # deprecated
|
52
|
+
failed = !opts || opts.fetch(:failed, true)
|
53
|
+
undeliverable = opts && opts[:undeliverable]
|
54
|
+
annotations = opts && opts[:annotations]
|
55
|
+
annotations = nil if annotations && annotations.empty?
|
56
|
+
if failed || undeliverable || annotations
|
57
|
+
d = Cproton.pn_delivery_local(@impl)
|
58
|
+
Cproton.pn_disposition_set_failed(d, true) if failed
|
59
|
+
Cproton.pn_disposition_set_undeliverable(d, true) if undeliverable
|
60
|
+
Codec::Data.from_object(Cproton.pn_disposition_annotations(d), annotations) if annotations
|
61
|
+
settle(MODIFIED)
|
62
|
+
else
|
63
|
+
settle(RELEASED)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# @deprecated use {#release} with modification options
|
68
|
+
def modify()
|
69
|
+
deprecated __method__, "release(modification_options)"
|
70
|
+
release failed=>true
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Boolean] True if the transfer was aborted by the sender.
|
74
|
+
proton_caller :aborted?
|
75
|
+
|
76
|
+
# @return true if the incoming message is complete, call {#message} to retrieve it.
|
77
|
+
def complete?() readable? && !aborted? && !partial?; end
|
78
|
+
|
79
|
+
# Get the message from the delivery.
|
80
|
+
# @return [Message] The message
|
81
|
+
# @raise [AbortedError] if the message has been aborted (check with {#aborted?}
|
82
|
+
# @raise [UnderflowError] if the message is incomplete (check with {#complete?}
|
83
|
+
# @raise [::ArgumentError] if the delivery is not the current delivery on a receiving link.
|
84
|
+
def message
|
85
|
+
unless @message
|
86
|
+
raise AbortedError, "message aborted by sender" if aborted?
|
87
|
+
raise UnderflowError, "incoming message incomplete" if partial?
|
88
|
+
raise ArgumentError, "no incoming message" unless readable?
|
89
|
+
@message = Message.new
|
90
|
+
@message.decode(link.receive(pending))
|
91
|
+
link.advance
|
92
|
+
end
|
93
|
+
@message
|
267
94
|
end
|
268
|
-
|
269
95
|
end
|
270
|
-
|
271
96
|
end
|
data/lib/core/disposition.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#--
|
2
1
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
2
|
# or more contributor license agreements. See the NOTICE file
|
4
3
|
# distributed with this work for additional information
|
@@ -15,38 +14,31 @@
|
|
15
14
|
# KIND, either express or implied. See the License for the
|
16
15
|
# specific language governing permissions and limitations
|
17
16
|
# under the License.
|
18
|
-
|
17
|
+
|
19
18
|
|
20
19
|
module Qpid::Proton
|
21
20
|
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# Every delivery contains both a local and a remote disposition. The local
|
25
|
-
# disposition holds the local state of the delivery, and the remote
|
26
|
-
# disposition holds the *last known* remote state of the delivery.
|
27
|
-
#
|
21
|
+
# @deprecated use {Delivery}
|
28
22
|
class Disposition
|
23
|
+
include Util::Deprecation
|
29
24
|
|
30
|
-
|
25
|
+
# @private
|
26
|
+
PROTON_METHOD_PREFIX = "pn_disposition"
|
27
|
+
# @private
|
28
|
+
include Util::Wrapper
|
31
29
|
|
32
|
-
# Indicates the delivery was received.
|
33
|
-
self.add_constant(:RECEIVED, Cproton::PN_RECEIVED)
|
34
|
-
# Indicates the delivery was accepted.
|
35
|
-
self.add_constant(:ACCEPTED, Cproton::PN_ACCEPTED)
|
36
|
-
# Indicates the delivery was rejected.
|
37
|
-
self.add_constant(:REJECTED, Cproton::PN_REJECTED)
|
38
|
-
# Indicates the delivery was released.
|
39
|
-
self.add_constant(:RELEASED, Cproton::PN_RELEASED)
|
40
|
-
# Indicates the delivery was modified.
|
41
|
-
self.add_constant(:MODIFIED, Cproton::PN_MODIFIED)
|
42
30
|
|
43
|
-
|
44
|
-
|
31
|
+
ACCEPTED = Cproton::PN_ACCEPTED
|
32
|
+
REJECTED = Cproton::PN_REJECTED
|
33
|
+
RELEASED = Cproton::PN_RELEASED
|
34
|
+
MODIFIED = Cproton::PN_MODIFIED
|
35
|
+
RECEIVED = Cproton::PN_RECEIVED
|
45
36
|
|
46
37
|
attr_reader :impl
|
47
38
|
|
48
39
|
# @private
|
49
40
|
def initialize(impl, local)
|
41
|
+
deprecated self.class, Delivery
|
50
42
|
@impl = impl
|
51
43
|
@local = local
|
52
44
|
@data = nil
|
@@ -54,35 +46,29 @@ module Qpid::Proton
|
|
54
46
|
@annotations = nil
|
55
47
|
end
|
56
48
|
|
57
|
-
# @private
|
58
|
-
include Util::SwigHelper
|
59
|
-
|
60
|
-
# @private
|
61
|
-
PROTON_METHOD_PREFIX = "pn_disposition"
|
62
|
-
|
63
49
|
# @!attribute section_number
|
64
50
|
#
|
65
51
|
# @return [Integer] The section number of the disposition.
|
66
52
|
#
|
67
|
-
|
53
|
+
proton_set_get :section_number
|
68
54
|
|
69
55
|
# @!attribute section_offset
|
70
56
|
#
|
71
57
|
# @return [Integer] The section offset of the disposition.
|
72
58
|
#
|
73
|
-
|
59
|
+
proton_set_get :section_offset
|
74
60
|
|
75
61
|
# @!attribute failed?
|
76
62
|
#
|
77
63
|
# @return [Boolean] The failed flag.
|
78
64
|
#
|
79
|
-
|
65
|
+
proton_set_is :failed
|
80
66
|
|
81
67
|
# @!attribute undeliverable?
|
82
68
|
#
|
83
69
|
# @return [Boolean] The undeliverable flag.
|
84
70
|
#
|
85
|
-
|
71
|
+
proton_set_is :undeliverable
|
86
72
|
|
87
73
|
# Sets the data for the disposition.
|
88
74
|
#
|
@@ -103,7 +89,7 @@ module Qpid::Proton
|
|
103
89
|
if @local
|
104
90
|
@data
|
105
91
|
else
|
106
|
-
|
92
|
+
Codec::Data.to_object(Cproton.pn_disposition_data(@impl))
|
107
93
|
end
|
108
94
|
end
|
109
95
|
|
@@ -126,11 +112,11 @@ module Qpid::Proton
|
|
126
112
|
if @local
|
127
113
|
@annotations
|
128
114
|
else
|
129
|
-
|
115
|
+
Codec::Data.to_object(Cproton.pn_disposition_annotations(@impl))
|
130
116
|
end
|
131
117
|
end
|
132
118
|
|
133
|
-
|
119
|
+
# Sets the condition for the disposition.
|
134
120
|
#
|
135
121
|
# @param condition [Codec::Data] The condition.
|
136
122
|
#
|
@@ -149,7 +135,7 @@ module Qpid::Proton
|
|
149
135
|
if @local
|
150
136
|
@condition
|
151
137
|
else
|
152
|
-
|
138
|
+
Condition.convert(Cproton.pn_disposition_condition(@impl))
|
153
139
|
end
|
154
140
|
end
|
155
141
|
|