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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/ext/cproton/cproton.c +863 -75
  3. data/lib/codec/data.rb +589 -815
  4. data/lib/codec/mapping.rb +142 -126
  5. data/lib/core/condition.rb +89 -0
  6. data/lib/core/connection.rb +188 -228
  7. data/lib/core/connection_driver.rb +202 -0
  8. data/lib/core/container.rb +366 -0
  9. data/lib/core/delivery.rb +76 -251
  10. data/lib/core/disposition.rb +21 -35
  11. data/lib/core/endpoint.rb +21 -53
  12. data/lib/core/event.rb +156 -0
  13. data/lib/core/exceptions.rb +109 -106
  14. data/lib/core/link.rb +24 -49
  15. data/lib/core/listener.rb +82 -0
  16. data/lib/core/message.rb +59 -155
  17. data/lib/core/messaging_handler.rb +190 -0
  18. data/lib/core/receiver.rb +38 -7
  19. data/lib/core/sasl.rb +43 -46
  20. data/lib/core/sender.rb +55 -32
  21. data/lib/core/session.rb +58 -58
  22. data/lib/core/ssl.rb +5 -13
  23. data/lib/core/ssl_details.rb +1 -2
  24. data/lib/core/ssl_domain.rb +5 -8
  25. data/lib/core/terminus.rb +62 -30
  26. data/lib/core/tracker.rb +45 -0
  27. data/lib/core/transfer.rb +121 -0
  28. data/lib/core/transport.rb +62 -97
  29. data/lib/core/uri.rb +73 -0
  30. data/lib/core/url.rb +11 -7
  31. data/lib/handler/adapter.rb +78 -0
  32. data/lib/handler/messaging_adapter.rb +127 -0
  33. data/lib/handler/messaging_handler.rb +128 -178
  34. data/lib/handler/reactor_messaging_adapter.rb +158 -0
  35. data/lib/messenger/messenger.rb +9 -8
  36. data/lib/messenger/subscription.rb +1 -2
  37. data/lib/messenger/tracker.rb +1 -2
  38. data/lib/messenger/tracker_status.rb +1 -2
  39. data/lib/qpid_proton.rb +36 -66
  40. data/lib/reactor/container.rb +40 -234
  41. data/lib/types/array.rb +73 -130
  42. data/lib/types/described.rb +2 -44
  43. data/lib/types/hash.rb +19 -56
  44. data/lib/types/strings.rb +1 -2
  45. data/lib/types/type.rb +68 -0
  46. data/lib/util/{handler.rb → deprecation.rb} +22 -15
  47. data/lib/util/error_handler.rb +4 -25
  48. data/lib/util/timeout.rb +1 -2
  49. data/lib/util/version.rb +1 -2
  50. data/lib/util/wrapper.rb +58 -38
  51. metadata +16 -33
  52. data/lib/core/base_handler.rb +0 -31
  53. data/lib/core/selectable.rb +0 -130
  54. data/lib/event/collector.rb +0 -148
  55. data/lib/event/event.rb +0 -318
  56. data/lib/event/event_base.rb +0 -91
  57. data/lib/event/event_type.rb +0 -71
  58. data/lib/handler/acking.rb +0 -70
  59. data/lib/handler/c_adaptor.rb +0 -47
  60. data/lib/handler/c_flow_controller.rb +0 -33
  61. data/lib/handler/endpoint_state_handler.rb +0 -217
  62. data/lib/handler/incoming_message_handler.rb +0 -74
  63. data/lib/handler/outgoing_message_handler.rb +0 -100
  64. data/lib/handler/wrapped_handler.rb +0 -76
  65. data/lib/reactor/acceptor.rb +0 -41
  66. data/lib/reactor/backoff.rb +0 -41
  67. data/lib/reactor/connector.rb +0 -115
  68. data/lib/reactor/global_overrides.rb +0 -44
  69. data/lib/reactor/link_option.rb +0 -90
  70. data/lib/reactor/reactor.rb +0 -196
  71. data/lib/reactor/session_per_connection.rb +0 -45
  72. data/lib/reactor/ssl_config.rb +0 -41
  73. data/lib/reactor/task.rb +0 -39
  74. data/lib/reactor/urls.rb +0 -45
  75. data/lib/util/class_wrapper.rb +0 -54
  76. data/lib/util/condition.rb +0 -47
  77. data/lib/util/constants.rb +0 -85
  78. data/lib/util/engine.rb +0 -82
  79. data/lib/util/reactor.rb +0 -32
  80. data/lib/util/swig_helper.rb +0 -114
  81. data/lib/util/uuid.rb +0 -32
data/lib/core/session.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,7 +14,7 @@
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
 
@@ -24,15 +23,12 @@ module Qpid::Proton
24
23
  # A Session has a single parent Qpid::Proton::Connection instance.
25
24
  #
26
25
  class Session < Endpoint
27
-
28
- # @private
29
- include Util::Wrapper
30
-
31
- # @private
32
- include Util::SwigHelper
26
+ include Util::Deprecation
33
27
 
34
28
  # @private
35
29
  PROTON_METHOD_PREFIX = "pn_session"
30
+ # @private
31
+ include Util::Wrapper
36
32
 
37
33
  # @!attribute incoming_capacity
38
34
  #
@@ -43,10 +39,10 @@ module Qpid::Proton
43
39
  #
44
40
  # @return [Integer] The incoing capacity of the session, measured in bytes.
45
41
  #
46
- proton_accessor :incoming_capacity
42
+ proton_set_get :incoming_capacity
47
43
 
48
44
  # @private
49
- proton_reader :attachments
45
+ proton_get :attachments
50
46
 
51
47
  # @!attribute [r] outgoing_bytes
52
48
  #
@@ -60,13 +56,7 @@ module Qpid::Proton
60
56
  #
61
57
  proton_caller :incoming_bytes
62
58
 
63
- # @!method open
64
- # Opens the session.
65
- #
66
- # Once this operaton has completed, the state flag is updated.
67
- #
68
- # @see LOCAL_ACTIVE
69
- #
59
+ # Open the session
70
60
  proton_caller :open
71
61
 
72
62
  # @!attribute [r] state
@@ -87,28 +77,16 @@ module Qpid::Proton
87
77
  self.class.store_instance(self, :pn_session_attachments)
88
78
  end
89
79
 
90
- # Closed the session.
91
- #
92
- # Once this operation has completed, the state flag will be set. This may be
93
- # called without calling #open, in which case it is the equivalence of
94
- # calling #open and then close immediately.
95
- #
96
- def close
97
- self._update_condition
80
+ # Close the local end of the session. The remote end may or may not be closed.
81
+ # @param error [Condition] Optional error condition to send with the close.
82
+ def close(error=nil)
83
+ Condition.assign(_local_condition, error)
98
84
  Cproton.pn_session_close(@impl)
99
85
  end
100
86
 
101
- # Retrieves the next session from a given connection that matches the
102
- # specified state mask.
103
- #
104
- # When uses with Connection#session_head an application can access all of
105
- # the session son the connection that match the given state.
106
- #
107
- # @param state_mask [Integer] The state mask to match.
108
- #
109
- # @return [Session, nil] The next session if one matches, or nil.
110
- #
87
+ # @deprecated use {Connection#each_session}
111
88
  def next(state_mask)
89
+ deprecated __method__, "Connection#each_session"
112
90
  Session.wrap(Cproton.pn_session_next(@impl, state_mask))
113
91
  end
114
92
 
@@ -120,40 +98,62 @@ module Qpid::Proton
120
98
  Connection.wrap(Cproton.pn_session_connection(@impl))
121
99
  end
122
100
 
123
- # Constructs a new sender.
124
- #
125
- # Each sender between two AMQP containers must be uniquely named. Note that
126
- # this uniqueness cannot be enforced at the library level, so some
127
- # consideration should be taken in choosing link names.
128
- #
129
- # @param name [String] The link name.
130
- #
131
- # @return [Sender, nil] The sender, or nil if an error occurred.
132
- #
101
+ # @deprecated use {#open_sender}
133
102
  def sender(name)
134
- Sender.new(Cproton.pn_sender(@impl, name))
103
+ deprecated __method__, "open_sender"
104
+ Sender.new(Cproton.pn_sender(@impl, name));
135
105
  end
136
106
 
