deimos-ruby 1.8.1.pre.beta3 → 1.8.1.pre.beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -2
- data/lib/deimos/active_record_consume/batch_consumption.rb +7 -2
- data/lib/deimos/active_record_consume/message_consumption.rb +8 -1
- data/lib/deimos/consume/message_consumption.rb +1 -1
- data/lib/deimos/schema_backends/avro_schema_coercer.rb +2 -0
- data/lib/deimos/test_helpers.rb +1 -1
- data/lib/deimos/utils/db_producer.rb +2 -2
- data/lib/deimos/version.rb +1 -1
- data/spec/consumer_spec.rb +6 -0
- data/spec/kafka_listener_spec.rb +1 -0
- data/spec/producer_spec.rb +2 -0
- data/spec/schemas/com/my-namespace/MyNestedSchema.avsc +7 -0
- data/spec/utils/db_producer_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec9800e76e6cc4e78af1e9f52d1f5bd0ab46820a223c663684278f5ef7c80e68
|
|
4
|
+
data.tar.gz: 1b7f4b9cad7933bea186efdf1a7827f8dac5275b296339131ea12c37fcfdd5c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17ae44bfadfb402e0573ade637c2b5ab69cff91465f8bc3771948a2136e2bbb2c7080ca1dd8e18f7cd11c0f13aa7def2b3557255094e358f002c747915ad4eec
|
|
7
|
+
data.tar.gz: 1d885ffb79c43422881e48cde1def8a0fe11bfa1a36250792b09f03d0a3ef7444f711e6b7ae4995d2a0aeb9ef6c036d37df60f90ebb0025b3c3cc14d2e48dbd3
|
data/CHANGELOG.md
CHANGED
|
@@ -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:
|
data/Gemfile.lock
CHANGED
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
|
|
92
|
-
|
|
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
|
-
|
|
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)
|
data/lib/deimos/test_helpers.rb
CHANGED
|
@@ -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 =
|
|
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
|
|
234
|
+
batch.reverse.uniq(&:key).reverse!
|
|
235
235
|
end
|
|
236
236
|
end
|
|
237
237
|
end
|
data/lib/deimos/version.rb
CHANGED
data/spec/consumer_spec.rb
CHANGED
|
@@ -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' }
|
data/spec/kafka_listener_spec.rb
CHANGED
|
@@ -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,
|
data/spec/producer_spec.rb
CHANGED
|
@@ -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,
|
|
@@ -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.
|
|
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-
|
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: avro_turf
|