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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6496a3f7011b2d9cf92bc2841bd0cdaeea6173eb8a2fb4f388c640ecc619f0d
4
- data.tar.gz: d98cd1b64bcc56397b4be95a54018beb57d294803ef3d2dec4f0ce649471f217
3
+ metadata.gz: 51d996dd84852cb13e3907865decb60c9461dbe95c7ac609520384ace3ee99e9
4
+ data.tar.gz: e337ab82edb93fcb194319a0fdc423ef174ed2140f4bced78617a82cc601bfe6
5
5
  SHA512:
6
- metadata.gz: 393b37b8dc0799317ffb037552dd3c6f140c45dfa8ed33de93fa2dcfaead6a06d4065ed2082b3026acbae7ae023494bfe09a5d1a9cb4ad08cb7620c2d00b11a5
7
- data.tar.gz: e3474dda911ee613f4048f82d76983cc6d361e5b878c87514543cd8b6105f3bf5c8ecb255a1349a59efb9944f637dabee147d7e32a9b767f1e06a90512bccc79
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.3.0.pre.beta1)
4
+ deimos-ruby (1.3.0.pre.beta2)
5
5
  avro-patches (~> 0.3)
6
6
  avro_turf (~> 0.8)
7
7
  phobos (~> 1.8.2.pre.beta2)
@@ -26,8 +26,7 @@ module Deimos
26
26
  return nil if key.nil?
27
27
 
28
28
  config = self.class.config
29
- if config[:encode_key] && config[:key_field].nil? &&
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
- metadata[:keys] = batch.map do |message|
27
- decode_key(message.key)
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|
@@ -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
@@ -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
- encode_key: true
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.3.0-beta1'
4
+ VERSION = '1.3.0-beta2'
5
5
  end
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.beta1
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-21 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro-patches