deimos-ruby 1.4.0.pre.beta7 → 1.5.0.pre.beta2
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/.rubocop.yml +3 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +140 -58
- data/README.md +38 -11
- data/Rakefile +2 -2
- data/deimos-ruby.gemspec +3 -2
- data/docs/CONFIGURATION.md +1 -0
- data/docs/DATABASE_BACKEND.md +1 -1
- data/lib/deimos/active_record_consumer.rb +11 -12
- data/lib/deimos/active_record_producer.rb +2 -2
- data/lib/deimos/backends/base.rb +32 -0
- data/lib/deimos/backends/db.rb +6 -1
- data/lib/deimos/backends/kafka.rb +1 -1
- data/lib/deimos/backends/kafka_async.rb +1 -1
- data/lib/deimos/backends/test.rb +20 -0
- data/lib/deimos/base_consumer.rb +7 -7
- data/lib/deimos/batch_consumer.rb +0 -1
- data/lib/deimos/config/configuration.rb +4 -0
- data/lib/deimos/consumer.rb +0 -2
- data/lib/deimos/kafka_source.rb +1 -1
- data/lib/deimos/kafka_topic_info.rb +1 -1
- data/lib/deimos/message.rb +7 -7
- data/lib/deimos/producer.rb +10 -12
- data/lib/deimos/schema_backends/avro_base.rb +108 -0
- data/lib/deimos/schema_backends/avro_local.rb +30 -0
- data/lib/deimos/{schema_coercer.rb → schema_backends/avro_schema_coercer.rb} +39 -51
- data/lib/deimos/schema_backends/avro_schema_registry.rb +34 -0
- data/lib/deimos/schema_backends/avro_validation.rb +21 -0
- data/lib/deimos/schema_backends/base.rb +130 -0
- data/lib/deimos/schema_backends/mock.rb +42 -0
- data/lib/deimos/test_helpers.rb +42 -168
- data/lib/deimos/utils/db_producer.rb +5 -0
- data/lib/deimos/version.rb +1 -1
- data/lib/deimos.rb +22 -6
- data/lib/tasks/deimos.rake +1 -1
- data/spec/active_record_consumer_spec.rb +7 -0
- data/spec/{publish_backend_spec.rb → backends/base_spec.rb} +1 -1
- data/spec/backends/db_spec.rb +5 -0
- data/spec/batch_consumer_spec.rb +0 -8
- data/spec/config/configuration_spec.rb +20 -20
- data/spec/consumer_spec.rb +0 -1
- data/spec/deimos_spec.rb +0 -4
- data/spec/kafka_source_spec.rb +8 -0
- data/spec/producer_spec.rb +23 -37
- data/spec/rake_spec.rb +19 -0
- data/spec/schema_backends/avro_base_shared.rb +174 -0
- data/spec/schema_backends/avro_local_spec.rb +32 -0
- data/spec/schema_backends/avro_schema_registry_spec.rb +32 -0
- data/spec/schema_backends/avro_validation_spec.rb +24 -0
- data/spec/schema_backends/base_spec.rb +29 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/utils/db_producer_spec.rb +10 -0
- metadata +56 -33
- data/lib/deimos/avro_data_coder.rb +0 -89
- data/lib/deimos/avro_data_decoder.rb +0 -36
- data/lib/deimos/avro_data_encoder.rb +0 -51
- data/lib/deimos/monkey_patches/schema_store.rb +0 -19
- data/lib/deimos/publish_backend.rb +0 -30
- data/spec/avro_data_decoder_spec.rb +0 -18
- data/spec/avro_data_encoder_spec.rb +0 -37
- data/spec/updateable_schema_store_spec.rb +0 -36
data/spec/producer_spec.rb
CHANGED
@@ -62,14 +62,15 @@ module ProducerTest
|
|
62
62
|
subscriber = Deimos.subscribe('produce') do |event|
|
63
63
|
expect(event.payload[:payloads]).to eq([{ 'invalid' => 'key' }])
|
64
64
|
end
|
65
|
+
expect(MyProducer.encoder).to receive(:validate).and_raise('OH NOES')
|
65
66
|
expect { MyProducer.publish('invalid' => 'key', :payload_key => 'key') }.
|
66
|
-
to raise_error(
|
67
|
+
to raise_error('OH NOES')
|
67
68
|
Deimos.unsubscribe(subscriber)
|
68
69
|
end
|
69
70
|
|
70
71
|
it 'should produce a message' do
|
71
72
|
expect(described_class).to receive(:produce_batch).once.with(
|
72
|
-
Deimos::Backends::
|
73
|
+
Deimos::Backends::Test,
|
73
74
|
[
|
74
75
|
Deimos::Message.new({ 'test_id' => 'foo', 'some_int' => 123 },
|
75
76
|
MyProducer,
|
@@ -82,7 +83,7 @@ module ProducerTest
|
|
82
83
|
partition_key: 'bar',
|
83
84
|
key: 'bar')
|
84
85
|
]
|
85
|
-
)
|
86
|
+
).and_call_original
|
86
87
|
|
87
88
|
MyProducer.publish_list(
|
88
89
|
[{ 'test_id' => 'foo', 'some_int' => 123 },
|
@@ -198,25 +199,16 @@ module ProducerTest
|
|
198
199
|
end
|
199
200
|
|
200
201
|
it 'should encode the key' do
|
201
|
-
encoder
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
expect(encoder).to receive(:encode_key).with('test_id', 'bar', 'my-topic-key')
|
212
|
-
expect(encoder).to receive(:encode).with({
|
213
|
-
'test_id' => 'foo',
|
214
|
-
'some_int' => 123
|
215
|
-
}, { topic: 'my-topic-value' })
|
216
|
-
expect(encoder).to receive(:encode).with({
|
217
|
-
'test_id' => 'bar',
|
218
|
-
'some_int' => 124
|
219
|
-
}, { topic: 'my-topic-value' })
|
202
|
+
expect(MyProducer.encoder).to receive(:encode_key).with('test_id', 'foo', topic: 'my-topic-key')
|
203
|
+
expect(MyProducer.encoder).to receive(:encode_key).with('test_id', 'bar', topic: 'my-topic-key')
|
204
|
+
expect(MyProducer.encoder).to receive(:encode).with({
|
205
|
+
'test_id' => 'foo',
|
206
|
+
'some_int' => 123
|
207
|
+
}, { topic: 'my-topic-value' })
|
208
|
+
expect(MyProducer.encoder).to receive(:encode).with({
|
209
|
+
'test_id' => 'bar',
|
210
|
+
'some_int' => 124
|
211
|
+
}, { topic: 'my-topic-value' })
|
220
212
|
|
221
213
|
MyProducer.publish_list(
|
222
214
|
[{ 'test_id' => 'foo', 'some_int' => 123 },
|
@@ -225,13 +217,7 @@ module ProducerTest
|
|
225
217
|
end
|
226
218
|
|
227
219
|
it 'should not encode with plaintext key' do
|
228
|
-
key_encoder
|
229
|
-
schema: 'MySchema',
|
230
|
-
namespace: 'com.my-namespace'
|
231
|
-
)
|
232
|
-
allow(key_encoder).to receive(:encode)
|
233
|
-
allow(MyNonEncodedProducer).to receive(:encoder).and_return(key_encoder)
|
234
|
-
expect(key_encoder).not_to receive(:encode_key)
|
220
|
+
expect(MyNonEncodedProducer.key_encoder).not_to receive(:encode_key)
|
235
221
|
|
236
222
|
MyNonEncodedProducer.publish_list(
|
237
223
|
[{ 'test_id' => 'foo', 'some_int' => 123, :payload_key => 'foo_key' },
|
@@ -240,14 +226,10 @@ module ProducerTest
|
|
240
226
|
end
|
241
227
|
|
242
228
|
it 'should encode with a schema' do
|
243
|
-
|
244
|
-
|
245
|
-
expect(MySchemaProducer).to receive(:
|
246
|
-
|
247
|
-
expect(encoder).to receive(:encode).with({ 'test_id' => 'foo_key' },
|
248
|
-
{ topic: 'my-topic2-key' })
|
249
|
-
expect(encoder).to receive(:encode).with({ 'test_id' => 'bar_key' },
|
250
|
-
{ topic: 'my-topic2-key' })
|
229
|
+
expect(MySchemaProducer.key_encoder).to receive(:encode).with({ 'test_id' => 'foo_key' },
|
230
|
+
{ topic: 'my-topic2-key' })
|
231
|
+
expect(MySchemaProducer.key_encoder).to receive(:encode).with({ 'test_id' => 'bar_key' },
|
232
|
+
{ topic: 'my-topic2-key' })
|
251
233
|
|
252
234
|
MySchemaProducer.publish_list(
|
253
235
|
[{ 'test_id' => 'foo', 'some_int' => 123,
|
@@ -364,6 +346,10 @@ module ProducerTest
|
|
364
346
|
end
|
365
347
|
|
366
348
|
describe '#determine_backend_class' do
|
349
|
+
before(:each) do
|
350
|
+
Deimos.configure { |c| c.producers.backend = :kafka_async }
|
351
|
+
end
|
352
|
+
|
367
353
|
it 'should return kafka_async if sync is false' do
|
368
354
|
expect(described_class.determine_backend_class(false, false)).
|
369
355
|
to eq(Deimos::Backends::KafkaAsync)
|
data/spec/rake_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rails'
|
5
|
+
Rails.logger = Logger.new(STDOUT)
|
6
|
+
load("#{__dir__}/../lib/tasks/deimos.rake")
|
7
|
+
|
8
|
+
if Rake.application.lookup(:environment).nil?
|
9
|
+
Rake::Task.define_task(:environment)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Rakefile' do # rubocop:disable RSpec/DescribeClass
|
13
|
+
it 'should start listeners' do
|
14
|
+
runner = instance_double(Phobos::CLI::Runner)
|
15
|
+
expect(Phobos::CLI::Runner).to receive(:new).and_return(runner)
|
16
|
+
expect(runner).to receive(:run!)
|
17
|
+
Rake::Task['deimos:start'].invoke
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'deimos/schema_backends/avro_base'
|
4
|
+
|
5
|
+
RSpec.shared_examples_for('an Avro backend') do
|
6
|
+
let(:backend) { described_class.new(schema: 'MySchema', namespace: 'com.my-namespace') }
|
7
|
+
|
8
|
+
let(:full_schema) do
|
9
|
+
{
|
10
|
+
'type' => 'record',
|
11
|
+
'name' => 'schema1',
|
12
|
+
'namespace' => 'com.my-namespace',
|
13
|
+
'fields' => [
|
14
|
+
{
|
15
|
+
'name' => 'int-field',
|
16
|
+
'type' => 'int'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
'name' => 'long-field',
|
20
|
+
'type' => 'long'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
'name' => 'float-field',
|
24
|
+
'type' => 'float'
|
25
|
+
},
|
26
|
+
{
|
27
|
+
'name' => 'double-field',
|
28
|
+
'type' => 'double'
|
29
|
+
},
|
30
|
+
{
|
31
|
+
'name' => 'string-field',
|
32
|
+
'type' => 'string'
|
33
|
+
},
|
34
|
+
{
|
35
|
+
'name' => 'boolean-field',
|
36
|
+
'type' => 'boolean'
|
37
|
+
},
|
38
|
+
{
|
39
|
+
'name' => 'union-field',
|
40
|
+
'type' => %w(null string)
|
41
|
+
},
|
42
|
+
{
|
43
|
+
'name' => 'union-int-field',
|
44
|
+
'type' => %w(null int)
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
specify('#encode_key') do
|
51
|
+
expect(backend).to receive(:encode).
|
52
|
+
with({ 'test_id' => 1 }, { schema: 'MySchema_key', topic: 'topic' }).and_return('itsme')
|
53
|
+
expect(backend.encode_key('test_id', 1, topic: 'topic')).to eq('itsme')
|
54
|
+
expect(backend.schema_store.find('MySchema_key', 'com.my-namespace').to_avro).
|
55
|
+
to eq(
|
56
|
+
'doc' => 'Key for com.my-namespace.MySchema - autogenerated by Deimos',
|
57
|
+
'fields' => [
|
58
|
+
{ 'name' => 'test_id', 'type' => 'string' }
|
59
|
+
],
|
60
|
+
'name' => 'MySchema_key',
|
61
|
+
'namespace' => 'com.my-namespace',
|
62
|
+
'type' => 'record'
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
specify('#decode_key') do
|
67
|
+
expect(backend).to receive(:decode).
|
68
|
+
with('payload', schema: 'MySchema_key').
|
69
|
+
and_return('test_id' => 1)
|
70
|
+
expect(backend.decode_key('payload', 'test_id')).to eq(1)
|
71
|
+
end
|
72
|
+
|
73
|
+
describe('#validate') do
|
74
|
+
it 'should pass valid schemas' do
|
75
|
+
expect {
|
76
|
+
backend.validate({ 'test_id' => 'hi', 'some_int' => 4 }, { schema: 'MySchema' })
|
77
|
+
}.not_to raise_error
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should fail invalid schemas' do
|
81
|
+
expect {
|
82
|
+
backend.validate({ 'test_id2' => 'hi', 'some_int' => 4 }, { schema: 'MySchema' })
|
83
|
+
}.to raise_error(Avro::SchemaValidator::ValidationError)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#coerce' do
|
89
|
+
let(:payload) do
|
90
|
+
{
|
91
|
+
'int-field' => 1,
|
92
|
+
'long-field' => 11_111_111_111_111_111_111,
|
93
|
+
'float-field' => 1.0,
|
94
|
+
'double-field' => 2.0,
|
95
|
+
'string-field' => 'hi mom',
|
96
|
+
'boolean-field' => true,
|
97
|
+
'union-field' => nil,
|
98
|
+
'union-int-field' => nil
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
before(:each) do
|
103
|
+
backend.schema_store.add_schema(full_schema)
|
104
|
+
backend.schema = 'schema1'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should leave numbers as is' do
|
108
|
+
result = backend.coerce(payload)
|
109
|
+
expect(result['int-field']).to eq(1)
|
110
|
+
expect(result['long-field']).to eq(11_111_111_111_111_111_111)
|
111
|
+
expect(result['float-field']).to eq(1.0)
|
112
|
+
expect(result['double-field']).to eq(2.0)
|
113
|
+
expect(result['boolean-field']).to eq(true)
|
114
|
+
expect(result['union-field']).to eq(nil)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should coerce strings to numbers' do
|
118
|
+
result = backend.coerce(payload.merge(
|
119
|
+
'int-field' => '1',
|
120
|
+
'long-field' => '123',
|
121
|
+
'float-field' => '1.1',
|
122
|
+
'double-field' => '2.1'
|
123
|
+
))
|
124
|
+
expect(result['int-field']).to eq(1)
|
125
|
+
expect(result['long-field']).to eq(123)
|
126
|
+
expect(result['float-field']).to eq(1.1)
|
127
|
+
expect(result['double-field']).to eq(2.1)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should coerce Time to number' do
|
131
|
+
result = backend.coerce(payload.merge('int-field' => Time.find_zone('UTC').local(2019, 5, 5)))
|
132
|
+
expect(result['int-field']).to eq(1_557_014_400)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should coerce symbols to string' do
|
136
|
+
result = backend.coerce(payload.merge('string-field' => :itsme))
|
137
|
+
expect(result['string-field']).to eq('itsme')
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should convert string-like things to string' do
|
141
|
+
stringy = Class.new do
|
142
|
+
# :nodoc:
|
143
|
+
def initialize(str)
|
144
|
+
@st = str
|
145
|
+
end
|
146
|
+
|
147
|
+
# :nodoc:
|
148
|
+
def to_s
|
149
|
+
@st
|
150
|
+
end
|
151
|
+
|
152
|
+
# :nodoc:
|
153
|
+
def to_str
|
154
|
+
@st
|
155
|
+
end
|
156
|
+
end
|
157
|
+
stub_const('Stringy', stringy)
|
158
|
+
result = backend.coerce(payload.merge('string-field' => Stringy.new('itsyou')))
|
159
|
+
expect(result['string-field']).to eq('itsyou')
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should convert null to false' do
|
163
|
+
result = backend.coerce(payload.merge('boolean-field' => nil))
|
164
|
+
expect(result['boolean-field']).to eq(false)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should convert unions' do
|
168
|
+
result = backend.coerce(payload.merge('union-field' => :itsme))
|
169
|
+
expect(result['union-field']).to eq('itsme')
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'avro_base_shared'
|
4
|
+
require 'deimos/schema_backends/avro_local'
|
5
|
+
|
6
|
+
RSpec.describe Deimos::SchemaBackends::AvroLocal do
|
7
|
+
let(:payload) do
|
8
|
+
{
|
9
|
+
'test_id' => 'some string',
|
10
|
+
'some_int' => 3
|
11
|
+
}
|
12
|
+
end
|
13
|
+
let(:backend) { described_class.new(schema: 'MySchema', namespace: 'com.my-namespace') }
|
14
|
+
|
15
|
+
it_should_behave_like 'an Avro backend'
|
16
|
+
|
17
|
+
it 'should encode and decode correctly' do
|
18
|
+
avro_turf = instance_double(AvroTurf)
|
19
|
+
expect(avro_turf).to receive(:encode).
|
20
|
+
with(payload, schema_name: 'MySchema', namespace: 'com.my-namespace').
|
21
|
+
and_return('encoded-payload')
|
22
|
+
expect(avro_turf).to receive(:decode).
|
23
|
+
with('encoded-payload', schema_name: 'MySchema', namespace: 'com.my-namespace').
|
24
|
+
and_return(payload)
|
25
|
+
allow(backend).to receive(:avro_turf).and_return(avro_turf)
|
26
|
+
results = backend.encode(payload)
|
27
|
+
expect(results).to eq('encoded-payload')
|
28
|
+
results = backend.decode(results)
|
29
|
+
expect(results).to eq(payload)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'avro_base_shared'
|
4
|
+
require 'deimos/schema_backends/avro_schema_registry'
|
5
|
+
|
6
|
+
RSpec.describe Deimos::SchemaBackends::AvroSchemaRegistry do
|
7
|
+
let(:payload) do
|
8
|
+
{
|
9
|
+
'test_id' => 'some string',
|
10
|
+
'some_int' => 3
|
11
|
+
}
|
12
|
+
end
|
13
|
+
let(:backend) { described_class.new(schema: 'MySchema', namespace: 'com.my-namespace') }
|
14
|
+
|
15
|
+
it_should_behave_like 'an Avro backend'
|
16
|
+
|
17
|
+
it 'should encode and decode correctly' do
|
18
|
+
avro_turf = instance_double(AvroTurf::Messaging)
|
19
|
+
expect(avro_turf).to receive(:encode).
|
20
|
+
with(payload, schema_name: 'MySchema', subject: 'topic').
|
21
|
+
and_return('encoded-payload')
|
22
|
+
expect(avro_turf).to receive(:decode).
|
23
|
+
with('encoded-payload', schema_name: 'MySchema').
|
24
|
+
and_return(payload)
|
25
|
+
allow(backend).to receive(:avro_turf_messaging).and_return(avro_turf)
|
26
|
+
results = backend.encode(payload, topic: 'topic')
|
27
|
+
expect(results).to eq('encoded-payload')
|
28
|
+
results = backend.decode(results)
|
29
|
+
expect(results).to eq(payload)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'avro_base_shared'
|
4
|
+
require 'deimos/schema_backends/avro_validation'
|
5
|
+
|
6
|
+
RSpec.describe Deimos::SchemaBackends::AvroValidation do
|
7
|
+
let(:payload) do
|
8
|
+
{
|
9
|
+
'test_id' => 'some string',
|
10
|
+
'some_int' => 3
|
11
|
+
}
|
12
|
+
end
|
13
|
+
let(:backend) { described_class.new(schema: 'MySchema', namespace: 'com.my-namespace') }
|
14
|
+
|
15
|
+
it_should_behave_like 'an Avro backend'
|
16
|
+
|
17
|
+
it 'should encode and decode correctly' do
|
18
|
+
results = backend.encode(payload)
|
19
|
+
expect(results).to eq(payload)
|
20
|
+
results = backend.decode(results)
|
21
|
+
expect(results).to eq(payload)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Deimos::SchemaBackends::Base do
|
4
|
+
let(:backend) { described_class.new(schema: 'schema', namespace: 'namespace') }
|
5
|
+
let(:payload) { { foo: 1 } }
|
6
|
+
|
7
|
+
it 'should validate on encode' do
|
8
|
+
expect(backend).to receive(:validate).with(payload, schema: 'schema')
|
9
|
+
expect(backend).to receive(:encode_payload).with(payload, schema: 'schema', topic: 'topic')
|
10
|
+
backend.encode(payload, topic: 'topic')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should validate and encode a passed schema' do
|
14
|
+
expect(backend).to receive(:validate).with(payload, schema: 'schema2')
|
15
|
+
expect(backend).to receive(:encode_payload).with(payload, schema: 'schema2', topic: 'topic')
|
16
|
+
backend.encode(payload, schema: 'schema2', topic: 'topic')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should decode a schema' do
|
20
|
+
expect(backend).to receive(:decode_payload).with(payload, schema: 'schema')
|
21
|
+
backend.decode(payload)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should decode a passed schema' do
|
25
|
+
expect(backend).to receive(:decode_payload).with(payload, schema: 'schema2')
|
26
|
+
backend.decode(payload, schema: 'schema2')
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -146,6 +146,11 @@ RSpec.configure do |config|
|
|
146
146
|
setup_db(DbConfigs::DB_OPTIONS.last)
|
147
147
|
end
|
148
148
|
|
149
|
+
config.mock_with(:rspec) do |mocks|
|
150
|
+
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
151
|
+
mocks.verify_partial_doubles = true
|
152
|
+
end
|
153
|
+
|
149
154
|
config.before(:each) do |ex|
|
150
155
|
Deimos.config.reset!
|
151
156
|
Deimos.configure do |deimos_config|
|
@@ -156,6 +161,7 @@ RSpec.configure do |config|
|
|
156
161
|
deimos_config.kafka.seed_brokers = ENV['KAFKA_SEED_BROKER'] || 'localhost:9092'
|
157
162
|
deimos_config.logger = Logger.new('/dev/null')
|
158
163
|
deimos_config.logger.level = Logger::INFO
|
164
|
+
deimos_config.schema.backend = :avro_validation
|
159
165
|
end
|
160
166
|
stub_producers_and_consumers! unless ex.metadata[:integration]
|
161
167
|
end
|
@@ -192,6 +192,11 @@ each_db_config(Deimos::Utils::DbProducer) do
|
|
192
192
|
topic: 'my-topic'
|
193
193
|
}
|
194
194
|
])
|
195
|
+
expect(Deimos.config.metrics).to receive(:increment).ordered.with(
|
196
|
+
'db_producer.process',
|
197
|
+
tags: %w(topic:my-topic),
|
198
|
+
by: 2
|
199
|
+
)
|
195
200
|
expect(producer).to receive(:retrieve_messages).ordered.
|
196
201
|
and_return(messages[2..3])
|
197
202
|
expect(producer).to receive(:produce_messages).ordered.with([
|
@@ -208,6 +213,11 @@ each_db_config(Deimos::Utils::DbProducer) do
|
|
208
213
|
topic: 'my-topic'
|
209
214
|
}
|
210
215
|
])
|
216
|
+
expect(Deimos.config.metrics).to receive(:increment).ordered.with(
|
217
|
+
'db_producer.process',
|
218
|
+
tags: %w(topic:my-topic),
|
219
|
+
by: 2
|
220
|
+
)
|
211
221
|
expect(producer).to receive(:retrieve_messages).ordered.
|
212
222
|
and_return([])
|
213
223
|
expect(Deimos::KafkaTopicInfo).to receive(:heartbeat).
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deimos-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.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:
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: avro-patches
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.3'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.3'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: avro_turf
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
19
|
+
version: '0.11'
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
26
|
+
version: '0.11'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: phobos
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +80,20 @@ dependencies:
|
|
94
80
|
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: avro
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.9'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.9'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '1.1'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rails
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '5.2'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '5.2'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: rake
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -323,12 +337,11 @@ files:
|
|
323
337
|
- lib/deimos.rb
|
324
338
|
- lib/deimos/active_record_consumer.rb
|
325
339
|
- lib/deimos/active_record_producer.rb
|
326
|
-
- lib/deimos/
|
327
|
-
- lib/deimos/avro_data_decoder.rb
|
328
|
-
- lib/deimos/avro_data_encoder.rb
|
340
|
+
- lib/deimos/backends/base.rb
|
329
341
|
- lib/deimos/backends/db.rb
|
330
342
|
- lib/deimos/backends/kafka.rb
|
331
343
|
- lib/deimos/backends/kafka_async.rb
|
344
|
+
- lib/deimos/backends/test.rb
|
332
345
|
- lib/deimos/base_consumer.rb
|
333
346
|
- lib/deimos/batch_consumer.rb
|
334
347
|
- lib/deimos/config/configurable.rb
|
@@ -346,11 +359,15 @@ files:
|
|
346
359
|
- lib/deimos/monkey_patches/phobos_cli.rb
|
347
360
|
- lib/deimos/monkey_patches/phobos_producer.rb
|
348
361
|
- lib/deimos/monkey_patches/ruby_kafka_heartbeat.rb
|
349
|
-
- lib/deimos/monkey_patches/schema_store.rb
|
350
362
|
- lib/deimos/producer.rb
|
351
|
-
- lib/deimos/publish_backend.rb
|
352
363
|
- lib/deimos/railtie.rb
|
353
|
-
- lib/deimos/
|
364
|
+
- lib/deimos/schema_backends/avro_base.rb
|
365
|
+
- lib/deimos/schema_backends/avro_local.rb
|
366
|
+
- lib/deimos/schema_backends/avro_schema_coercer.rb
|
367
|
+
- lib/deimos/schema_backends/avro_schema_registry.rb
|
368
|
+
- lib/deimos/schema_backends/avro_validation.rb
|
369
|
+
- lib/deimos/schema_backends/base.rb
|
370
|
+
- lib/deimos/schema_backends/mock.rb
|
354
371
|
- lib/deimos/shared_config.rb
|
355
372
|
- lib/deimos/test_helpers.rb
|
356
373
|
- lib/deimos/tracing/datadog.rb
|
@@ -369,8 +386,7 @@ files:
|
|
369
386
|
- lib/tasks/deimos.rake
|
370
387
|
- spec/active_record_consumer_spec.rb
|
371
388
|
- spec/active_record_producer_spec.rb
|
372
|
-
- spec/
|
373
|
-
- spec/avro_data_encoder_spec.rb
|
389
|
+
- spec/backends/base_spec.rb
|
374
390
|
- spec/backends/db_spec.rb
|
375
391
|
- spec/backends/kafka_async_spec.rb
|
376
392
|
- spec/backends/kafka_spec.rb
|
@@ -386,7 +402,12 @@ files:
|
|
386
402
|
- spec/phobos.bad_db.yml
|
387
403
|
- spec/phobos.yml
|
388
404
|
- spec/producer_spec.rb
|
389
|
-
- spec/
|
405
|
+
- spec/rake_spec.rb
|
406
|
+
- spec/schema_backends/avro_base_shared.rb
|
407
|
+
- spec/schema_backends/avro_local_spec.rb
|
408
|
+
- spec/schema_backends/avro_schema_registry_spec.rb
|
409
|
+
- spec/schema_backends/avro_validation_spec.rb
|
410
|
+
- spec/schema_backends/base_spec.rb
|
390
411
|
- spec/schemas/com/my-namespace/MySchema-key.avsc
|
391
412
|
- spec/schemas/com/my-namespace/MySchema.avsc
|
392
413
|
- spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
|
@@ -396,7 +417,6 @@ files:
|
|
396
417
|
- spec/schemas/com/my-namespace/Widget.avsc
|
397
418
|
- spec/schemas/com/my-namespace/WidgetTheSecond.avsc
|
398
419
|
- spec/spec_helper.rb
|
399
|
-
- spec/updateable_schema_store_spec.rb
|
400
420
|
- spec/utils/db_producer_spec.rb
|
401
421
|
- spec/utils/executor_spec.rb
|
402
422
|
- spec/utils/lag_reporter_spec.rb
|
@@ -425,15 +445,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
425
445
|
- !ruby/object:Gem::Version
|
426
446
|
version: 1.3.1
|
427
447
|
requirements: []
|
428
|
-
rubygems_version: 3.
|
448
|
+
rubygems_version: 3.1.2
|
429
449
|
signing_key:
|
430
450
|
specification_version: 4
|
431
451
|
summary: Kafka libraries for Ruby.
|
432
452
|
test_files:
|
433
453
|
- spec/active_record_consumer_spec.rb
|
434
454
|
- spec/active_record_producer_spec.rb
|
435
|
-
- spec/
|
436
|
-
- spec/avro_data_encoder_spec.rb
|
455
|
+
- spec/backends/base_spec.rb
|
437
456
|
- spec/backends/db_spec.rb
|
438
457
|
- spec/backends/kafka_async_spec.rb
|
439
458
|
- spec/backends/kafka_spec.rb
|
@@ -449,7 +468,12 @@ test_files:
|
|
449
468
|
- spec/phobos.bad_db.yml
|
450
469
|
- spec/phobos.yml
|
451
470
|
- spec/producer_spec.rb
|
452
|
-
- spec/
|
471
|
+
- spec/rake_spec.rb
|
472
|
+
- spec/schema_backends/avro_base_shared.rb
|
473
|
+
- spec/schema_backends/avro_local_spec.rb
|
474
|
+
- spec/schema_backends/avro_schema_registry_spec.rb
|
475
|
+
- spec/schema_backends/avro_validation_spec.rb
|
476
|
+
- spec/schema_backends/base_spec.rb
|
453
477
|
- spec/schemas/com/my-namespace/MySchema-key.avsc
|
454
478
|
- spec/schemas/com/my-namespace/MySchema.avsc
|
455
479
|
- spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
|
@@ -459,7 +483,6 @@ test_files:
|
|
459
483
|
- spec/schemas/com/my-namespace/Widget.avsc
|
460
484
|
- spec/schemas/com/my-namespace/WidgetTheSecond.avsc
|
461
485
|
- spec/spec_helper.rb
|
462
|
-
- spec/updateable_schema_store_spec.rb
|
463
486
|
- spec/utils/db_producer_spec.rb
|
464
487
|
- spec/utils/executor_spec.rb
|
465
488
|
- spec/utils/lag_reporter_spec.rb
|