137
- # Constructs a new receiver.
138
- #
139
- # Each receiver between two AMQP containers must be uniquely named. Note
140
- # that this uniqueness cannot be enforced at the library level, so some
141
- # consideration should be taken in choosing link names.
142
- #
143
- # @param name [String] The link name.
144
- #
145
- # @return [Receiver, nil] The receiver, or nil if an error occurred.
146
- #
107
+ # @deprecated use {#open_receiver}
147
108
  def receiver(name)
109
+ deprecated __method__, "open_receiver"
148
110
  Receiver.new(Cproton.pn_receiver(@impl, name))
149
111
  end
150
112
 
151
- # @private
113
+ # Create and open a {Receiver} link, see {Receiver#open}
114
+ # @param opts [Hash] receiver options, see {Receiver#open}
115
+ # @return [Receiver]
116
+ def open_receiver(opts=nil)
117
+ name = opts[:name] rescue connection.link_name
118
+ Receiver.new(Cproton.pn_receiver(@impl, name)).open(opts)
119
+ end
120
+
121
+ # Create and open a {Sender} link, see {#open}
122
+ # @param opts [Hash] sender options, see {Sender#open}
123
+ # @return [Sender]
124
+ def open_sender(opts=nil)
125
+ name = opts[:name] rescue connection.link_name
126
+ Sender.new(Cproton.pn_sender(@impl, name)).open(opts)
127
+ end
128
+
129
+ # Get the links on this Session.
130
+ # @overload each_link
131
+ # @yieldparam l [Link] pass each link to block
132
+ # @overload each_link
133
+ # @return [Enumerator] enumerator over links
134
+ def each_link
135
+ return enum_for(:each_link) unless block_given?
136
+ l = Cproton.pn_link_head(Cproton.pn_session_connection(@impl), 0);
137
+ while l
138
+ link = Link.wrap(l)
139
+ yield link if link.session == self
140
+ l = Cproton.pn_link_next(l, 0)
141
+ end
142
+ self
143
+ end
144
+
145
+ # Get the {Sender} links - see {#each_link}
146
+ def each_sender() each_link.select { |l| l.sender? }; end
147
+
148
+ # Get the {Receiver} links - see {#each_link}
149
+ def each_receiver() each_link.select { |l| l.receiver? }; end
150
+
151
+ private
152
+
152
153
  def _local_condition
153
154
  Cproton.pn_session_condition(@impl)
154
155
  end
155
156
 
156
- # @private
157
157
  def _remote_condition # :nodoc:
158
158
  Cproton.pn_session_remote_condition(@impl)
159
159
  end
data/lib/core/ssl.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,7 +14,7 @@
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
 
@@ -52,7 +51,7 @@ module Qpid::Proton
52
51
  # @see #resume_status
53
52
  #
54
53
  class SSL
55
-
54
+
56
55
  # Session resume state is unkonnwn or not supported.
57
56
  RESUME_UNKNOWN = Cproton::PN_SSL_RESUME_UNKNOWN
58
57
  # Session renegotiated and not resumed.
@@ -60,17 +59,13 @@ module Qpid::Proton
60
59
  # Session resumed from the previous session.
61
60
  RESUME_REUSED = Cproton::PN_SSL_RESUME_REUSED
62
61
 
63
- # @private
64
- include Util::SwigHelper
65
-
66
62
  # @private
67
63
  PROTON_METHOD_PREFIX = "pn_ssl"
68
-
64
+ # @private
65
+ include Util::Wrapper
69
66
  # @private
70
67
  include Util::ErrorHandler
71
68
 
72
- can_raise_error :peer_hostname=, :error_class => SSLError
73
-
74
69
  # Returns whether SSL is supported.
75
70
  #
76
71
  # @return [Boolean] True if SSL support is available.
@@ -133,8 +128,7 @@ module Qpid::Proton
133
128
  #
134
129
  def protocol_name
135
130
  rc, name = Cproton.pn_ssl_get_protocol_name(@impl, 128)
136
- retur name if rc
137
- nil
131
+ name if rc
138
132
  end
139
133
 
140
134
  # Checks whether or not the state has resumed.
@@ -158,7 +152,5 @@ module Qpid::Proton
158
152
  raise SSLError.new if error < 0
159
153
  return name
160
154
  end
161
-
162
155
  end
163
-
164
156
  end
@@ -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,7 +14,7 @@
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
 
@@ -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,7 +14,7 @@
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
 
@@ -43,11 +42,6 @@ module Qpid::Proton
43
42
  # @private
44
43
  include Util::ErrorHandler
45
44
 
46
- can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
47
- can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
48
- can_raise_error :peer_authentication, :error_class => Qpid::Proton::SSLError
49
- can_raise_error :allow_unsecured_client, :error_class => Qpid::Proton::SSLError
50
-
51
45
  # @private
52
46
  attr_reader :impl
53
47
 
@@ -151,6 +145,9 @@ module Qpid::Proton
151
145
  Cproton.pn_ssl_domain_allow_unsecured_client(@impl);
152
146
  end
153
147
 
148
+ can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
149
+ can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
150
+ can_raise_error :peer_authentication, :error_class => Qpid::Proton::SSLError
151
+ can_raise_error :allow_unsecured_client, :error_class => Qpid::Proton::SSLError
154
152
  end
155
-
156
153
  end
data/lib/core/terminus.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,7 +14,7 @@
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
 
@@ -30,6 +29,7 @@ module Qpid::Proton
30
29
  # the Link.
31
30
  #
32
31
  class Terminus
32
+ include Util::Deprecation
33
33
 
34
34
  # Indicates a non-existent source or target terminus.
35
35
  UNSPECIFIED = Cproton::PN_UNSPECIFIED
@@ -65,11 +65,10 @@ module Qpid::Proton
65
65
  # The receives compete for messages.
66
66
  DIST_MODE_MOVE = Cproton::PN_DIST_MODE_MOVE
67
67
 
68
- # @private
69
- include Util::SwigHelper
70
-
71
68
  # @private
72
69
  PROTON_METHOD_PREFIX = "pn_terminus"
70
+ # @private
71
+ include Util::Wrapper
73
72
 
74
73
  # @!attribute type
75
74
  #
@@ -79,15 +78,15 @@ module Qpid::Proton
79
78
  # @see TARGET
80
79
  # @see COORDINATOR
81
80
  #
82
- proton_accessor :type
81
+ proton_set_get :type
83
82
 
84
83
  # @!attribute address
85
84
  #
86
85
  # @return [String] The terminus address.
87
86
  #
88
- proton_accessor :address
87
+ proton_set_get :address
89
88
 
90
- # @!attribute durability
89
+ # @!attribute durability_mode
91
90
  #
92
91
  # @return [Integer] The durability mode of the terminus.
93
92
  #
@@ -95,7 +94,11 @@ module Qpid::Proton
95
94
  # @see CONFIGURATION
96
95
  # @see DELIVERIES
97
96
  #
98
- proton_accessor :durability
97
+ proton_forward :durability_mode, :get_durability
98
+ proton_forward :durability_mode=, :set_durability
99
+
100
+ deprecated_alias :durability, :durability_mode
101
+ deprecated_alias :durability=, :durability_mode=
99
102
 
100
103
  # @!attribute expiry_policy
101
104
  #
@@ -106,37 +109,33 @@ module Qpid::Proton
106
109
  # @see EXPIRE_WITH_CONNECTION
107
110
  # @see EXPIRE_NEVER
108
111
  #
109
- proton_accessor :expiry_policy
112
+ proton_set_get :expiry_policy
110
113
 
111
114
  # @!attribute timeout
112
115
  #
113
116
  # @return [Integer] The timeout period.
114
117
  #
115
- proton_accessor :timeout
118
+ proton_set_get :timeout
116
119
 
117
120
  # @!attribute dynamic?
118
121
  #
119
122
  # @return [Boolean] True if the terminus is dynamic.
120
123
  #
121
- proton_accessor :dynamic, :is_or_get => :is
124
+ proton_set_is :dynamic
122
125
 
123
126
  # @!attribute distribution_mode
124
127
  #
125
- # @return [Integer] The distribution mode.
128
+ # @return [Integer] The distribution mode. Only relevant for a message source.
126
129
  #
127
130
  # @see DIST_MODE_UNSPECIFIED
128
131
  # @see DIST_MODE_COPY
129
132
  # @see DIST_MODE_MOVE
130
133
  #
131
- proton_accessor :distribution_mode
134
+ proton_set_get :distribution_mode
132
135
 
133
136
  # @private
134
137
  include Util::ErrorHandler
135
138
 
136
- can_raise_error [:type=, :address=, :durability=, :expiry_policy=,
137
- :timeout=, :dynamic=, :distribution_mode=, :copy],
138
- :error_class => Qpid::Proton::LinkError
139
-
140
139
  # @private
141
140
  attr_reader :impl
142
141
 
@@ -157,7 +156,7 @@ module Qpid::Proton
157
156
  # @return [Data] The terminus properties.
158
157
  #
159
158
  def properties
160
- Data.new(Cproton.pn_terminus_properties(@impl))
159
+ Codec::Data.new(Cproton.pn_terminus_properties(@impl))
161
160
  end
162
161
 
163
162
  # Access and modify the AMQP capabilities data for the Terminus.
@@ -172,7 +171,7 @@ module Qpid::Proton
172
171
  # @return [Data] The terminus capabilities.
173
172
  #
174
173
  def capabilities
175
- Data.new(Cproton.pn_terminus_capabilities(@impl))
174
+ Codec::Data.new(Cproton.pn_terminus_capabilities(@impl))
176
175
  end
177
176
 
178
177
  # Access and modify the AMQP outcomes for the Terminus.
@@ -187,10 +186,11 @@ module Qpid::Proton
187
186
  # @return [Data] The terminus outcomes.
188
187
  #
189
188
  def outcomes
190
- Data.new(Cproton.pn_terminus_outcomes(@impl))
189
+ Codec::Data.new(Cproton.pn_terminus_outcomes(@impl))
191
190
  end
192
191
 
193
- # Access and modify the AMQP filter set for the Terminus.
192
+ # Access and modify the AMQP filter set for a source terminus.
193
+ # Only relevant for a message source.
194
194
  #
195
195
  # This operation will return an instance of Data that is valid until the
196
196
  # Terminus is freed due to its parent being freed. Any data contained in
@@ -202,17 +202,49 @@ module Qpid::Proton
202
202
  # @return [Data] The terminus filter.
203
203
  #
204
204
  def filter
205
- Data.new(Cproton.pn_terminus_filter(@impl))
205
+ Codec::Data.new(Cproton.pn_terminus_filter(@impl))
206
206
  end
207
207
 
208
- # Copy another Terminus into this instance.
209
- #
210
- # @param source [Terminus] The source instance.
211
- #
212
- def copy(source)
213
- Cproton.pn_terminus_copy(@impl,source.impl)
208
+ # Replace the data in this Terminus with the contents of +other+
209
+ # @param other [Terminus] The other instance.
210
+ def replace(other)
211
+ Cproton.pn_terminus_copy(@impl, other.impl)
212
+ self
213
+ end
214
+ deprecated_alias :copy, :replace
215
+
216
+ # Apply options to this terminus.
217
+ # @option opts [String] :address the node address
218
+ # @option opts [Boolean] :dynamic (false)
219
+ # if true, request a new node with a unique address to be created. +:address+ is ignored.
220
+ # @option opts [Integer] :distribution_mode see {#distribution_mode}, only for source nodes
221
+ # @option opts [Integer] :durability_mode see {#durability_mode}
222
+ # @option opts [Integer] :timeout see {#timeout}
223
+ # @option opts [Integer] :expiry_policy see {#expiry_policy}
224
+ # @option opts [Hash] :filter see {#filter}, only for source nodes
225
+ # @option opts [Hash] :capabilities see {#capabilities}
226
+ def apply(opts=nil)
227
+ return unless opts
228
+ if opts.is_a? String # Shorthand for address
229
+ self.address = opts
230
+ else
231
+ opts.each_pair do |k,v|
232
+ case k
233
+ when :address then self.address = v
234
+ when :dynamic then self.dynamic = !!v
235
+ when :distribution_mode then self.distribution_mode = v
236
+ when :durability_mode then self.durability_mode = v
237
+ when :timeout then self.timeout = v
238
+ when :expiry_policy then self.expiry_policy = v
239
+ when :filter then self.filter = v
240
+ when :capabilities then self.capabilities = v
241
+ end
242
+ end
243
+ end
214
244
  end
215
245
 
246
+ can_raise_error([:type=, :address=, :durability=, :expiry_policy=,
247
+ :timeout=, :dynamic=, :distribution_mode=, :copy],
248
+ :error_class => Qpid::Proton::LinkError)
216
249
  end
217
-
218
250
  end