manageiq-messaging 1.1.2 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 191fa67428995db65820476da103a6e5aec0d9dd9c39197f4f66acea13503d2e
4
- data.tar.gz: 07fd94d6722e61ea6518d52fd2352b6f2e7b432313af30a30715805af4800a1e
3
+ metadata.gz: cfe85cf657f8c2c1abbe3c4e89fbaddb02339972f0c93c2e325b5eadba10b456
4
+ data.tar.gz: 5e28a2cc86fa33a89893cad6652aa20acd5af801f5061c5a2c0632668f1c94c8
5
5
  SHA512:
6
- metadata.gz: d3be8c5b3346bed57d236b2e5ce56524fc0f5777e650c2dbe5efe428832b29e028e27037d484c47dddb0598b15c6b1aedaae7bff02841ca51880eb03a4dd8346
7
- data.tar.gz: 6520395f34a358aff5aa447345ad8f9ea335fdf961bb9a929cebaa25c0daa9e97e1a8e23dabaea056929ae8543beac62de59de0cb63104ad2831284009f86ddd
6
+ metadata.gz: a20dad2e6813bdacfc24ebfb81a9edff1ae37156de353c307d8e403cb27915a4da928872feff00cb157fb8aa5539e67d024afc20c7ceaba79f68ea564cbbdd27
7
+ data.tar.gz: 786daacf2af78548fe5695e38d36083b21e1c9bedfe13977d287a5b8f1ae5f22d58f5b379ca40144382873e08b120acb0bebf2835cfda0d7eee67e556c085aee
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.0] - 19-Oct-2022
10
+
11
+ * Add ssl and ca_file options to `Client.open` [#76](https://github.com/ManageIQ/manageiq-messaging/pull/76)
12
+ * Add wait_for_topic option to Kafka [#75](https://github.com/ManageIQ/manageiq-messaging/pull/75)
13
+
9
14
  ## [1.1.2] - 6-Oct-2022
10
15
 
11
16
  * Fix kafka publish_topic on ruby3 [#74](https://github.com/ManageIQ/manageiq-messaging/pull/74)
@@ -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,14 @@ 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[:"ssl.ca.location"] = options[:ca_file] if options[:ca_file]
95
+ result[:"security.protocol"] = !!options[:ssl] ? "SASL_SSL" : "PLAINTEXT"
96
+
97
+ result.merge(options.except(:port, :host, :hosts, :encoding, :protocol, :client_ref, :username, :password, :ssl, :ca_file))
96
98
  end
97
99
  end
98
100
  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.2.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.2.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: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport