manageiq-messaging 1.1.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 191fa67428995db65820476da103a6e5aec0d9dd9c39197f4f66acea13503d2e
4
- data.tar.gz: 07fd94d6722e61ea6518d52fd2352b6f2e7b432313af30a30715805af4800a1e
3
+ metadata.gz: b0f15797e5132dab8e6e37ca495eb1c0018b665c853c9e042f472d7b6ff1fa8a
4
+ data.tar.gz: 26c517dac36367c0c1e707618f02c1ccc0622a0f4ba2cea585d84e9020fa1c00
5
5
  SHA512:
6
- metadata.gz: d3be8c5b3346bed57d236b2e5ce56524fc0f5777e650c2dbe5efe428832b29e028e27037d484c47dddb0598b15c6b1aedaae7bff02841ca51880eb03a4dd8346
7
- data.tar.gz: 6520395f34a358aff5aa447345ad8f9ea335fdf961bb9a929cebaa25c0daa9e97e1a8e23dabaea056929ae8543beac62de59de0cb63104ad2831284009f86ddd
6
+ metadata.gz: 777d39d0123ffd98a5bdb5d7b1e82f7642089f12489ee56ccbe4463a01b8d5371c26b62663815ff3e8bcfdf213f08917bb3fd04154f137ff45039b425c441b60
7
+ data.tar.gz: 8e9002b7f3f4f60240baa7eb7ed1cfb3b8e1da6bc18830ff3d7edc98c0cd9f7bed2f24c3d6a514ecc067c0b78d637f5765897dc121c92f9cfa00aeb09b3dc984
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.3.0] - 03-Apr-2023
10
+ * Add Kafka SSL keystore options to client [#77](https://github.com/ManageIQ/manageiq-messaging/pull/77)
11
+
12
+ ## [1.2.0] - 19-Oct-2022
13
+
14
+ * Add ssl and ca_file options to `Client.open` [#76](https://github.com/ManageIQ/manageiq-messaging/pull/76)
15
+ * Add wait_for_topic option to Kafka [#75](https://github.com/ManageIQ/manageiq-messaging/pull/75)
16
+
9
17
  ## [1.1.2] - 6-Oct-2022
10
18
 
11
19
  * Fix kafka publish_topic on ruby3 [#74](https://github.com/ManageIQ/manageiq-messaging/pull/74)
@@ -68,7 +76,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
68
76
 
69
77
  * Initial release
70
78
 
71
- [Unreleased]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.1.1...HEAD
79
+ [Unreleased]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.3.0...HEAD
80
+ [1.3.0]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.2.0...v1.3.0
81
+ [1.2.0]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.1.2...v1.2.0
82
+ [1.1.2]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.1.1...v1.1.2
72
83
  [1.1.1]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.1.0...v1.1.1
73
84
  [1.1.0]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.0.3...v1.1.0
74
85
  [1.0.3]: https://github.com/ManageIQ/manageiq-messaging/compare/v1.0.2...v1.0.3
@@ -33,6 +33,12 @@ module ManageIQ
33
33
  # Open or create a connection to the message broker.
34
34
  # Expected +options+ keys are:
35
35
  # * :protocol (Implemented: 'Stomp', 'Kafka'. Default 'Stomp')
36
+ # * :host (hostname or IP address of the messaging broker)
37
+ # * :port (host port number)
38
+ # * :username (optional)
39
+ # * :password (optional)
40
+ # * :ssl (true/false)
41
+ # * :ca_file (optional. path to a certificate authority cert)
36
42
  # * :encoding ('yaml' or 'json'. Default 'yaml')
37
43
  # Other connection options are underlying messaging system specific.
38
44
  #
@@ -8,13 +8,11 @@ module ManageIQ
8
8
  # Kafka specific connection options accepted by +open+ method:
9
9
  # * :client_ref (A reference string to identify the client)
10
10
  # * :hosts (Array of Kafka cluster hosts, or)
11
- # * :host (Single host name)
12
- # * :port (host port number)
13
11
  #
14
- # For additional security options, please refer to
12
+ # For additional security options, please refer to
15
13
  # https://github.com/edenhill/librdkafka/wiki/Using-SSL-with-librdkafka and
16
- # https://github.com/edenhill/librdkafka/wiki/Using-SASL-with-librdkafka
17
- #
14
+ # https://github.com/edenhill/librdkafka/wiki/Using-SASL-with-librdkafka
15
+ #
18
16
  #
19
17
  # Kafka specific +publish_message+ options:
20
18
  # * :group_name (Used as Kafka partition_key)
@@ -89,10 +87,16 @@ module ManageIQ
89
87
 
90
88
  result = {:"bootstrap.servers" => hosts.join(',')}
91
89
  result[:"client.id"] = options[:client_ref] if options[:client_ref]
92
- result[:"sasl.username"] = options[:username] if options[:username]
93
- result[:"sasl.password"] = options[:password] if options[:password]
94
90
 
95
- result.merge(options.except(:port, :host, :hosts, :encoding, :protocol, :client_ref, :username, :password))
91
+ result[:"sasl.mechanism"] = "PLAIN"
92
+ result[:"sasl.username"] = options[:username] if options[:username]
93
+ result[:"sasl.password"] = options[:password] if options[:password]
94
+ result[:"security.protocol"] = !!options[:ssl] ? "SASL_SSL" : "PLAINTEXT"
95
+ result[:"ssl.ca.location"] = options[:ca_file] if options[:ca_file]
96
+ result[:"ssl.keystore.location"] = options[:keystore_location] if options[:keystore_location]
97
+ result[:"ssl.keystore.password"] = options[:keystore_password] if options[:keystore_password]
98
+
99
+ result.merge(options.except(:port, :host, :hosts, :encoding, :protocol, :client_ref, :username, :password, :ssl, :ca_file, :keystore_location, :keystore_password))
96
100
  end
97
101
  end
98
102
  end
@@ -94,6 +94,22 @@ module ManageIQ
94
94
  end
95
95
  end
96
96
 
97
+ def wait_for_topic(wait = true)
98
+ retry_count = 0
99
+ maximum_backoff = 300
100
+
101
+ begin
102
+ yield
103
+ rescue Rdkafka::RdkafkaError => err
104
+ raise if err.code != :unknown_topic_or_part || !wait
105
+
106
+ retry_count += 1
107
+ sleep([1.5 * retry_count, maximum_backoff].min)
108
+
109
+ retry
110
+ end
111
+ end
112
+
97
113
  def message_header_keys
98
114
  [:sender, :message_type, :class_name]
99
115
  end
@@ -17,13 +17,18 @@ module ManageIQ
17
17
  end
18
18
 
19
19
  def subscribe_messages_impl(options, &block)
20
+ wait = options.delete(:wait_for_topic)
21
+ wait = true if wait.nil?
22
+
20
23
  topic = address(options)
21
24
  options[:persist_ref] = GROUP_FOR_QUEUE_MESSAGES + topic
22
25
 
23
- queue_consumer = consumer(true, options)
24
- queue_consumer.subscribe(topic)
25
- queue_consumer.each do |message|
26
- process_queue_message(queue_consumer, topic, message, &block)
26
+ wait_for_topic(wait) do
27
+ queue_consumer = consumer(true, options)
28
+ queue_consumer.subscribe(topic)
29
+ queue_consumer.each do |message|
30
+ process_queue_message(queue_consumer, topic, message, &block)
31
+ end
27
32
  end
28
33
  end
29
34
  end
@@ -14,13 +14,19 @@ module ManageIQ
14
14
  end
15
15
 
16
16
  def subscribe_topic_impl(options, &block)
17
+ wait = options.delete(:wait_for_topic)
18
+ wait = true if wait.nil?
19
+
17
20
  topic = address(options)
18
21
 
19
22
  options[:persist_ref] = "#{GROUP_FOR_ADHOC_LISTENERS}_#{Time.now.to_i}" unless options[:persist_ref]
20
- topic_consumer = consumer(false, options)
21
- topic_consumer.subscribe(topic)
22
- topic_consumer.each do |message|
23
- process_topic_message(topic_consumer, topic, message, &block)
23
+
24
+ wait_for_topic(wait) do
25
+ topic_consumer = consumer(false, options)
26
+ topic_consumer.subscribe(topic)
27
+ topic_consumer.each do |message|
28
+ process_topic_message(topic_consumer, topic, message, &block)
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -61,7 +61,7 @@ module ManageIQ
61
61
  attr_reader :stomp_client
62
62
 
63
63
  def initialize(options)
64
- host = options.slice(:host, :port)
64
+ host = options.slice(:host, :port, :ssl)
65
65
  host[:passcode] = options[:password] if options[:password]
66
66
  host[:login] = options[:username] if options[:username]
67
67
 
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module Messaging
3
- VERSION = "1.1.2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manageiq-messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ManageIQ Authors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport