waterdrop 2.7.0.rc1 → 2.7.0.rc2

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: e715326d8ff0715491d71ec9f42c60eb049258a9b5eaf739a0b088cf515427dd
4
- data.tar.gz: ed94552c972a77b5509907f59910d9ad37f033b718666d5520335bbb7f5d545f
3
+ metadata.gz: 1b34784c24ea856bc39203d722b386282960a3387b34171a6911d030a70b308f
4
+ data.tar.gz: fc095eae32f55193b98b3d1d9f13b96cdc74eaa9d2e25d50e773046e4749843a
5
5
  SHA512:
6
- metadata.gz: 460c2e3f8989059293835af6f5a96c5c3af68a4f47608d98d22a217cfd15179edd8a834e8c621ff10ae894c5713878c833f23a6af47d83cfc215454326aabc37
7
- data.tar.gz: 67d497d37e6be9593dbe14bfb0d4df7d8c80c18f176dda66987a372acaffa68f172ae415d9797b713af0c67f6127113bd49a6ebb7a778eec4f8b69b864bceea7
6
+ metadata.gz: aaec4c4216c2c8360c5a6b17e5a33fc726ee5fa6220d496216d1181c535b5755c4b6a51a28c9ff72757768c3c513cc3e81a3d3cad24a532d6cebe1a7bf2e8e1c
7
+ data.tar.gz: 8589024b7bcbd01f4c0f41c85224ace586dbe5e0a4679fe68abbdf66b9d49ff279ee44f15887cc864e50f0bc28302095c87e6d0863561db258db3e95e7507ad5
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -9,13 +9,33 @@ This release contains **BREAKING** changes. Make sure to read and apply upgrade
9
9
  - **[Breaking]** Change default timeouts so final delivery `message.timeout.ms` is less that `max_wait_time` so we do not end up with not final verdict.
10
10
  - **[Breaking]** Update all the time related configuration settings to be in `ms` and not mixed.
11
11
  - **[Breaking]** Remove no longer needed `wait_timeout` configuration option.
12
+ - **[Breaking]** Do **not** validate or morph (via middleware) messages added to the buffer prior to `flush_sync` or `flush_async`.
12
13
  - [Enhancement] Provide `WaterDrop::Producer#transaction?` that returns only when producer has an active transaction running.
13
14
  - [Enhancement] Introduce `instrument_on_wait_queue_full` flag (defaults to `true`) to be able to configure whether non critical (retryable) queue full errors should be instrumented in the error pipeline. Useful when building high-performance pipes with WaterDrop queue retry backoff as a throttler.
15
+ - [Enhancement] Treat the queue size as a gauge rather than a cumulative stat (isturdy).
16
+ - [Fix] Fix a case where purge on non-initialized client would crash.
17
+ - [Fix] Middlewares run twice when using buffered produce.
18
+ - [Fix] Validations run twice when using buffered produce.
14
19
 
15
20
  ### Upgrade Notes
16
21
 
17
22
  **PLEASE MAKE SURE TO READ AND APPLY THEM!**
18
23
 
24
+ #### `wait_timeout` Configuration No Longer Needed
25
+
26
+ The `wait_timeout` WaterDrop configuration option is no longer needed. You can safely remove it.
27
+
28
+ ```ruby
29
+ producer = WaterDrop::Producer.new
30
+
31
+ producer.setup do |config|
32
+ # Other config...
33
+
34
+ # Remove this, no longer needed
35
+ config.wait_timeout = 30
36
+ end
37
+ ```
38
+
19
39
  #### Time Settings Format Alignment
20
40
 
21
41
  **All** time-related values are now configured in milliseconds instead of some being in seconds and some in milliseconds.
@@ -23,7 +43,6 @@ This release contains **BREAKING** changes. Make sure to read and apply upgrade
23
43
  The values that were changed from seconds to milliseconds are:
24
44
 
25
45
  - `max_wait_timeout`
26
- - `wait_timeout`
27
46
  - `wait_backoff_on_queue_full`
28
47
  - `wait_timeout_on_queue_full`
29
48
  - `wait_backoff_on_transaction_command, default`
@@ -37,10 +56,10 @@ producer.setup do |config|
37
56
  config.deliver = true
38
57
 
39
58
  # Replace this:
40
- config.wait_timeout = 30
59
+ config.max_wait_timeout = 30
41
60
 
42
61
  # With
43
- config.wait_timeout = 30_000
62
+ config.max_wait_timeout = 30_000
44
63
  # ...
45
64
  end
46
65
  ```
@@ -82,6 +101,32 @@ Below, you can find a table with what has changed, the new defaults, and the cur
82
101
 
83
102
  This alignment ensures that when using sync operations or invoking `#wait`, any exception you get should give you a conclusive and final delivery verdict.
84
103
 
104
+ #### Buffering No Longer Early Validates Messages
105
+
106
+ As of version `2.7.0`, WaterDrop has changed how message buffering works. Previously, messages underwent validation and middleware processing when they were buffered. Now, these steps are deferred until just before dispatching the messages. The buffer functions strictly as a thread-safe storage area without performing any validations or middleware operations until the messages are ready to be sent.
107
+
108
+ This adjustment was made primarily to ensure that middleware runs and validations are applied when most relevant—shortly before message dispatch. This approach addresses potential issues with buffers that might hold messages for extended periods:
109
+
110
+ - **Temporal Relevance**: Validating and processing messages near their dispatch time helps ensure that actions such as partition assignments reflect the current system state. This is crucial in dynamic environments where system states are subject to rapid changes.
111
+
112
+ - **Stale State Management**: By delaying validations and middleware to the dispatch phase, the system minimizes the risk of acting on outdated information, which could lead to incorrect processing or partitioning decisions.
113
+
114
+ ```ruby
115
+ # Prior to 2.7.0 this would raise an error
116
+ producer.buffer(topic: nil, payload: '')
117
+ # => WaterDrop::Errors::MessageInvalidError
118
+
119
+ # After 2.7.0 buffer will not, but flush_async will
120
+ producer.buffer(topic: nil, payload: '')
121
+ # => all good here
122
+ producer.flush_async(topic: nil, payload: '')
123
+ # => WaterDrop::Errors::MessageInvalidError
124
+ ```
125
+
126
+ #### Middleware Execution Prior to Flush When Buffering
127
+
128
+ The timing of middleware execution has been adjusted. Middleware, which was previously run when messages were added to the buffer, will now only execute immediately before the messages are flushed from the buffer and dispatched. This change is similar to the validation-related changes.
129
+
85
130
  ## 2.6.14 (2024-02-06)
86
131
  - [Enhancement] Instrument `producer.connected` and `producer.closing` lifecycle events.
87
132
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterdrop (2.7.0.rc1)
5
- karafka-core (>= 2.4.0.rc1, < 3.0.0)
4
+ waterdrop (2.7.0.rc2)
5
+ karafka-core (>= 2.4.0.rc2, < 3.0.0)
6
6
  zeitwerk (~> 2.3)
7
7
 
8
8
  GEM
@@ -31,9 +31,9 @@ GEM
31
31
  ffi (1.16.3)
32
32
  i18n (1.14.4)
33
33
  concurrent-ruby (~> 1.0)
34
- karafka-core (2.4.0.rc1)
35
- karafka-rdkafka (>= 0.15.0.rc1, < 0.16.0)
36
- karafka-rdkafka (0.15.0.rc1)
34
+ karafka-core (2.4.0.rc2)
35
+ karafka-rdkafka (>= 0.15.0.rc2, < 0.16.0)
36
+ karafka-rdkafka (0.15.0.rc2)
37
37
  ffi (~> 1.15)
38
38
  mini_portile2 (~> 2.6)
39
39
  rake (> 12)
data/docker-compose.yml CHANGED
@@ -3,7 +3,7 @@ version: '2'
3
3
  services:
4
4
  kafka:
5
5
  container_name: kafka
6
- image: confluentinc/cp-kafka:7.6.0
6
+ image: confluentinc/cp-kafka:7.6.1
7
7
 
8
8
  ports:
9
9
  - 9092:9092
@@ -36,7 +36,7 @@ module WaterDrop
36
36
  setting :rd_kafka_metrics, default: [
37
37
  # Client metrics
38
38
  RdKafkaMetric.new(:count, :root, 'calls', 'tx_d'),
39
- RdKafkaMetric.new(:histogram, :root, 'queue.size', 'msg_cnt_d'),
39
+ RdKafkaMetric.new(:histogram, :root, 'queue.size', 'msg_cnt'),
40
40
 
41
41
  # Broker metrics
42
42
  RdKafkaMetric.new(:count, :brokers, 'deliver.attempts', 'txretries_d'),
@@ -12,9 +12,6 @@ module WaterDrop
12
12
  def buffer(message)
13
13
  ensure_active!
14
14
 
15
- message = middleware.run(message)
16
- validate_message!(message)
17
-
18
15
  @monitor.instrument(
19
16
  'message.buffered',
20
17
  producer_id: id,
@@ -32,9 +29,6 @@ module WaterDrop
32
29
  def buffer_many(messages)
33
30
  ensure_active!
34
31
 
35
- messages = middleware.run_many(messages)
36
- messages.each { |message| validate_message!(message) }
37
-
38
32
  @monitor.instrument(
39
33
  'messages.buffered',
40
34
  producer_id: id,
@@ -133,7 +133,12 @@ module WaterDrop
133
133
  @messages = []
134
134
  end
135
135
 
136
- @client.purge
136
+ # We should not purge if there is no client initialized
137
+ # It may not be initialized if we created a new producer that never connected to kafka,
138
+ # we used buffer and purged. In cases like this client won't exist
139
+ @connecting_mutex.synchronize do
140
+ @client&.purge
141
+ end
137
142
  end
138
143
  end
139
144
 
@@ -3,5 +3,5 @@
3
3
  # WaterDrop library
4
4
  module WaterDrop
5
5
  # Current WaterDrop version
6
- VERSION = '2.7.0.rc1'
6
+ VERSION = '2.7.0.rc2'
7
7
  end
data/waterdrop.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.description = spec.summary
17
17
  spec.license = 'MIT'
18
18
 
19
- spec.add_dependency 'karafka-core', '>= 2.4.0.rc1', '< 3.0.0'
19
+ spec.add_dependency 'karafka-core', '>= 2.4.0.rc2', '< 3.0.0'
20
20
  spec.add_dependency 'zeitwerk', '~> 2.3'
21
21
 
22
22
  spec.required_ruby_version = '>= 3.0.0'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterdrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0.rc1
4
+ version: 2.7.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2024-04-10 00:00:00.000000000 Z
38
+ date: 2024-04-18 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.4.0.rc1
46
+ version: 2.4.0.rc2
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
49
  version: 3.0.0
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 2.4.0.rc1
56
+ version: 2.4.0.rc2
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
59
  version: 3.0.0
metadata.gz.sig CHANGED
Binary file