Skip to content

Commit

Permalink
CCOL-2039: Linting and spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Pereira committed Nov 29, 2023
1 parent 807520f commit 30e60fa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/deimos/active_record_consume/batch_consumption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def update_database(messages)
valid_upserts, invalid_upserts = if max_db_batch_size
upserted.each_slice(max_db_batch_size) do |group|
valid, invalid = upsert_records(group)
valid_upserts.push(*valid) if valid.any?
invalid_upserts.push(*invalid) if invalid.any?
valid_upserts.push(*valid)
invalid_upserts.push(*invalid)
end
valid_upserts.compact!
invalid_upserts.compact!
Expand Down
12 changes: 8 additions & 4 deletions lib/deimos/config/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def self.validate_consumers

# @!visibility private
# @param kafka_config [FigTree::ConfigStruct]
# rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
def self.configure_producer_or_consumer(kafka_config)
klass = kafka_config.class_name.constantize
klass.class_eval do
Expand All @@ -90,15 +91,18 @@ def self.configure_producer_or_consumer(kafka_config)
if kafka_config.respond_to?(:bulk_import_id_column) # consumer
klass.config.merge!(
bulk_import_id_column: kafka_config.bulk_import_id_column,
replace_associations: kafka_config.replace_associations.nil? ?
Deimos.config.consumers.replace_associations :
kafka_config.replace_associations,
replace_associations: if kafka_config.replace_associations.nil?
Deimos.config.consumers.replace_associations
else
kafka_config.replace_associations
end,
bulk_import_id_generator: kafka_config.bulk_import_id_generator ||
Deimos.config.consumers.bulk_import_id_generator
)
end
end
end
# rubocop:enable Metrics/PerceivedComplexity, Metrics/AbcSize

define_settings do

Expand Down Expand Up @@ -249,7 +253,7 @@ def self.configure_producer_or_consumer(kafka_config)

# The default function to generate a bulk ID for bulk consumers
# @return [Block]
setting :bulk_import_id_generator, proc { SecureRandom.uuid }
setting(:bulk_import_id_generator, proc { SecureRandom.uuid })

# If true, multi-table consumers will blow away associations rather than appending to them.
# Applies to all consumers unless specified otherwise
Expand Down
4 changes: 2 additions & 2 deletions spec/config/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ def consume

it 'should override global configurations' do
described_class.configure do
consumers.bulk_import_id_generator proc { 'global' }
consumers.bulk_import_id_generator(-> { 'global' })
consumers.replace_associations true

consumer do
class_name 'MyConfigConsumer'
schema 'blah'
topic 'blah'
group_id 'myconsumerid'
bulk_import_id_generator proc { 'consumer' }
bulk_import_id_generator(-> { 'consumer' })
replace_associations false
end

Expand Down

0 comments on commit 30e60fa

Please sign in to comment.