deimos-ruby 1.3.0.pre.beta1 → 1.3.0.pre.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/deimos/base_consumer.rb +1 -2
- data/lib/deimos/batch_consumer.rb +4 -2
- data/lib/deimos/consumer.rb +1 -1
- data/lib/deimos/shared_config.rb +5 -1
- data/lib/deimos/test_helpers.rb +3 -1
- data/lib/deimos/version.rb +1 -1
- 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: 51d996dd84852cb13e3907865decb60c9461dbe95c7ac609520384ace3ee99e9
|
4
|
+
data.tar.gz: e337ab82edb93fcb194319a0fdc423ef174ed2140f4bced78617a82cc601bfe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0295f4730381d36d2599bc01852610d4a18e821438799fa9d5c8cc8fd87332d07231ee4676d0f3ff5406ba12e95fe404306dc11c630f581732a24cf38d068cf8'
|
7
|
+
data.tar.gz: f27882ee2e78c799aad970fe5c38056a45bb6fed3b062255a31ff2e975e3bc4d7d3c74a256b4e31492faf4d714b49fd8589fb5a74c1226fbfa15d28a6e7ee14d
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
# [1.3.0-beta2] - 2019-11-22
|
11
|
+
- Fixed bug where consumers would require a key config in all cases
|
12
|
+
even though it's optional if they don't use keys.
|
13
|
+
|
10
14
|
# [1.3.0-beta1] - 2019-11-21
|
11
15
|
- Added `fetch_record` and `assign_key` methods to ActiveRecordConsumer.
|
12
16
|
|
data/Gemfile.lock
CHANGED
data/lib/deimos/base_consumer.rb
CHANGED
@@ -26,8 +26,7 @@ module Deimos
|
|
26
26
|
return nil if key.nil?
|
27
27
|
|
28
28
|
config = self.class.config
|
29
|
-
|
30
|
-
config[:key_schema].nil?
|
29
|
+
unless config[:key_configured]
|
31
30
|
raise 'No key config given - if you are not decoding keys, please use '\
|
32
31
|
'`key_config plain: true`'
|
33
32
|
end
|
@@ -23,8 +23,10 @@ module Deimos
|
|
23
23
|
# :nodoc:
|
24
24
|
def before_consume_batch(batch, metadata)
|
25
25
|
_with_error_span(batch, metadata) do
|
26
|
-
|
27
|
-
|
26
|
+
if self.class.config[:key_configured]
|
27
|
+
metadata[:keys] = batch.map do |message|
|
28
|
+
decode_key(message.key)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
batch.map do |message|
|
data/lib/deimos/consumer.rb
CHANGED
@@ -27,7 +27,7 @@ module Deimos
|
|
27
27
|
# :nodoc:
|
28
28
|
def before_consume(payload, metadata)
|
29
29
|
_with_error_span(payload, metadata) do
|
30
|
-
metadata[:key] = decode_key(metadata[:key])
|
30
|
+
metadata[:key] = decode_key(metadata[:key]) if self.class.config[:key_configured]
|
31
31
|
self.class.decoder.decode(payload) if payload.present?
|
32
32
|
end
|
33
33
|
end
|
data/lib/deimos/shared_config.rb
CHANGED
@@ -14,8 +14,11 @@ module Deimos
|
|
14
14
|
def config
|
15
15
|
return @config if @config
|
16
16
|
|
17
|
+
# default to none: true
|
17
18
|
@config = {
|
18
|
-
|
19
|
+
key_configured: false,
|
20
|
+
encode_key: false,
|
21
|
+
no_keys: true
|
19
22
|
}
|
20
23
|
klass = self.superclass
|
21
24
|
while klass.respond_to?(:config)
|
@@ -49,6 +52,7 @@ module Deimos
|
|
49
52
|
# @param plain [Boolean] if true, do not encode keys at all
|
50
53
|
# @param none [Boolean] if true, do not use keys at all
|
51
54
|
def key_config(plain: nil, field: nil, schema: nil, none: nil)
|
55
|
+
config[:key_configured] = true
|
52
56
|
config[:no_keys] = none
|
53
57
|
config[:encode_key] = !plain && !none
|
54
58
|
config[:key_field] = field&.to_s
|
data/lib/deimos/test_helpers.rb
CHANGED
@@ -138,7 +138,7 @@ module Deimos
|
|
138
138
|
alias_method(:old_consume, :consume) unless self.instance_methods.include?(:old_consume)
|
139
139
|
end
|
140
140
|
allow_any_instance_of(klass).to receive(:consume) do |instance, payload, metadata|
|
141
|
-
metadata[:key] = klass.new.decode_key(metadata[:key])
|
141
|
+
metadata[:key] = klass.new.decode_key(metadata[:key]) if klass.config[:key_configured]
|
142
142
|
instance.old_consume(payload, metadata)
|
143
143
|
end
|
144
144
|
end
|
@@ -445,6 +445,8 @@ module Deimos
|
|
445
445
|
def _key_from_consumer(consumer)
|
446
446
|
if consumer.config[:key_field] || consumer.config[:key_schema]
|
447
447
|
{ 'test' => 1 }
|
448
|
+
elsif consumer.config[:no_keys]
|
449
|
+
nil
|
448
450
|
else
|
449
451
|
1
|
450
452
|
end
|
data/lib/deimos/version.rb
CHANGED
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.3.0.pre.
|
4
|
+
version: 1.3.0.pre.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro-patches
|