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,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,27 +14,35 @@
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
- #++
19
17
 
20
18
  module Qpid::Proton::Util
21
-
22
19
  # @private
23
- module Handler
20
+ module Deprecation
21
+ MATCH_DIR = /#{File.dirname(File.dirname(__FILE__))}/
22
+
23
+ DEPRECATE_FULL_TRACE = false
24
24
 
25
- def chandler(handler, on_error)
26
- return nil if handler.nil?
25
+ def self.deprecated(old, new=nil)
26
+ replace = new ? "use `#{new}`" : "internal use only"
27
+
28
+ from = DEPRECATE_FULL_TRACE ? caller(2).join("\n") : caller.find { |l| not MATCH_DIR.match(l) }
29
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{from}"
30
+ end
27
31
 
28
- if handler.instance_of?(Qpid::Proton::Handler::WrappedHandler)
29
- impl = handler.impl
30
- Cproton.pn_incref(impl)
31
- return impl
32
- else
33
- cadaptor = Qpid::Proton::Handler::CAdaptor.new(handler, on_error)
34
- rbhandler = Cproton.pn_rbhandler(cadaptor)
35
- return rbhandler
32
+ def deprecated(*arg) Deprecation.deprecated(*arg); end
33
+
34
+ module ClassMethods
35
+ def deprecated_alias(bad, good)
36
+ bad, good = bad.to_sym, good.to_sym
37
+ define_method(bad) do |*args, &block|
38
+ self.deprecated bad, good
39
+ self.__send__(good, *args, &block)
40
+ end
36
41
  end
37
42
  end
38
43
 
44
+ def self.included(other)
45
+ other.extend ClassMethods
46
+ end
39
47
  end
40
-
41
48
  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::Util
21
20
 
@@ -24,35 +23,15 @@ module Qpid::Proton::Util
24
23
  # @private
25
24
  module ErrorHandler
26
25
 
27
- def self.included(base)
28
- base.extend(self)
29
-
30
- unless defined? base.to_be_wrapped
31
- class << base
32
- @@to_be_wrapped = []
33
- end
34
- end
35
-
36
- define_method :method_added do |name|
37
- if (!@@to_be_wrapped.nil?) && (@@to_be_wrapped.include? name)
38
- @@to_be_wrapped.delete name
39
- create_exception_handler_wrapper(name)
40
- end
41
- end
42
- end
26
+ def self.included(other) other.extend(self); end
43
27
 
44
28
  def can_raise_error(method_names, options = {})
45
29
  error_class = options[:error_class]
46
30
  below = options[:below] || 0
47
31
  # coerce the names to be an array
48
32
  Array(method_names).each do |method_name|
49
- # if the method doesn't already exist then queue this aliasing
50
- unless self.method_defined? method_name
51
- @@to_be_wrapped ||= []
52
- @@to_be_wrapped << method_name
53
- else
54
- create_exception_handler_wrapper(method_name, error_class, below)
55
- end
33
+ raise "missing method #{method_name.inspect}" unless method_defined?(method_name) || private_method_defined?(method_name)
34
+ create_exception_handler_wrapper(method_name, error_class, below)
56
35
  end
57
36
  end
58
37
 
data/lib/util/timeout.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::Util
21
20
 
data/lib/util/version.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::Util
21
20
 
data/lib/util/wrapper.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,49 +14,48 @@
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
- #++
19
17
 
20
- module Qpid::Proton::Util
21
18
 
22
- # @private
23
- module Wrapper
19
+ module Qpid::Proton
20
+ module Util
24
21
 
25
22
  # @private
26
- def impl=(impl)
27
- @impl = impl
28
- end
29
-
30
- # @private
31
- def impl
32
- @impl
33
- end
23
+ # Class methods to help wrapper classes define forwarding methods to proton-C functions
24
+ #
25
+ # The extending class must define PROTON_METHOD_PREFIX, the functions here
26
+ # make it easy to define ruby methods to forward calls to C functions.
27
+ #
28
+ module SWIGClassHelper
29
+ # Define ruby method +name+ to forward arguments to
30
+ # CProton.PROTON_METHOD_PREFIX_+pn_name+(@impl, ...)
31
+ def proton_forward(name, pn_name)
32
+ pn_name = pn_name[0..-2] if pn_name.to_s.end_with? "?" # Drop trailing ? for ruby bool methods
33
+ pn_name = "#{self::PROTON_METHOD_PREFIX}_#{pn_name}".to_sym
34
+ define_method(name.to_sym) { |*args| Cproton.__send__(pn_name, @impl, *args) }
35
+ end
34
36
 
35
- def self.registry
36
- @registry ||= {}
37
- end
37
+ def proton_caller(*names) names.each { |name| proton_forward(name, name) }; end
38
+ def proton_set(*names) names.each { |name| proton_forward("#{name}=", "set_#{name}") }; end
39
+ def proton_get(*names) names.each { |name| proton_forward(name, "get_#{name}") }; end
40
+ def proton_is(*names) names.each { |name| proton_forward("#{name}?", "is_#{name}") }; end
41
+ def proton_set_get(*names) names.each { |name| proton_get(name); proton_set(name) }; end
42
+ def proton_set_is(*names) names.each { |name| proton_is(name); proton_set(name) }; end
38
43
 
39
- def self.included(base)
40
- base.extend(ClassMethods)
41
- end
44
+ # Store ruby wrappers as attachments so they can be retrieved from the C pointer.
45
+ #
46
+ # Wrappers are stored in a registry using a key. The key is then attached to
47
+ # the Proton structure as a record. That record lives for as long as the
48
+ # Proton structure lives, and when the structure is released the record acts
49
+ # as hook to also delete the Ruby wrapper object from the registry.
42
50
 
43
- # Adds methods to the target class for storing and retrieving pure Ruby
44
- # wrappers to underlying Proton structures.
45
- #
46
- # Such wrappers are stored in a registry using a key. The key is then
47
- # attached to the Proton structure as a record. That record lives for as
48
- # long as the Proton structure lives, and when the structure is released
49
- # the record acts as hook to also delete the Ruby wrapper object from the
50
- # registry.
51
- #
52
- # @private
53
- #
54
- module ClassMethods
51
+ @@registry = {}
55
52
 
56
53
  # @private
57
54
  def get_key(impl)
58
55
  ("%032x" % Cproton.pni_address_of(impl))
59
56
  end
60
57
 
58
+ # @private
61
59
  # Stores the given object for later retrieval.
62
60
  #
63
61
  # @param object [Object] The object.
@@ -76,7 +74,7 @@ module Qpid::Proton::Util
76
74
  Cproton.pn_record_def(record, RBCTX, Cproton.Pn_rbkey__class());
77
75
  Cproton.pn_record_set(record, RBCTX, rbkey)
78
76
  end
79
- Qpid::Proton::Util::Wrapper.registry[registry_key] = object
77
+ @@registry[registry_key] = object
80
78
  end
81
79
 
82
80
  # Retrieves the wrapper object with the supplied Proton struct.
@@ -101,9 +99,9 @@ module Qpid::Proton::Util
101
99
  registry_key = get_key(impl)
102
100
  end
103
101
  # if the object's not in the registry then return
104
- return nil unless Qpid::Proton::Util::Wrapper.registry.has_key?(registry_key)
102
+ return nil unless @@registry.has_key?(registry_key)
105
103
 
106
- result = Qpid::Proton::Util::Wrapper.registry[registry_key]
104
+ result = @@registry[registry_key]
107
105
  # result = nil unless result.weakref_alive?
108
106
  if result.nil?
109
107
  raise Qpid::Proton::ProtonError.new("missing object for key=#{registry_key}")
@@ -113,12 +111,34 @@ module Qpid::Proton::Util
113
111
  end
114
112
  return result
115
113
  end
116
-
114
+ RBCTX = self.hash.to_i
117
115
  end
118
116
 
119
- end
117
+ # @private
118
+ module Wrapper
120
119
 
121
- # @private
122
- RBCTX = Wrapper.hash.to_i
120
+ def self.included(base)
121
+ base.extend(SWIGClassHelper)
122
+ end
123
+
124
+ attr_accessor :impl
123
125
 
126
+ def inspect
127
+ return "#{self.class}<nil>" unless @impl
128
+ pstr = Cproton.pn_string("")
129
+ begin
130
+ Cproton.pn_inspect(@impl, pstr)
131
+ return Cproton.pn_string_get(pstr)
132
+ ensure
133
+ Cproton.pn_free(pstr)
134
+ end
135
+ end
136
+
137
+ def to_s() inspect; end
138
+
139
+ def self.registry
140
+ @registry ||= {}
141
+ end
142
+ end
143
+ end
124
144
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qpid_proton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darryl L. Pierce
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-14 00:00:00.000000000 Z
12
+ date: 2018-01-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |
15
15
  Proton is a high performance, lightweight messaging library. It can be used in
@@ -30,67 +30,50 @@ files:
30
30
  - ext/cproton/extconf.rb
31
31
  - lib/codec/data.rb
32
32
  - lib/codec/mapping.rb
33
- - lib/core/base_handler.rb
33
+ - lib/core/condition.rb
34
34
  - lib/core/connection.rb
35
+ - lib/core/connection_driver.rb
36
+ - lib/core/container.rb
35
37
  - lib/core/delivery.rb
36
38
  - lib/core/disposition.rb
37
39
  - lib/core/endpoint.rb
40
+ - lib/core/event.rb
38
41
  - lib/core/exceptions.rb
39
42
  - lib/core/link.rb
43
+ - lib/core/listener.rb
40
44
  - lib/core/message.rb
45
+ - lib/core/messaging_handler.rb
41
46
  - lib/core/receiver.rb
42
47
  - lib/core/sasl.rb
43
- - lib/core/selectable.rb
44
48
  - lib/core/sender.rb
45
49
  - lib/core/session.rb
46
50
  - lib/core/ssl.rb
47
51
  - lib/core/ssl_details.rb
48
52
  - lib/core/ssl_domain.rb
49
53
  - lib/core/terminus.rb
54
+ - lib/core/tracker.rb
55
+ - lib/core/transfer.rb
50
56
  - lib/core/transport.rb
57
+ - lib/core/uri.rb
51
58
  - lib/core/url.rb
52
- - lib/event/collector.rb
53
- - lib/event/event.rb
54
- - lib/event/event_base.rb
55
- - lib/event/event_type.rb
56
- - lib/handler/acking.rb
57
- - lib/handler/c_adaptor.rb
58
- - lib/handler/c_flow_controller.rb
59
- - lib/handler/endpoint_state_handler.rb
60
- - lib/handler/incoming_message_handler.rb
59
+ - lib/handler/adapter.rb
60
+ - lib/handler/messaging_adapter.rb
61
61
  - lib/handler/messaging_handler.rb
62
- - lib/handler/outgoing_message_handler.rb
63
- - lib/handler/wrapped_handler.rb
62
+ - lib/handler/reactor_messaging_adapter.rb
64
63
  - lib/messenger/messenger.rb
65
64
  - lib/messenger/subscription.rb
66
65
  - lib/messenger/tracker.rb
67
66
  - lib/messenger/tracker_status.rb
68
67
  - lib/qpid_proton.rb
69
- - lib/reactor/acceptor.rb
70
- - lib/reactor/backoff.rb
71
- - lib/reactor/connector.rb
72
68
  - lib/reactor/container.rb
73
- - lib/reactor/global_overrides.rb
74
- - lib/reactor/link_option.rb
75
- - lib/reactor/reactor.rb
76
- - lib/reactor/session_per_connection.rb
77
- - lib/reactor/ssl_config.rb
78
- - lib/reactor/task.rb
79
- - lib/reactor/urls.rb
80
69
  - lib/types/array.rb
81
70
  - lib/types/described.rb
82
71
  - lib/types/hash.rb
83
72
  - lib/types/strings.rb
84
- - lib/util/class_wrapper.rb
85
- - lib/util/condition.rb
86
- - lib/util/constants.rb
87
- - lib/util/engine.rb
73
+ - lib/types/type.rb
74
+ - lib/util/deprecation.rb
88
75
  - lib/util/error_handler.rb
89
- - lib/util/handler.rb
90
- - lib/util/reactor.rb
91
- - lib/util/swig_helper.rb
92
76
  - lib/util/timeout.rb
93
- - lib/util/uuid.rb
94
77
  - lib/util/version.rb
95
78
  - lib/util/wrapper.rb
96
79
  homepage: http://qpid.apache.org/proton
@@ -1,31 +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
21
-
22
- class BaseHandler
23
-
24
- # Override to process unhandled events.
25
- #
26
- def on_unhandled(method, *args)
27
- end
28
-
29
- end
30
-
31
- end
@@ -1,130 +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
21
-
22
- # Selectable enables accessing the underlying file descriptors
23
- # for Messenger.
24
- #
25
- # @private
26
- class Selectable
27
-
28
- # @private
29
- include Util::SwigHelper
30
-
31
- # @private
32
- PROTON_METHOD_PREFIX = "pn_selectable"
33
-
34
- # Returns the underlying file descriptor.
35
- #
36
- # This can be used in conjunction with the IO class.
37
- #
38
- def fileno
39
- Cproton.pn_selectable_get_fd(@impl)
40
- end
41
-
42
- proton_reader :reading, :is_or_get => :is
43
-
44
- proton_reader :writing, :is_or_get => :is
45
-
46
- proton_caller :readable
47
-
48
- proton_caller :writable
49
-
50
- proton_caller :expired
51
-
52
- proton_accessor :registered, :is_or_get => :is
53
-
54
- proton_accessor :terminal, :is_or_get => :is
55
-
56
- proton_caller :terminate
57
-
58
- proton_caller :release
59
-
60
- # @private
61
- def self.wrap(impl)
62
- return nil if impl.nil?
63
-
64
- self.fetch_instance(impl, :pn_selectable_attachments) || Selectable.new(impl)
65
- end
66
-
67
- # @private
68
- include Util::Wrapper
69
-
70
- # @private
71
- def initialize(impl)
72
- @impl = impl
73
- self.class.store_instance(self, :pn_selectable_attachments)
74
- end
75
-
76
- private
77
-
78
- DEFAULT = Object.new
79
-
80
- public
81
-
82
- def fileno(fd = DEFAULT)
83
- if fd == DEFAULT
84
- Cproton.pn_selectable_get_fd(@impl)
85
- elsif fd.nil?
86
- Cproton.pn_selectable_set_fd(@impl, Cproton::PN_INVALID_SOCKET)
87
- else
88
- Cproton.pn_selectable_set_fd(@impl, fd)
89
- end
90
- end
91
-
92
- def reading=(reading)
93
- if reading.nil?
94
- reading = false
95
- elsif reading == "0"
96
- reading = false
97
- else
98
- reading = true
99
- end
100
- Cproton.pn_selectable_set_reading(@impl, reading ? true : false)
101
- end
102
-
103
- def writing=(writing)
104
- if writing.nil?
105
- writing = false
106
- elsif writing == "0"
107
- writing = false
108
- else
109
- writing = true
110
- end
111
- Cproton.pn_selectable_set_writing(@impl, writing ? true : false)
112
- end
113
-
114
- def deadline
115
- tstamp = Cproton.pn_selectable_get_deadline(@impl)
116
- return nil if tstamp.nil?
117
- mills_to_sec(tstamp)
118
- end
119
-
120
- def deadline=(deadline)
121
- Cproton.pn_selectable_set_deadline(sec_to_millis(deadline))
122
- end
123
-
124
- def to_io
125
- @io ||= IO.new(fileno)
126
- end
127
-
128
- end
129
-
130
- end