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
@@ -1,74 +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 for simpler and more intuitive handling of delivery events
23
- # related to incoming messages.
24
- #
25
- class IncomingMessageHandler < Qpid::Proton::BaseHandler
26
-
27
- include Acking
28
-
29
- def initialize(auto_accept = true, delegate = nil)
30
- @delegate = delegate
31
- @auto_accept = auto_accept
32
- end
33
-
34
- def on_delivery(event)
35
- delivery = event.delivery
36
- return unless delivery.link.receiver?
37
- if delivery.readable? && !delivery.partial?
38
- event.message = Qpid::Proton::Util::Engine.receive_message(delivery)
39
- if event.link.local_closed?
40
- if @auto_accept
41
- delivery.update(Qpid::Proton::Disposition::RELEASED)
42
- delivery.settle
43
- end
44
- else
45
- begin
46
- self.on_message(event)
47
- if @auto_accept
48
- delivery.update(Qpid::Proton::Disposition::ACCEPTED)
49
- delivery.settle
50
- end
51
- rescue Qpid::Proton::Reject
52
- delivery.update(Qpid::Proton::Disposition::REJECTED)
53
- delivery.settle
54
- rescue Qpid::Proton::Release
55
- delivery.update(Qpid::Proton::Disposition::MODIFIED)
56
- delivery.settle
57
- end
58
- end
59
- elsif delivery.updated? && delivery.settled?
60
- self.on_settled(event)
61
- end
62
- end
63
-
64
- def on_message(event)
65
- Qpid::Proton::Event.dispatch(@delegate, :on_message, event) if !@delegate.nil?
66
- end
67
-
68
- def on_settled(event)
69
- Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
70
- end
71
-
72
- end
73
-
74
- end
@@ -1,100 +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 for simpler and more intuitive handling of delivery events
23
- # related to outgoing messages.
24
- #
25
- class OutgoingMessageHandler < Qpid::Proton::BaseHandler
26
-
27
- def initialize(auto_settle = true, delegate = nil)
28
- @auto_settle = auto_settle
29
- @delegate = delegate
30
- end
31
-
32
- def on_link_flow(event)
33
- self.on_sendable(event) if event.link.sender? && event.link.credit > 0 &&
34
- (event.link.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE) &&
35
- (event.link.state & Qpid::Proton::Endpoint::REMOTE_ACTIVE)
36
- end
37
-
38
- def on_delivery(event)
39
- delivery = event.delivery
40
- if delivery.link.sender? && delivery.updated?
41
- if delivery.remote_accepted?
42
- self.on_accepted(event)
43
- elsif delivery.remote_rejected?
44
- self.on_rejected(event)
45
- elsif delivery.remote_released? || delivery.remote_modified?
46
- self.on_released(event)
47
- end
48
- self.on_settled(event) if delivery.settled?
49
- delivery.settle if @auto_settle
50
- end
51
- end
52
-
53
- # Called when the sender link has credit and messages and be transferred.
54
- #
55
- # @param event [Qpid::Proton::Event::Event] The event.
56
- #
57
- def on_sendable(event)
58
- Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil?
59
- end
60
-
61
- # Called when the remote peer accepts a sent message.
62
- #
63
- # @param event [Qpid::Proton::Event::Event] The event.
64
- #
65
- def on_accepted(event)
66
- Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil?
67
- end
68
-
69
- # Called when the remote peer rejects a sent message.
70
- #
71
- # @param event [Qpid::Proton::Event::Event] The event.
72
- #
73
- def on_rejected(event)
74
- Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil?
75
- end
76
-
77
- # Called when the remote peer releases an outgoing message.
78
- #
79
- # Note that this may be in resposnse to either the REELAASE or MODIFIED
80
- # state as defined by the AMQP specification.
81
- #
82
- # @param event [Qpid::Proton::Event::Event] The event.
83
- #
84
- def on_released(event)
85
- Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil?
86
- end
87
-
88
- # Called when the remote peer has settled the outgoing message.
89
- #
90
- # This is the point at which it should never be retransmitted.
91
- #
92
- # @param event [Qpid::Proton::Event::Event] The event.
93
- #
94
- def on_settled(event)
95
- Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
96
- end
97
-
98
- end
99
-
100
- end
@@ -1,76 +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
- class WrappedHandler
23
-
24
- # @private
25
- include Qpid::Proton::Util::Wrapper
26
-
27
- def self.wrap(impl, on_error = nil)
28
- return nil if impl.nil?
29
-
30
- result = self.fetch_instance(impl) || WrappedHandler.new(impl)
31
- result.on_error = on_error
32
- return result
33
- end
34
-
35
- include Qpid::Proton::Util::Handler
36
-
37
- def initialize(impl_or_constructor)
38
- if impl_or_constructor.is_a?(Method)
39
- @impl = impl_or_constructor.call
40
- else
41
- @impl = impl_or_constructor
42
- Cproton.pn_incref(@impl)
43
- end
44
- @on_error = nil
45
- self.class.store_instance(self)
46
- end
47
-
48
- def add(handler)
49
- return if handler.nil?
50
-
51
- impl = chandler(handler, self.method(:_on_error))
52
- Cproton.pn_handler_add(@impl, impl)
53
- Cproton.pn_decref(impl)
54
- end
55
-
56
- def clear
57
- Cproton.pn_handler_clear(@impl)
58
- end
59
-
60
- def on_error=(on_error)
61
- @on_error = on_error
62
- end
63
-
64
- private
65
-
66
- def _on_error(info)
67
- if self.has?['on_error']
68
- self['on_error'].call(info)
69
- else
70
- raise info
71
- end
72
- end
73
-
74
- end
75
-
76
- end
@@ -1,41 +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::Reactor
21
-
22
- class Acceptor
23
-
24
- include Qpid::Proton::Util::Wrapper
25
-
26
- def initialize(impl)
27
- @impl = impl
28
- self.class.store_instance(self)
29
- end
30
-
31
- def set_ssl_domain(ssl_domain)
32
- Cproton.pn_acceptor_set_ssl_domain(@impl, ssl_domain.impl)
33
- end
34
-
35
- def close
36
- Cproton.pn_acceptor_close(@impl)
37
- end
38
-
39
- end
40
-
41
- end
@@ -1,41 +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::Reactor
21
-
22
- class Backoff
23
-
24
- def initialize
25
- @delay = 0
26
- end
27
-
28
- def reset
29
- @delay = 0
30
- end
31
-
32
- def next
33
- current = @delay
34
- current = 0.1 if current.zero?
35
- @delay = [10, 2 * current].min
36
- return current
37
- end
38
-
39
- end
40
-
41
- end
@@ -1,115 +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::Reactor
21
-
22
- class Connector < Qpid::Proton::BaseHandler
23
-
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
36
-
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
42
- end
43
-
44
- def on_connection_local_open(event)
45
- self.connect(event.connection)
46
- end
47
-
48
- def on_connection_remote_open(event)
49
- @reconnect.reset if @reconnect
50
- end
51
-
52
- def on_transport_tail_closed(event)
53
- self.on_transport_closed(event)
54
- end
55
-
56
- def on_transport_closed(event)
57
- if !@connection.nil? && !(@connection.state & Qpid::Proton::Endpoint::LOCAL_ACTIVE).zero?
58
- if !@reconnect.nil?
59
- event.transport.unbind
60
- delay = @reconnect.next
61
- if delay == 0
62
- self.connect(@connection)
63
- else
64
- event.reactor.schedule(delay, self)
65
- end
66
- else
67
- @connection = nil
68
- end
69
- end
70
- end
71
-
72
- def on_timer_task(event)
73
- self.connect(@connection)
74
- end
75
-
76
- def on_connection_remote_close(event)
77
- @connection = nil
78
- end
79
-
80
- def connect(connection)
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
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?
106
-
107
- transport.bind(connection)
108
-
109
- if (url.scheme == "amqps") && @ssl_domain
110
- @ssl = Qpid::Proton::SSL.new(transport, @ssl_domain)
111
- @ssl.peer_hostname = url.host
112
- end
113
- end
114
- end
115
- end