deimos-ruby 1.8.1.pre.beta4 → 1.8.1.pre.beta9

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: bb7b72866d42e8a74dfe9e441b5e1436c81cb16684d2985840980c010416e8af
4
- data.tar.gz: 97b806b1b52807ea487a0da20099450d005bf71ac4cd88fbc5eb50aae66726bb
3
+ metadata.gz: 18ef8f674c86fcdba3fc7a2556162b1104084fd38c6ee8046ed773e9352633bd
4
+ data.tar.gz: 60f5a05874a0cd2cd6abceb7cfc5af1a01068a2a3cc4cc4e65dd59d42783468a
5
5
  SHA512:
6
- metadata.gz: 0d98923fd57076e391a9e8e1c2a6afb83fbde7769d646fc88d599921d9b0d55a6b1c7bd0df7f3344c71c66915766484bd0c9c19cfa72fef7f9299ab41cf66232
7
- data.tar.gz: c537564c70e3d297ca76000cd683f6c0891c18dc3b54d95b9aa6f3ea4b390a59fd2992d070112afc1e562c0bc59e0a4b523cb7bd4d71efafe2b03083df5273a6
6
+ metadata.gz: '0963acc646195fac41c3aaa71c67bbdc253bf26fa650c6132096a7912b665bb1956e3511f41db08309fbc9db35a6717c7a48f17a340039732bced4c5b6bd8b7a'
7
+ data.tar.gz: 0c642071d49e099d8516ed05c5856b1bba00a432c30567b3c79491654b0e1b1cc43e51a4c20f9765e0f2cbcd4af6550fbaa7620b1693d9ed342202609e496914
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ ## 1.8.1-beta9 - 2020-08-27
11
+
12
+ ### Fixes :wrench:
13
+ - Moved the TestHelpers hook to `before(:suite)` to allow for
14
+ overriding e.g. in integration tests.
15
+
16
+ ## 1.8.1-beta7 - 2020-08-25
17
+
18
+ ### Fixes :wrench:
19
+ - Fix for crash when sending pending metrics with DB producer.
20
+ - Fix for compacting messages if all the keys are already unique
21
+ (fixes [#75](https://github.com/flipp-oss/deimos/issues/75))
22
+
23
+ ## 1.8.1-beta6 - 2020-08-13
24
+
25
+ ### Fixes :wrench:
26
+
27
+ - Fix for consuming nil payloads with Ruby 2.3.
28
+
29
+ ## 1.8.1-beta5 - 2020-08-13
30
+
31
+ ### Fixes :wrench:
32
+ - Fix regression bug which introduces backwards incompatibility
33
+ with ActiveRecordProducer's `record_attributes` method.
34
+
10
35
  ## 1.8.1-beta4 - 2020-08-12
11
36
 
12
37
  ### Fixes :wrench:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.8.1.pre.beta3)
4
+ deimos-ruby (1.8.1.pre.beta8)
5
5
  avro_turf (~> 0.11)
6
6
  phobos (~> 1.9)
7
7
  ruby-kafka (~> 0.7)
data/README.md CHANGED
@@ -599,7 +599,7 @@ class MyConsumer < Deimos::ActiveRecordConsumer
599
599
 
600
600
  # Optional override to change the attributes of the record before they
601
601
  # are saved.
602
- def record_attributes(payload)
602
+ def record_attributes(payload, key)
603
603
  super.merge(:some_field => 'some_value')
604
604
  end
605
605
 
@@ -680,7 +680,7 @@ class MyConsumer < Deimos::ActiveRecordConsumer
680
680
 
681
681
  # Optional override to change the attributes of the record before they
682
682
  # are saved.
683
- def record_attributes(payload)
683
+ def record_attributes(payload, key)
684
684
  super.merge(:some_field => 'some_value')
685
685
  end
686
686
  end
@@ -921,6 +921,17 @@ Deimos::TestHelpers.schemas_compatible?(schema1, schema2)
921
921
 
922
922
  ### Integration Test Helpers
923
923
 
924
+ When running integration tests, you'll want to override the default test helper settings:
925
+
926
+ ```ruby
927
+ config.before(:each, :my_integration_metadata) do
928
+ Deimos.configure do
929
+ producers.backend :kafka
930
+ schema.backend :avro_schema_registry
931
+ end
932
+ end
933
+ ```
934
+
924
935
  You can use the `InlineConsumer` class to help with integration testing,
925
936
  with a full external Kafka running.
926
937
 
@@ -88,8 +88,13 @@ module Deimos
88
88
 
89
89
  # Create payloads with payload + key attributes
90
90
  upserts = messages.map do |m|
91
- record_attributes(m.payload, m.key)&.
92
- merge(record_key(m.key))
91
+ attrs = if self.method(:record_attributes).parameters.size == 2
92
+ record_attributes(m.payload, m.key)
93
+ else
94
+ record_attributes(m.payload)
95
+ end
96
+
97
+ attrs&.merge(record_key(m.key))
93
98
  end
94
99
 
95
100
  # If overridden record_attributes indicated no record, skip
@@ -37,7 +37,14 @@ module Deimos
37
37
  record = klass.new
38
38
  assign_key(record, payload, key)
39
39
  end
40
- attrs = record_attributes(payload.with_indifferent_access, key)
40
+
41
+ # for backwards compatibility
42
+ # TODO next major release we should deprecate this
43
+ attrs = if self.method(:record_attributes).parameters.size == 2
44
+ record_attributes(payload.with_indifferent_access, key)
45
+ else
46
+ record_attributes(payload.with_indifferent_access)
47
+ end
41
48
  # don't use attributes= - bypass Rails < 5 attr_protected
42
49
  attrs.each do |k, v|
43
50
  record.send("#{k}=", v)
@@ -10,7 +10,7 @@ module Deimos
10
10
 
11
11
  # :nodoc:
12
12
  def around_consume(payload, metadata)
13
- decoded_payload = payload.dup
13
+ decoded_payload = payload.nil? ? nil : payload.dup
14
14
  new_metadata = metadata.dup
15
15
  benchmark = Benchmark.measure do
16
16
  _with_span do
@@ -30,18 +30,19 @@ module Deimos
30
30
  d_config.consumers.reraise_errors = true
31
31
  d_config.kafka.seed_brokers ||= ['test_broker']
32
32
  d_config.schema.backend = Deimos.schema_backend_class.mock_backend
33
+ d_config.producers.backend = :test
33
34
  end
34
35
  end
35
- end
36
36
 
37
- before(:each) do
38
- client = double('client').as_null_object
39
- allow(client).to receive(:time) do |*_args, &block|
40
- block.call
37
+ config.before(:each) do
38
+ client = double('client').as_null_object
39
+ allow(client).to receive(:time) do |*_args, &block|
40
+ block.call
41
+ end
42
+ Deimos::Backends::Test.sent_messages.clear
41
43
  end
42
- Deimos.configure { |c| c.producers.backend = :test }
43
- Deimos::Backends::Test.sent_messages.clear
44
44
  end
45
+
45
46
  end
46
47
 
47
48
  # @deprecated
@@ -161,7 +161,7 @@ module Deimos
161
161
  # the oldest message, or the last time we processed, whichever comes
162
162
  # last.
163
163
  if message_record
164
- record_earliest = record.earliest
164
+ record_earliest = message_record.earliest
165
165
  # SQLite gives a string here
166
166
  if record_earliest.is_a?(String)
167
167
  record_earliest = Time.zone.parse(record_earliest)
@@ -231,7 +231,7 @@ module Deimos
231
231
  return batch if config.compact_topics != :all &&
232
232
  !config.compact_topics.include?(topic)
233
233
 
234
- batch.reverse.uniq!(&:key).reverse!
234
+ batch.reverse.uniq(&:key).reverse!
235
235
  end
236
236
  end
237
237
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.8.1-beta4'
4
+ VERSION = '1.8.1-beta9'
5
5
  end
@@ -32,6 +32,12 @@ module ConsumerTest
32
32
  end
33
33
  end
34
34
 
35
+ it 'should consume a nil message' do
36
+ test_consume_message(MyConsumer, nil) do |payload, _metadata|
37
+ expect(payload).to be_nil
38
+ end
39
+ end
40
+
35
41
  it 'should consume a message idempotently' do
36
42
  # testing for a crash and re-consuming the same message/metadata
37
43
  key = { 'test_id' => 'foo' }
@@ -30,6 +30,7 @@ describe Deimos::KafkaListener do
30
30
  end
31
31
 
32
32
  it 'should listen to publishing errors and republish as Deimos events' do
33
+ allow(Deimos::Producer).to receive(:descendants).and_return([MyProducer])
33
34
  Deimos.subscribe('produce_error') do |event|
34
35
  expect(event.payload).to include(
35
36
  producer: MyProducer,
@@ -183,6 +183,7 @@ RSpec.configure do |config|
183
183
  config.before(:each) do
184
184
  Deimos.config.reset!
185
185
  Deimos.configure do |deimos_config|
186
+ deimos_config.producers.backend = :test
186
187
  deimos_config.phobos_config_file = File.join(File.dirname(__FILE__), 'phobos.yml')
187
188
  deimos_config.schema.path = File.join(File.expand_path(__dir__), 'schemas')
188
189
  deimos_config.consumers.reraise_errors = true
@@ -155,6 +155,10 @@ each_db_config(Deimos::Utils::DbProducer) do
155
155
  Deimos.configure { |c| c.db_producer.compact_topics = [] }
156
156
  end
157
157
 
158
+ it 'should compact messages when all messages are unique' do
159
+ Deimos.configure { |c| c.db_producer.compact_topics = %w(my-topic my-topic2) }
160
+ expect(producer.compact_messages(deduped_batch)).to eq(deduped_batch)
161
+ end
158
162
  end
159
163
  end
160
164
 
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.8.1.pre.beta4
4
+ version: 1.8.1.pre.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf