qpid_proton 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,91 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Event
21
-
22
- # @private
23
- def self.dispatch(handler, method, *args)
24
- args = args.last unless args.nil?
25
- if handler.respond_to? method.to_sym
26
- return handler.__send__(method, args)
27
- elsif handler.respond_to? :on_unhandled
28
- return handler.__send__(:on_unhandled, method, args)
29
- end
30
- end
31
-
32
- # EventBase is the foundation for creating application-specific events.
33
- #
34
- # @example
35
- #
36
- # # SCENARIO: A continuation of the example in EventType.
37
- # #
38
- # # An Event class is defined to handle receiving encrypted
39
- # # data from a remote endpoint.
40
- #
41
- # class EncryptedDataEvent < EventBase
42
- # def initialize(message)
43
- # super(EncryptedDataEvent, message,
44
- # Qpid::Proton::Event::ENCRYPTED_RECV)
45
- # end
46
- # end
47
- #
48
- # # at another point, when encrypted data is received
49
- # msg = Qpid::Proton::Message.new
50
- # msg.decode(link.receive(link.pending))
51
- # if encrypted?(msg)
52
- # collector.put(EncryptedDataEvent.new(msg)
53
- # end
54
- #
55
- # @see EventType The EventType class for how ENCRYPTED_RECV was defined.
56
- #
57
- class EventBase
58
-
59
- # Returns the name for the class associated with this event.
60
- attr_reader :class_name
61
-
62
- # Returns the associated context object for the event.
63
- attr_reader :context
64
-
65
- # Returns the type of the event.
66
- attr_reader :type
67
-
68
- # Creates a new event with the specific class_name and context of the
69
- # specified type.
70
- #
71
- # @param class_name [String] The name of the class.
72
- # @param context [Object] The event context.
73
- # @param type [EventType] The event type.
74
- #
75
- def initialize(class_name, context, type)
76
- @class_name = class_name
77
- @context = context
78
- @type = type
79
- end
80
-
81
- # Invokes the type-specific method on the provided handler.
82
- #
83
- # @param handler [Object] The handler to be notified of this event.
84
- #
85
- def dispatch(handler)
86
- Qpid::Proton.dispatch(handler, @type.method, self)
87
- end
88
-
89
- end
90
-
91
- end
@@ -1,71 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Event
21
-
22
- # Manages the association between an Event and the method which should
23
- # process on the context object associated with an occurance of the event.
24
- #
25
- # Each type is identified by a unique #type value.
26
- #
27
- # @example
28
- #
29
- # # SCENARIO: A part of an application handles extracting and decrypting
30
- # # data received from a remote endpoint.
31
- # #
32
- # # An EventType is created to notify handlers that such a
33
- # # situation has occurred.
34
- #
35
- # ENCRYPTED_RECV = 10000 # the unique constant value for the event
36
- #
37
- # # create a new event type which, when it occurs, invokes a method
38
- # # named :on_encrypted_data when a handler is notified of its occurrance
39
- # Qpid::Proton::Event::ENCRYPTED_RECV =
40
- # Qpid::Proton::Event::EventType.new(ENCRYPTED_RECV, :on_encrypted_data)
41
- #
42
- # @see EventBase EventBase for the rest of this example.
43
- # @see Qpid::Proton::Event::Event The Event class for more details on events.
44
- #
45
- class EventType
46
-
47
- # The method to invoke on any potential handler.
48
- attr_reader :method
49
- attr_reader :number
50
-
51
- def initialize(number, method)
52
- @number = number
53
- @name = Cproton.pn_event_type_name(@number)
54
- @method = method
55
- @@types ||= {}
56
- @@types[number] = self
57
- end
58
-
59
- # @private
60
- def to_s
61
- @name
62
- end
63
-
64
- # @private
65
- def self.by_type(type) # :nodoc:
66
- @@types[type]
67
- end
68
-
69
- end
70
-
71
- end
@@ -1,70 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Handler
21
-
22
- # Mixing that provides methods for acknowledging a delivery.
23
- #
24
- module Acking
25
-
26
- # Accept the receivered message.
27
- #
28
- # @param delivery [Qpid::Proton::Delivery] The delivery.
29
- #
30
- def accept(delivery)
31
- self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED)
32
- end
33
-
34
- # Rejects a received message that is considered invalid or unprocessable.
35
- #
36
- # @param delivery [Qpid::Proton::Delivery] The delivery.
37
- #
38
- def reject(delivery)
39
- self.settle(delivery, Qpid::Proton::Delivery::REJECTED)
40
- end
41
-
42
- # Releases a received message, making it available at the source for any
43
- # other interested receiver.
44
- #
45
- # @param delivery [Qpid::Proton::Delivery] The delivery
46
- # @param delivered [Boolean] True if this was considered a delivery
47
- # attempt.
48
- #
49
- def release(delivery, delivered = true)
50
- if delivered
51
- self.settle(delivery, Qpid::Proton::Delivery::MODIFIED)
52
- else
53
- self.settle(delivery, Qpid::Proton::Delivery::RELEASED)
54
- end
55
- end
56
-
57
- # Settles the specified delivery. Updates the delivery state if a state
58
- # is specified.
59
- #
60
- # @param delivery [Qpid::Proton::Delivery] The delivery.
61
- # @param state [Integer] The delivery state.
62
- #
63
- def settle(delivery, state = nil)
64
- delivery.update(state) unless state.nil?
65
- delivery.settle
66
- end
67
-
68
- end
69
-
70
- end
@@ -1,47 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Handler
21
-
22
- # @private
23
- class CAdaptor
24
-
25
- def initialize(handler, on_error = nil)
26
- @handler = handler
27
- @on_error = on_error
28
- end
29
-
30
- def dispatch(cevent, ctype)
31
- event = Qpid::Proton::Event::Event.wrap(cevent, ctype)
32
- # TODO add a variable to enable this programmatically
33
- # print "EVENT: #{event} going to #{@handler}\n"
34
- event.dispatch(@handler)
35
- end
36
-
37
- def exception(error)
38
- if @on_error.nil?
39
- raise error
40
- else
41
- @on_error.call(error)
42
- end
43
- end
44
-
45
- end
46
-
47
- end
@@ -1,33 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Handler
21
-
22
- # @private
23
- class CFlowController < Qpid::Proton::Handler::WrappedHandler
24
-
25
- include Qpid::Proton::Util::Wrapper
26
-
27
- def initialize(window = 1024)
28
- super(Cproton.pn_flowcontroller(window))
29
- end
30
-
31
- end
32
-
33
- end
@@ -1,217 +0,0 @@
1
- #--
2
- # Licensed to the Apache Software Foundation (ASF) under one
3
- # or more contributor license agreements. See the NOTICE file
4
- # distributed with this work for additional information
5
- # regarding copyright ownership. The ASF licenses this file
6
- # to you under the Apache License, Version 2.0 (the
7
- # "License"); you may not use this file except in compliance
8
- # with the License. You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing,
13
- # software distributed under the License is distributed on an
14
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- # KIND, either express or implied. See the License for the
16
- # specific language governing permissions and limitations
17
- # under the License.
18
- #++
19
-
20
- module Qpid::Proton::Handler
21
-
22
- # A utility that exposes endpoint events; i.e., the open/close of a link,
23
- # session or connection, in a more intuitive manner.
24
- #
25
- # A XXX_opened method will be called when both local and remote peers have
26
- # opened the link, session or connection. This can be used to confirm a
27
- # locally initiated action for example.
28
- #
29
- # A XXX_opening method will be called when the remote peer has requested
30
- # an open that was not initiated locally. By default this will simply open
31
- # locally, which then trigtgers the XXX_opened called.
32
- #
33
- # The same applies to close.
34
- #
35
- class EndpointStateHandler < Qpid::Proton::BaseHandler
36
-
37
- def initialize(peer_close_is_error = false, delegate = nil)
38
- @delegate = delegate
39
- @peer_close_is_error = peer_close_is_error
40
- end
41
-
42
- def self.print_error(endpoint, endpoint_type)
43
- if !endpoint.remote_condition.nil?
44
- elsif self.local_endpoint?(endpoint) && endpoint.remote_closed?
45
- logging.error("#{endpoint_type} closed by peer")
46
- end
47
- end
48
-
49
- def on_link_remote_close(event)
50
- if !event.link.remote_condition.nil?
51
- self.on_link_error(event)
52
- elsif event.link.local_closed?
53
- self.on_link_closed(event)
54
- else
55
- self.on_link_closing(event)
56
- end
57
- event.link.close
58
- end
59
-
60
- def on_session_remote_close(event)
61
- if !event.session.remote_condition.nil?
62
- self.on_session_error(event)
63
- elsif event.session.local_closed?
64
- self.on_session_closed(event)
65
- else
66
- self.on_session_closing(event)
67
- end
68
- event.session.close
69
- end
70
-
71
- def on_connection_remote_close(event)
72
- if !event.connection.remote_condition.nil?
73
- self.on_connection_error(event)
74
- elsif event.connection.local_closed?
75
- self.on_connection_closed(event)
76
- else
77
- self.on_connection_closing(event)
78
- end
79
- event.connection.close
80
- end
81
-
82
- def on_connection_local_open(event)
83
- self.on_connection_opened(event) if event.connection.remote_active?
84
- end
85
-
86
- def on_connection_remote_open(event)
87
- if !(event.connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
88
- self.on_connection_opened(event)
89
- elsif event.connection.local_uninit?
90
- self.on_connection_opening(event)
91
- event.connection.open
92
- end
93
- end
94
-
95
- def on_session_local_open(event)
96
- self.on_session_opened(event) if event.session.remote_active?
97
- end
98
-
99
- def on_session_remote_open(event)
100
- if !(event.session.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
101
- self.on_session_opened(event)
102
- elsif event.session.local_uninit?
103
- self.on_session_opening(event)
104
- event.session.open
105
- end
106
- end
107
-
108
- def on_link_local_open(event)
109
- self.on_link_opened(event) if event.link.remote_active?
110
- end
111
-
112
- def on_link_remote_open(event)
113
- if !(event.link.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
114
- self.on_link_opened(event)
115
- elsif event.link.local_uninit?
116
- self.on_link_opening(event)
117
- event.link.open
118
- end
119
- end
120
-
121
- def on_connection_opened(event)
122
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_opened, event) if !@delegate.nil?
123
- end
124
-
125
- def on_session_opened(event)
126
- Qpid::Proton::Event.dispatch(@delegate, :on_session_opened, event) if !@delegate.nil?
127
- end
128
-
129
- def on_link_opened(event)
130
- Qpid::Proton::Event.dispatch(@delegate, :on_link_opened, event) if !@delegate.nil?
131
- end
132
-
133
- def on_connection_opening(event)
134
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_opening, event) if !@delegate.nil?
135
- end
136
-
137
- def on_session_opening(event)
138
- Qpid::Proton::Event.dispatch(@delegate, :on_session_opening, event) if !@delegate.nil?
139
- end
140
-
141
- def on_link_opening(event)
142
- Qpid::Proton::Event.dispatch(@delegate, :on_link_opening, event) if !@delegate.nil?
143
- end
144
-
145
- def on_connection_error(event)
146
- if !@delegate.nil?
147
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_error, event)
148
- else
149
- self.log_error(event.connection, "connection")
150
- end
151
- end
152
-
153
- def on_session_error(event)
154
- if !@delegate.nil?
155
- Qpid::Proton::Event.dispatch(@delegate, :on_session_error, event)
156
- else
157
- self.log_error(event.session, "session")
158
- event.connection.close
159
- end
160
- end
161
-
162
- def on_link_error(event)
163
- if !@delegate.nil?
164
- Qpid::Proton::Event.dispatch(@delegate, :on_link_error, event)
165
- else
166
- self.log_error(event.link, "link")
167
- event.conneciton.close
168
- end
169
- end
170
-
171
- def on_connection_closed(event)
172
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_closed, event) if !@delegate.nil?
173
- end
174
-
175
- def on_session_closed(event)
176
- Qpid::Proton::Event.dispatch(@delegate, :on_session_closed, event) if !@delegate.nil?
177
- end
178
-
179
- def on_link_closed(event)
180
- Qpid::Proton::Event.dispatch(@delegate, :on_link_closed, event) if !@delegate.nil?
181
- end
182
-
183
- def on_connection_closing(event)
184
- if !@delegate.nil?
185
- Qpid::Proton::Event.dispatch(@delegate, :on_connection_closing, event)
186
- elsif @peer_close_is_error
187
- self.on_connection_error(event)
188
- end
189
- end
190
-
191
- def on_session_closing(event)
192
- if !@delegate.nil?
193
- Qpid::Proton::Event.dispatch(@delegate, :on_session_closing, event)
194
- elsif @peer_close_is_error
195
- self.on_session_error(event)
196
- end
197
- end
198
-
199
- def on_link_closing(event)
200
- if !@delegate.nil?
201
- Qpid::Proton::Event.dispatch(@delegate, :on_link_closing, event)
202
- elsif @peer_close_is_error
203
- self.on_link_error(event)
204
- end
205
- end
206
-
207
- def on_transport_tail_closed(event)
208
- self.on_transport_closed(event)
209
- end
210
-
211
- def on_transport_closed(event)
212
- Qpid::Proton::Event.dispatch(@delegate, :on_disconnected, event) if !@delegate.nil?
213
- end
214
-
215
- end
216
-
217
- end