deimos-ruby 1.19.beta2 → 1.19.1.pre.beta1

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: c460892f0e27ef50137442b4ca2a1328479c54fe47b65850575e7ef3ff769ff7
4
- data.tar.gz: 57cbd04c1d2bb0582579ef9b0413c38cd4de4dcca682ca0ff201564815960d6e
3
+ metadata.gz: 58e9bdd29f309b3e911e71ca38b872560dbdfc5245a854bde579e8bb086a51b9
4
+ data.tar.gz: 1f0689ba41f0cd886c47c65e6876cbdeffd055680c2ef83f8399967c59a8a4fd
5
5
  SHA512:
6
- metadata.gz: c07bdf21830aa08b0151ad5db8291ebe597fac4265592ab549db6583ada6043765d92052cd7a6bae6f2264b2cbd15242659b8e108572bb32aaca710eb3fdc740
7
- data.tar.gz: 5c51d92c8956f54fe8a689015e46c195ab8ee2b543555c2b8e9b1263d3e58c3411b2263283a46e2f29bdf467f4b8d1cb49af528c8dc2d5450d98e5f5481b60ff
6
+ metadata.gz: 0d6806620fcea3e34d863c70f761c90ebbd469537d43c315caeac74016fca213739ed575892314ae406f92909cd60e9edfc99b0872e326a867c1c0625d6c08ec
7
+ data.tar.gz: 9c53de460d27f5e59ff3f8b5a68a06c7ea1a05155755096c6be17873278d1b87d099f5beabe7ea192c4800a5b0483f958f9dc4e45fc7b65a6a7963749c1781b2
data/CHANGELOG.md CHANGED
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ - Feature: Limit amount of transactions in a single database call with `max_db_batch_size`
11
+
12
+ # 1.19.0 - 2023-02-21
13
+
10
14
  - Feature: When consuming data in batch mode, this adds ability to save data to multiple tables with `association_list`.
15
+ - Fix bug with the `disable_producers` method where producers may remain disabled after the block
16
+ is done processing if an error occurs inside it.
11
17
 
12
18
  # 1.18.2 - 2022-11-14
13
19
 
@@ -83,6 +83,7 @@ key_config|nil|Configuration hash for message keys. See [Kafka Message Keys](../
83
83
  disabled|false|Set to true to skip starting an actual listener for this consumer on startup.
84
84
  group_id|nil|ID of the consumer group.
85
85
  use_schema_classes|nil|Set to true or false to enable or disable using the consumers schema classes. See [Generated Schema Classes](../README.md#generated-schema-classes)
86
+ max_db_batch_size|nil|Maximum limit for batching database calls to reduce the load on the db.
86
87
  max_concurrency|1|Number of threads created for this listener. Each thread will behave as an independent consumer. They don't share any state.
87
88
  start_from_beginning|true|Once the consumer group has checkpointed its progress in the topic's partitions, the consumers will always start from the checkpointed offsets, regardless of config. As such, this setting only applies when the consumer initially starts consuming from a topic
88
89
  max_bytes_per_partition|512.kilobytes|Maximum amount of data fetched from a single partition at a time.
@@ -78,8 +78,21 @@ module Deimos
78
78
  # deleted record (no payload)
79
79
  removed, upserted = messages.partition(&:tombstone?)
80
80
 
81
- upsert_records(upserted) if upserted.any?
82
- remove_records(removed) if removed.any?
81
+ if upserted.any?
82
+ if @max_db_batch_size
83
+ upserted.each_slice(@max_db_batch_size) { |group| upsert_records(group) }
84
+ else
85
+ upsert_records(upserted)
86
+ end
87
+ end
88
+
89
+ return unless removed.any?
90
+
91
+ if @max_db_batch_size
92
+ removed.each_slice(@max_db_batch_size) { |group| remove_records(group) }
93
+ else
94
+ remove_records(removed)
95
+ end
83
96
  end
84
97
 
85
98
  # Upsert any non-deleted records
@@ -48,6 +48,12 @@ module Deimos
48
48
  def compacted(val)
49
49
  config[:compacted] = val
50
50
  end
51
+
52
+ # @param limit [Integer] Maximum number of transactions in a single database call.
53
+ # @return [void]
54
+ def max_db_batch_size(limit)
55
+ config[:max_db_batch_size] = limit
56
+ end
51
57
  end
52
58
 
53
59
  # Setup
@@ -62,6 +68,7 @@ module Deimos
62
68
  end
63
69
 
64
70
  @compacted = self.class.config[:compacted] != false
71
+ @max_db_batch_size = self.class.config[:max_db_batch_size]
65
72
  end
66
73
 
67
74
  # Override this method (with `super`) if you want to add/change the default
@@ -424,6 +424,9 @@ module Deimos
424
424
  # Configure the usage of generated schema classes for this consumer
425
425
  # @return [Boolean]
426
426
  setting :use_schema_classes
427
+ # Optional maximum limit for batching database calls to reduce the load on the db.
428
+ # @return [Integer]
429
+ setting :max_db_batch_size
427
430
 
428
431
  # These are the phobos "listener" configs. See CONFIGURATION.md for more
429
432
  # info.
@@ -37,9 +37,12 @@ module Deimos
37
37
  Thread.current[:frk_disabled_producers] ||= Set.new
38
38
  producers_to_disable = producer_classes -
39
39
  Thread.current[:frk_disabled_producers].to_a
40
- Thread.current[:frk_disabled_producers] += producers_to_disable
41
- yield
42
- Thread.current[:frk_disabled_producers] -= producers_to_disable
40
+ begin
41
+ Thread.current[:frk_disabled_producers] += producers_to_disable
42
+ yield
43
+ ensure
44
+ Thread.current[:frk_disabled_producers] -= producers_to_disable
45
+ end
43
46
  end
44
47
 
45
48
  # Are producers disabled? If a class is passed in, check only that class.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.19.beta2'
4
+ VERSION = '1.19.1-beta1'
5
5
  end
@@ -90,7 +90,8 @@ describe Deimos, 'configuration' do
90
90
  offset_retention_time: nil,
91
91
  heartbeat_interval: 10,
92
92
  handler: 'ConsumerTest::MyConsumer',
93
- use_schema_classes: nil
93
+ use_schema_classes: nil,
94
+ max_db_batch_size: nil
94
95
  }, {
95
96
  topic: 'my_batch_consume_topic',
96
97
  group_id: 'my_batch_group_id',
@@ -107,7 +108,8 @@ describe Deimos, 'configuration' do
107
108
  offset_retention_time: nil,
108
109
  heartbeat_interval: 10,
109
110
  handler: 'ConsumerTest::MyBatchConsumer',
110
- use_schema_classes: nil
111
+ use_schema_classes: nil,
112
+ max_db_batch_size: nil
111
113
  }
112
114
  ],
113
115
  producer: {
@@ -258,7 +260,8 @@ describe Deimos, 'configuration' do
258
260
  offset_retention_time: 13,
259
261
  heartbeat_interval: 13,
260
262
  handler: 'MyConfigConsumer',
261
- use_schema_classes: false
263
+ use_schema_classes: false,
264
+ max_db_batch_size: nil
262
265
  }
263
266
  ],
264
267
  producer: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.beta2
4
+ version: 1.19.1.pre.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-02 00:00:00.000000000 Z
11
+ date: 2023-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf