karafka 2.2.2 → 2.2.4

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: 440133344045600ff04e132d48e16b83ce492d06616383f02f3c282ec28cd239
4
- data.tar.gz: e12def9a87bf4e731bc049f15352c86ed95bdcd970ac4081cc720bd268e99d26
3
+ metadata.gz: 7e6cb6a9b75c85409da5835992ea35b8db57e7f38906d31e2dd4e6345027a357
4
+ data.tar.gz: 40ceebe714cf3db25dcc33a8b5ff8ea1426101aaf18862be907298334beddc16
5
5
  SHA512:
6
- metadata.gz: 2c9deb6fdd1172e4a40828d8650d016e0cd660e3c3f4a98ab9bf6abcb2ce77179206e7d898ddfce4379fea994c4f7e3840a2a5b768648f13aa11504efd55feb0
7
- data.tar.gz: 3543d19c5066d144d0d9a15d366d522e5b0134a3df601ef01e416659d71d07d977fef2e71d170dfa5382f8ce496ed554dd004b45bf936d472b2aab75ef473ac5
6
+ metadata.gz: 5e0f780dc0d46e5917df86afba04cb9620547abfc188b550b7667035ed624ab5a36a2dd35e9437fe43d3be66868f409f9d9c3b71d61825b6830261de2a973e27
7
+ data.tar.gz: bc2182903ab8bc48ed431054f2bf23226277608b017b070d8a7cf697b700dc612bea38de3ff1659b481a788e507e1dba0a3972f15e9434bbba8ad0cb48ecb5f5
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Karafka framework changelog
2
2
 
3
+ ## 2.2.4 (2023-09-13)
4
+ - [Enhancement] Compensate for potential Kafka cluster drifts vs consumer drift in batch metadata (#1611).
5
+
6
+ ## 2.2.3 (2023-09-12)
7
+ - [Fix] Karafka admin time based offset lookup can break for one non-default partition.
8
+
3
9
  ## 2.2.2 (2023-09-11)
4
10
  - [Feature] Provide ability to define routing defaults.
5
11
  - [Maintenance] Require `karafka-core` `>=` `2.2.2`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (2.2.2)
4
+ karafka (2.2.4)
5
5
  karafka-core (>= 2.2.2, < 2.3.0)
6
6
  thor (>= 0.20)
7
7
  waterdrop (>= 2.6.6, < 3.0.0)
data/docker-compose.yml CHANGED
@@ -1,14 +1,14 @@
1
1
  version: '2'
2
2
  services:
3
3
  zookeeper:
4
- container_name: karafka_21_zookeeper
4
+ container_name: karafka_22_zookeeper
5
5
  image: wurstmeister/zookeeper
6
6
  restart: on-failure
7
7
  ports:
8
8
  - '2181:2181'
9
9
 
10
10
  kafka:
11
- container_name: karafka_21_kafka
11
+ container_name: karafka_22_kafka
12
12
  image: wurstmeister/kafka
13
13
  ports:
14
14
  - '9092:9092'
data/lib/karafka/admin.rb CHANGED
@@ -257,7 +257,10 @@ module Karafka
257
257
  )
258
258
 
259
259
  real_offsets = consumer.offsets_for_times(tpl)
260
- detected_offset = real_offsets.to_h.dig(name, partition)
260
+ detected_offset = real_offsets
261
+ .to_h
262
+ .fetch(name)
263
+ .find { |p_data| p_data.partition == partition }
261
264
 
262
265
  detected_offset&.offset || raise(Errors::InvalidTimeBasedOffsetError)
263
266
  else
@@ -26,13 +26,33 @@ module Karafka
26
26
  topic: topic.name,
27
27
  # We go with the assumption that the creation of the whole batch is the last message
28
28
  # creation time
29
- created_at: messages.last&.timestamp || nil,
29
+ created_at: local_created_at(messages.last),
30
30
  # When this batch was built and scheduled for execution
31
31
  scheduled_at: scheduled_at,
32
32
  # This needs to be set to a correct value prior to processing starting
33
33
  processed_at: nil
34
34
  )
35
35
  end
36
+
37
+ private
38
+
39
+ # Code that aligns the batch creation at into our local time. If time of current machine
40
+ # and the Kafka cluster drift, this helps not to allow this to leak into the framework.
41
+ #
42
+ # @param last_message [::Karafka::Messages::Message, nil] last message from the batch or
43
+ # nil if no message
44
+ # @return [Time] batch creation time. Now if no messages (workless flow) or the last
45
+ # message time as long as the message is not from the future
46
+ # @note Message can be from the future in case consumer machine and Kafka cluster drift
47
+ # apart and the machine is behind the cluster.
48
+ def local_created_at(last_message)
49
+ now = ::Time.now
50
+
51
+ return now unless last_message
52
+
53
+ timestamp = last_message.timestamp
54
+ timestamp > now ? now : timestamp
55
+ end
36
56
  end
37
57
  end
38
58
  end
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.2.2'
6
+ VERSION = '2.2.4'
7
7
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.4
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: 2023-09-11 00:00:00.000000000 Z
38
+ date: 2023-09-13 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka-core
metadata.gz.sig CHANGED
Binary file