deimos-ruby 1.19.1.pre.beta1 → 1.19.2

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: 58e9bdd29f309b3e911e71ca38b872560dbdfc5245a854bde579e8bb086a51b9
4
- data.tar.gz: 1f0689ba41f0cd886c47c65e6876cbdeffd055680c2ef83f8399967c59a8a4fd
3
+ metadata.gz: 34ab9629daca099d1745e192f379cdd5289c081fc241d2920966485c896611c1
4
+ data.tar.gz: 9dd093633667f4560312c0cd945083fb605d29cb4074d7807ea5a98c1a54d68a
5
5
  SHA512:
6
- metadata.gz: 0d6806620fcea3e34d863c70f761c90ebbd469537d43c315caeac74016fca213739ed575892314ae406f92909cd60e9edfc99b0872e326a867c1c0625d6c08ec
7
- data.tar.gz: 9c53de460d27f5e59ff3f8b5a68a06c7ea1a05155755096c6be17873278d1b87d099f5beabe7ea192c4800a5b0483f958f9dc4e45fc7b65a6a7963749c1781b2
6
+ metadata.gz: 02276cba6707533b241b0ea2b0f3c8bf74ebf8120515b7ca883a080f4bdd80a1e15e3120097d3b0627a6519b4dc4ccdf5fc4f4e2950111ae69c12a262ec5ac9b
7
+ data.tar.gz: 4a6236f8d659c90ef864a3b99b04518c5f045235079f7168540b4d25f862ac2554d228c9ea94d10f93dd1ead0c1edd8476a66c6b360cbb572ccdaf9740212dfa
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`
10
+ # 1.19.2 - 2023-03-20
11
+
12
+ - Fix for saving associations where the primary key is not `id`.
13
+
14
+ # 1.19.1 - 2023-03-17
15
+
16
+ - Fix for `rails g deimos:bulk_import_id` generator.
11
17
 
12
18
  # 1.19.0 - 2023-02-21
13
19
 
data/README.md CHANGED
@@ -360,7 +360,7 @@ end
360
360
  Sometimes, the Kafka message needs to be saved to multiple database tables. For example, if a `User` topic provides you metadata and profile image for users, we might want to save it to multiple tables: `User` and `Image`.
361
361
 
362
362
  - The `association_list` configuration allows you to achieve this use case.
363
- - The optional `bulk_import_id_column` config allows you to specify column_name on `record_class` which can be used to retrieve IDs after save. Defaults to `bulk_import_id`
363
+ - The `bulk_import_id_column` config allows you to specify column_name on `record_class` which can be used to retrieve IDs after save. Defaults to `bulk_import_id`. This config is *required* if you have associations but optional if you do not.
364
364
 
365
365
  You must override the `build_records` and `bulk_import_columns` methods on your ActiveRecord class for this feature to work.
366
366
  - `build_records` - This method is required to set the value of the `bulk_import_id` column and map Kafka messages to ActiveRecord model objects.
@@ -374,7 +374,7 @@ class MyBatchConsumer < Deimos::ActiveRecordConsumer
374
374
 
375
375
  def build_records(messages)
376
376
  # Initialise bulk_import_id and build ActiveRecord objects out of Kafka message attributes
377
- messages.each do |m|
377
+ messages.map do |m|
378
378
  u = User.new(first_name: m.first_name, bulk_import_id: SecureRandom.uuid)
379
379
  i = Image.new(attr1: m.image_url)
380
380
  u.images << i
@@ -83,7 +83,6 @@ 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.
87
86
  max_concurrency|1|Number of threads created for this listener. Each thread will behave as an independent consumer. They don't share any state.
88
87
  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
89
88
  max_bytes_per_partition|512.kilobytes|Maximum amount of data fetched from a single partition at a time.
@@ -78,21 +78,8 @@ module Deimos
78
78
  # deleted record (no payload)
79
79
  removed, upserted = messages.partition(&:tombstone?)
80
80
 
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
81
+ upsert_records(upserted) if upserted.any?
82
+ remove_records(removed) if removed.any?
96
83
  end
97
84
 
98
85
  # Upsert any non-deleted records
@@ -150,7 +137,7 @@ module Deimos
150
137
  # Get associated `has_one` or `has_many` records for each entity
151
138
  sub_records = Array(entity.send(assoc.name))
152
139
  # Set IDS from master to each of the records in `has_one` or `has_many` relation
153
- sub_records.each { |d| d.send("#{assoc.send(:foreign_key)}=", entity.id) }
140
+ sub_records.each { |d| d.send("#{assoc.foreign_key}=", entity.send(assoc.active_record_primary_key)) }
154
141
  sub_records
155
142
  }.flatten
156
143
 
@@ -256,7 +243,7 @@ module Deimos
256
243
  return if entities.first.respond_to?(@bulk_import_id_column)
257
244
 
258
245
  raise "Create bulk_import_id on #{entities.first.class} and set it in `build_records` for associations." \
259
- ' Run rails g deimos:bulk_import_id:setup to create the migration.'
246
+ ' Run rails g deimos:bulk_import_id {table} to create the migration.'
260
247
  end
261
248
 
262
249
  # Fills Primary Key ID on in-memory objects.
@@ -48,12 +48,6 @@ 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
57
51
  end
58
52
 
59
53
  # Setup
@@ -68,7 +62,6 @@ module Deimos
68
62
  end
69
63
 
70
64
  @compacted = self.class.config[:compacted] != false
71
- @max_db_batch_size = self.class.config[:max_db_batch_size]
72
65
  end
73
66
 
74
67
  # Override this method (with `super`) if you want to add/change the default
@@ -424,9 +424,6 @@ 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
430
427
 
431
428
  # These are the phobos "listener" configs. See CONFIGURATION.md for more
432
429
  # info.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.19.1-beta1'
4
+ VERSION = '1.19.2'
5
5
  end
@@ -12,8 +12,6 @@ module Deimos
12
12
  include Rails::Generators::Migration
13
13
  include ActiveRecord::Generators::Migration
14
14
 
15
- namespace 'deimos:bulk_import_id:setup'
16
-
17
15
  argument :table_name, desc: 'The table to add bulk import column.', required: true
18
16
  argument :column_name, desc: 'The bulk import ID column name.', default: 'bulk_import_id'
19
17
 
@@ -108,7 +108,7 @@ module ActiveRecordBatchConsumerTest
108
108
  publish_batch([{ key: 2,
109
109
  payload: { test_id: 'xyz', some_int: 5, title: 'Widget Title' } }])
110
110
  }.to raise_error('Create bulk_import_id on ActiveRecordBatchConsumerTest::Widget'\
111
- ' and set it in `build_records` for associations. Run rails g deimos:bulk_import_id:setup'\
111
+ ' and set it in `build_records` for associations. Run rails g deimos:bulk_import_id {table}'\
112
112
  ' to create the migration.')
113
113
  end
114
114
  end
@@ -90,8 +90,7 @@ 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,
94
- max_db_batch_size: nil
93
+ use_schema_classes: nil
95
94
  }, {
96
95
  topic: 'my_batch_consume_topic',
97
96
  group_id: 'my_batch_group_id',
@@ -108,8 +107,7 @@ describe Deimos, 'configuration' do
108
107
  offset_retention_time: nil,
109
108
  heartbeat_interval: 10,
110
109
  handler: 'ConsumerTest::MyBatchConsumer',
111
- use_schema_classes: nil,
112
- max_db_batch_size: nil
110
+ use_schema_classes: nil
113
111
  }
114
112
  ],
115
113
  producer: {
@@ -260,8 +258,7 @@ describe Deimos, 'configuration' do
260
258
  offset_retention_time: 13,
261
259
  heartbeat_interval: 13,
262
260
  handler: 'MyConfigConsumer',
263
- use_schema_classes: false,
264
- max_db_batch_size: nil
261
+ use_schema_classes: false
265
262
  }
266
263
  ],
267
264
  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.1.pre.beta1
4
+ version: 1.19.2
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-03-17 00:00:00.000000000 Z
11
+ date: 2023-03-20 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: 1.3.1
629
+ version: '0'
630
630
  requirements: []
631
631
  rubygems_version: 3.3.20
632
632
  signing_key: