deimos-ruby 1.19.0 → 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: b73bb23507a35a1e4cd10af15db00f15f434f9464ed5451fb33ef64c25e48687
4
- data.tar.gz: cbaccc72e855b4cd9cbb928f2d7c5409d77dd1c356d209e6081889d6cb6092e8
3
+ metadata.gz: 58e9bdd29f309b3e911e71ca38b872560dbdfc5245a854bde579e8bb086a51b9
4
+ data.tar.gz: 1f0689ba41f0cd886c47c65e6876cbdeffd055680c2ef83f8399967c59a8a4fd
5
5
  SHA512:
6
- metadata.gz: 0fe9445824b00c2c492a1357965408c99f4cd36f40ea7431bbf79727466575d69a7c91cb0709204b57ad49cee8158d4c628e3b300a85b5da56203827ecbf27c9
7
- data.tar.gz: c0adb09c939eb8c2f784a58ffdfddf2ae6b11dad3dd1ba1be5572551cd4d97774db7f38ce7265f2b017fa0c5e339bf2a258dc9c21f14f3984a9e8ce1ef87ccad
6
+ metadata.gz: 0d6806620fcea3e34d863c70f761c90ebbd469537d43c315caeac74016fca213739ed575892314ae406f92909cd60e9edfc99b0872e326a867c1c0625d6c08ec
7
+ data.tar.gz: 9c53de460d27f5e59ff3f8b5a68a06c7ea1a05155755096c6be17873278d1b87d099f5beabe7ea192c4800a5b0483f958f9dc4e45fc7b65a6a7963749c1781b2
data/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ 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
+
10
12
  # 1.19.0 - 2023-02-21
11
13
 
12
14
  - Feature: When consuming data in batch mode, this adds ability to save data to multiple tables with `association_list`.
@@ -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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.19.0'
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.0
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-21 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
@@ -624,9 +624,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
624
624
  version: '0'
625
625
  required_rubygems_version: !ruby/object:Gem::Requirement
626
626
  requirements:
627
- - - ">="
627
+ - - ">"
628
628
  - !ruby/object:Gem::Version
629
- version: '0'
629
+ version: 1.3.1
630
630
  requirements: []
631
631
  rubygems_version: 3.3.20
632
632
  signing_key: