deimos-ruby 1.8.1.pre.beta3 → 1.8.1.pre.beta8

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: 380e0a86786dc4b308858186e5f97a102d13e0d0ac72ca172e941d42b6dfb81a
4
- data.tar.gz: ca99315cf3ee096160c24f15d194ce73d77d95b1e7c27b3454e2a5e4165ef156
3
+ metadata.gz: ec9800e76e6cc4e78af1e9f52d1f5bd0ab46820a223c663684278f5ef7c80e68
4
+ data.tar.gz: 1b7f4b9cad7933bea186efdf1a7827f8dac5275b296339131ea12c37fcfdd5c7
5
5
  SHA512:
6
- metadata.gz: 8aa602000e702a9ce3c271b0796f4ea864fdc0acaf0852fdf7bdc3bf51e0eaf2df3265420e2558f37e3c174a5a555d43920323bb3a1539753b8821ae00ad6f32
7
- data.tar.gz: c505ef8b587d2a405f9773a3c0f5a178f27811a071a4579ecfbe46c9f75759f1375b773949a384cdd465638ca7e95c53e6e34d8a1b7dd27e5128e03a90c0c3b1
6
+ metadata.gz: 17ae44bfadfb402e0573ade637c2b5ab69cff91465f8bc3771948a2136e2bbb2c7080ca1dd8e18f7cd11c0f13aa7def2b3557255094e358f002c747915ad4eec
7
+ data.tar.gz: 1d885ffb79c43422881e48cde1def8a0fe11bfa1a36250792b09f03d0a3ef7444f711e6b7ae4995d2a0aeb9ef6c036d37df60f90ebb0025b3c3cc14d2e48dbd3
@@ -7,6 +7,35 @@ 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-beta8 - 2020-08-27
11
+ ### Fixes :wrench:
12
+ - Moved the TestHelpers hook to `prepend_before` to allow for
13
+ overriding e.g. in integration tests.
14
+
15
+ ## 1.8.1-beta7 - 2020-08-25
16
+
17
+ ### Fixes :wrench:
18
+ - Fix for crash when sending pending metrics with DB producer.
19
+ - Fix for compacting messages if all the keys are already unique
20
+ (fixes [#75](https://github.com/flipp-oss/deimos/issues/75))
21
+
22
+ ## 1.8.1-beta6 - 2020-08-13
23
+
24
+ ### Fixes :wrench:
25
+
26
+ - Fix for consuming nil payloads with Ruby 2.3.
27
+
28
+ ## 1.8.1-beta5 - 2020-08-13
29
+
30
+ ### Fixes :wrench:
31
+ - Fix regression bug which introduces backwards incompatibility
32
+ with ActiveRecordProducer's `record_attributes` method.
33
+
34
+ ## 1.8.1-beta4 - 2020-08-12
35
+
36
+ ### Fixes :wrench:
37
+ - Fix regression bug where arrays were not being encoded
38
+
10
39
  ## 1.8.1-beta3 - 2020-08-05
11
40
 
12
41
  ### 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.beta7)
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
@@ -75,6 +75,8 @@ module Deimos
75
75
  coerce_union(type, val)
76
76
  when :record
77
77
  coerce_record(type, val)
78
+ else
79
+ val
78
80
  end
79
81
  end
80
82
 
@@ -34,7 +34,7 @@ module Deimos
34
34
  end
35
35
  end
36
36
 
37
- before(:each) do
37
+ prepend_before(:each) do
38
38
  client = double('client').as_null_object
39
39
  allow(client).to receive(:time) do |*_args, &block|
40
40
  block.call
@@ -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-beta3'
4
+ VERSION = '1.8.1-beta8'
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,
@@ -246,6 +246,7 @@ module ProducerTest
246
246
  MyNestedSchemaProducer.publish(
247
247
  'test_id' => 'foo',
248
248
  'test_float' => BigDecimal('123.456'),
249
+ 'test_array' => ['1'],
249
250
  'some_nested_record' => {
250
251
  'some_int' => 123,
251
252
  'some_float' => BigDecimal('456.789'),
@@ -257,6 +258,7 @@ module ProducerTest
257
258
  expect(MyNestedSchemaProducer.topic).to have_sent(
258
259
  'test_id' => 'foo',
259
260
  'test_float' => 123.456,
261
+ 'test_array' => ['1'],
260
262
  'some_nested_record' => {
261
263
  'some_int' => 123,
262
264
  'some_float' => 456.789,
@@ -14,6 +14,13 @@
14
14
  "type": "float",
15
15
  "doc": "test float"
16
16
  },
17
+ {
18
+ "name": "test_array",
19
+ "type": {
20
+ "type": "array",
21
+ "items": "string"
22
+ }
23
+ },
17
24
  {
18
25
  "name": "some_nested_record",
19
26
  "doc": "some nested record",
@@ -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.beta3
4
+ version: 1.8.1.pre.beta8
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-05 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