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/reactor/urls.rb DELETED
@@ -1,45 +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 URLs
23
-
24
- def initialize(values)
25
- @values = values
26
- if @values.is_a? Enumerable
27
- @values = @values.map { |u| Qpid::Proton::URL.new(u) }
28
- else
29
- @values = [Qpid::Proton::URL.new(values)]
30
- end
31
- @iter = @values.each
32
- end
33
-
34
- def next
35
- begin
36
- return @iter.next
37
- rescue StopIteration
38
- @iter = @values.each
39
- return @iter.next
40
- end
41
- end
42
-
43
- end
44
-
45
- end
@@ -1,54 +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::Util
21
-
22
- # This mixin provides a method for mapping from an underlying Proton
23
- # C library class to a Ruby class.
24
- #
25
- # @private
26
- #
27
- module ClassWrapper
28
-
29
- WRAPPERS =
30
- {
31
- "pn_void" => proc {|x| Cproton.pn_void2rb(x)},
32
- "pn_rbref" => proc {|x| Cproton.pn_void2rb(x)},
33
- "pn_connection" => proc {|x| Qpid::Proton::Connection.wrap(Cproton.pn_cast_pn_connection(x))},
34
- "pn_session" => proc {|x| Qpid::Proton::Session.wrap(Cproton.pn_cast_pn_session(x))},
35
- "pn_link" => proc {|x| Qpid::Proton::Link.wrap(Cproton.pn_cast_pn_link(x))},
36
- "pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))},
37
- "pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))},
38
- "pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))},
39
- "pn_reactor" => proc {|x| Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_cast_pn_reactor(x))},
40
- "pn_task" => proc {|x| Qpid::Proton::Reactor::Task.wrap(Cproton.pn_cast_pn_task(x))},
41
- }
42
-
43
- def class_wrapper(clazz, c_impl, &block)
44
- proc_func = WRAPPERS[clazz]
45
- if !proc_func.nil?
46
- proc_func.yield(c_impl)
47
- elsif block_given?
48
- yield(c_impl)
49
- end
50
- end
51
-
52
- end
53
-
54
- 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::Util
21
-
22
- class Condition
23
-
24
- attr_reader :name, :description, :info
25
-
26
- def initialize(name, description = nil, info = nil)
27
- @name = name
28
- @description = description
29
- @info = info
30
- end
31
-
32
- # @private
33
- def to_s
34
- "Condition(#{@name}, #{@description}, #{@info})"
35
- end
36
-
37
- # @private
38
- def ==(other)
39
- ((other.class = self.class) &&
40
- (other.name == self.name) &&
41
- (other.description == self.description) &&
42
- (other.info == self.info))
43
- end
44
-
45
- end
46
-
47
- end
@@ -1,85 +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::Util
21
-
22
- # Provides a means for defining constant values within the namespace
23
- # of a class.
24
- #
25
- # If the class has defined the class method, :post_add_constant, then that
26
- # method will be invoked after each new item is added. It must be defined
27
- # *before* any constants are defined.
28
- #
29
- # ==== Example
30
- #
31
- # class GrammarComponent
32
- #
33
- # include Qpid::Proton::Constants
34
- #
35
- # def self.post_add_constant(key, value)
36
- # @terminal << value if value.terminal?
37
- # @nonterminal << value if !value.terminal? && !value.rule
38
- # @rule << value if value.rule
39
- # end
40
- #
41
- # self.add_constant :LEFT_PARENTHESIS, new GrammarComponent("(", :terminal)
42
- # self.add_constant :RIGHT_PARENTHESIS, new GrammarComponent(")", :terminal)
43
- # self.add_constant :ELEMENT, new GrammarComponent("E", :rule)
44
- #
45
- # def initialize(component, type)
46
- # @component = component
47
- # @type = type
48
- # end
49
- #
50
- # def terminal?; @type == :terminal; end
51
- #
52
- # def rule?; @type == :rule; end
53
- #
54
- # end
55
- #
56
- # @private
57
- #
58
- module Constants
59
-
60
- def self.included(base)
61
- base.extend ClassMethods
62
- end
63
-
64
- module ClassMethods
65
-
66
- def add_constant(key, value)
67
- self.const_set(key, value)
68
-
69
- @pn_by_value ||= {}
70
- @pn_by_value[value] = key
71
-
72
- if self.respond_to? :post_add_constant
73
- self.post_add_constant(key, value)
74
- end
75
- end
76
-
77
- def by_value(value)
78
- (@pn_by_value || {})[value]
79
- end
80
-
81
- end
82
-
83
- end
84
-
85
- end
data/lib/util/engine.rb DELETED
@@ -1,82 +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::Util
21
-
22
- # @private
23
- module Engine
24
-
25
- # Convenience method to receive messages from a delivery.
26
- #
27
- # @param delivery [Qpid::Proton::Delivery] The delivery.
28
- # @param msg [Qpid::Proton::Message] The message to use.
29
- #
30
- # @return [Qpid::Proton::Message] the message
31
- #
32
- def self.receive_message(delivery, msg = nil)
33
- msg = Qpid::Proton::Message.new if msg.nil?
34
- msg.decode(delivery.link.receive(delivery.pending))
35
- delivery.link.advance
36
- return msg
37
- end
38
-
39
- def data_to_object(data_impl) # :nodoc:
40
- object = nil
41
- unless data_impl.nil?
42
- data = Qpid::Proton::Codec::Data.new(data_impl)
43
- data.rewind
44
- data.next
45
- object = data.object
46
- data.rewind
47
- end
48
- return object
49
- end
50
-
51
- def object_to_data(object, data_impl) # :nodoc:
52
- unless object.nil?
53
- data = Data.new(data_impl)
54
- data.object = object
55
- end
56
- end
57
-
58
- def condition_to_object(condition) # :nodoc:
59
- result = nil
60
- if Cproton.pn_condition_is_set(condition)
61
- result = Condition.new(Cproton.pn_condition_get_name(condition),
62
- Cproton.pn_condition_get_description(condition),
63
- data_to_object(Cproton.pn_condition_info(condition)))
64
- end
65
- return result
66
- end
67
-
68
- def object_to_condition(object, condition) # :nodoc:
69
- Cproton.pn_condition_clear(condition)
70
- unless object.nil?
71
- Cproton.pn_condition_set_name(condition, object.name)
72
- Cproton.pn_condition_set_description(condition, object.description)
73
- info = Data.new(Cproton.pn_condition_info(condition))
74
- if object.info?
75
- info.object = object.info
76
- end
77
- end
78
- end
79
-
80
- end
81
-
82
- end
data/lib/util/reactor.rb DELETED
@@ -1,32 +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::Util
21
-
22
- module Reactor
23
-
24
- def create_session(connection, handler = nil)
25
- session = connection.session
26
- session.open
27
- return session
28
- end
29
-
30
- end
31
-
32
- end
@@ -1,114 +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::Util
21
-
22
- # Provides helper functions for writing wrapper functions for the
23
- # underlying C APIs.
24
- #
25
- # Before defining any mutators the class must define the name of the
26
- # prefix for methods with the constant PROTON_METOD_PREFIX.
27
- #
28
- # == Mutators, Setters And Getters
29
- #
30
- # There are three types of wrappers that are supported:
31
- #
32
- # [proton_writer] Defines a set-only method for the named attribute.
33
- # [proton_reader] Defines a get-only method for the named attribute.
34
- # [proton_accessor] Defines both a set- and a get-method for the named
35
- # attribute.
36
- # [proton_caller] A simple wrapper for calling an underlying method,
37
- # avoids repetitive boiler plate coding.
38
- #
39
- # == Arguments
40
- #
41
- # [:is_or_get => {:is, :get}] For both the getter and the mutator types
42
- # you can also declare that the method uses "is" instead of "get" in the
43
- # underlying API. Such methods are then defined with "?"
44
- #
45
- # @example
46
- # class Terminus
47
- #
48
- # include WrapperHelper
49
- #
50
- # PROTON_METHOD_PREFIX = "pn_terminus"
51
- #
52
- # # add methods "type" and "type=" that call "pn_terminus_{get,set}_type"
53
- # proton_accessor :type
54
- #
55
- # # adds the method "dynamic?" that calls "pn_terminus_is_dynamic"
56
- # proton_accessor :dynamic, :is_or_get => :is
57
- #
58
- # # adds a method named "foo" that calls "pn_terminus_foo"
59
- # proton_caller :foo
60
- #
61
- # end
62
- #
63
- # @private
64
- module SwigHelper
65
-
66
- def self.included(base)
67
- base.extend ClassMethods
68
- end
69
-
70
- module ClassMethods # :nodoc:
71
-
72
- def create_wrapper_method(name, proton_method, with_arg = false)
73
- if with_arg
74
- define_method "#{name}" do |arg|
75
- Cproton.__send__(proton_method.to_sym, @impl, arg)
76
- end
77
- else
78
- define_method "#{name}" do
79
- Cproton.__send__(proton_method.to_sym, @impl)
80
- end
81
- end
82
- end
83
-
84
- # Defines a method that calls an underlying C library function.
85
- def proton_caller(name, options = {})
86
- proton_method = "#{self::PROTON_METHOD_PREFIX}_#{name}"
87
- # drop the trailing '?' if this is a property method
88
- proton_method = proton_method[0..-2] if proton_method.end_with? "?"
89
- create_wrapper_method(name, proton_method, options[:arg])
90
- end
91
-
92
- def proton_writer(name, options = {})
93
- proton_method = "#{self::PROTON_METHOD_PREFIX}_set_#{name}"
94
- create_wrapper_method("#{name}=", proton_method, true)
95
- end
96
-
97
- def proton_reader(name, options = {})
98
- an_is_method = options[:is_or_get] == :is
99
- prefix = (an_is_method) ? "is" : "get"
100
- proton_method = "#{self::PROTON_METHOD_PREFIX}_#{prefix}_#{name}"
101
- name = "#{name}?" if an_is_method
102
- create_wrapper_method(name, proton_method)
103
- end
104
-
105
- def proton_accessor(name, options = {})
106
- proton_writer(name, options)
107
- proton_reader(name, options)
108
- end
109
-
110
- end
111
-
112
- end
113
-
114
- end