deimos-ruby 1.0.0.pre.beta22 → 1.0.0.pre.beta23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/{deimos-kafka.gemspec → deimos-ruby.gemspec} +0 -0
- data/lib/deimos/kafka_message.rb +2 -1
- data/lib/deimos/kafka_source.rb +7 -8
- data/lib/deimos/kafka_topic_info.rb +1 -1
- data/lib/deimos/utils/db_producer.rb +16 -0
- data/lib/deimos/version.rb +1 -1
- data/lib/tasks/deimos.rake +1 -1
- data/spec/backends/db_spec.rb +7 -0
- data/spec/spec_helper.rb +11 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7de207dcf4a09b8881881cfbb6af9c007c48083e091344ed3401e4a6fb944fb
|
4
|
+
data.tar.gz: 662ecac0adcd71cd8bf4bb44fa70436a88844d4ef65c76f8a2f341c964ae2cd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4508f6fb52f68a89b57cdda8bf46d1069d2359c3fafd9e12e099601ed5b474a36739958a56fa4c796584eec73ae1eac3e8e31aab121d139a9a8ee6dac7797fc2
|
7
|
+
data.tar.gz: b2b31653474653660fd0e4fac2af4843954c39b1525604fb7ff9fa39aa14f6e982627ad1da48c655077f4ad3143253ee923043229b36f6cf44d03135fb4c873a
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.0.0-beta23] - 2019-08-22
|
9
|
+
- Fix bug where nil payloads were not being saved to the DB.
|
10
|
+
- Fix DB producer rake task looking at THREADS env var instead of THREAD_COUNT.
|
11
|
+
- Debug messages in the DB producer if debug logs are turned on.
|
12
|
+
- Changed logger in specs to info.
|
13
|
+
|
8
14
|
## [1.0.0-beta22] - 2019-08-09
|
9
15
|
- Add `pending_db_messages_max_wait` metric for the DB producer.
|
10
16
|
- Fix mock metrics to allow optional option hashes.
|
data/Gemfile.lock
CHANGED
File without changes
|
data/lib/deimos/kafka_message.rb
CHANGED
@@ -5,7 +5,7 @@ module Deimos
|
|
5
5
|
class KafkaMessage < ActiveRecord::Base
|
6
6
|
self.table_name = 'kafka_messages'
|
7
7
|
|
8
|
-
validates_presence_of :
|
8
|
+
validates_presence_of :topic
|
9
9
|
|
10
10
|
# Ensure it gets turned into a string, e.g. for testing purposes. It
|
11
11
|
# should already be a string.
|
@@ -23,5 +23,6 @@ module Deimos
|
|
23
23
|
topic: self.topic
|
24
24
|
}
|
25
25
|
end
|
26
|
+
|
26
27
|
end
|
27
28
|
end
|
data/lib/deimos/kafka_source.rb
CHANGED
@@ -93,14 +93,13 @@ module Deimos
|
|
93
93
|
|
94
94
|
# This will contain an array of hashes, where each hash is the actual
|
95
95
|
# attribute hash that created the object.
|
96
|
-
ids =
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
96
|
+
ids = if results.is_a?(Array)
|
97
|
+
results[1]
|
98
|
+
elsif results.respond_to?(:ids)
|
99
|
+
results.ids
|
100
|
+
else
|
101
|
+
[]
|
102
|
+
end
|
104
103
|
if ids.blank?
|
105
104
|
# re-fill IDs based on what was just entered into the DB.
|
106
105
|
if self.connection.adapter_name.downcase =~ /sqlite/
|
@@ -62,6 +62,22 @@ module Deimos
|
|
62
62
|
messages = retrieve_messages
|
63
63
|
|
64
64
|
while messages.any?
|
65
|
+
@logger.debug do
|
66
|
+
producer = Deimos::Producer.descendants.find { |c| c.topic == topic }
|
67
|
+
decoded_messages = if producer
|
68
|
+
consumer = Class.new(Deimos::Consumer)
|
69
|
+
consumer.config.merge!(producer.config)
|
70
|
+
messages.map do |message|
|
71
|
+
{
|
72
|
+
:key => message[:key].present? ? consumer.new.decode_key(message[:key]) : nil,
|
73
|
+
:message => consumer.decoder.decode(message[:payload])
|
74
|
+
}
|
75
|
+
end
|
76
|
+
else
|
77
|
+
messages
|
78
|
+
end
|
79
|
+
"DB producer: Topic #{topic} Producing messages: #{decoded_messages}"
|
80
|
+
end
|
65
81
|
produce_messages(messages.map(&:phobos_message))
|
66
82
|
messages.first.class.where(id: messages.map(&:id)).delete_all
|
67
83
|
break if messages.size < BATCH_SIZE
|
data/lib/deimos/version.rb
CHANGED
data/lib/tasks/deimos.rake
CHANGED
@@ -20,7 +20,7 @@ namespace :deimos do
|
|
20
20
|
ENV['DEIMOS_RAKE_TASK'] = 'true'
|
21
21
|
STDOUT.sync = true
|
22
22
|
Rails.logger.info('Running deimos:db_producer rake task.')
|
23
|
-
thread_count = ENV['
|
23
|
+
thread_count = ENV['THREAD_COUNT'].to_i.zero? ? 1 : ENV['THREAD_COUNT'].to_i
|
24
24
|
Deimos.start_db_backend!(thread_count: thread_count)
|
25
25
|
end
|
26
26
|
|
data/spec/backends/db_spec.rb
CHANGED
@@ -23,6 +23,13 @@ each_db_config(Deimos::Backends::Db) do
|
|
23
23
|
'key' => 'foo3'
|
24
24
|
)
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'should add nil messages' do
|
28
|
+
described_class.publish(producer_class: MyProducer,
|
29
|
+
messages: [build_message(nil, 'my-topic', "foo1")])
|
30
|
+
expect(Deimos::KafkaMessage.count).to eq(1)
|
31
|
+
end
|
32
|
+
|
26
33
|
it 'should add to non-keyed messages' do
|
27
34
|
described_class.publish(producer_class: MyNoKeyProducer,
|
28
35
|
messages: messages)
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require 'deimos/metrics/mock'
|
|
7
7
|
require 'deimos/tracing/mock'
|
8
8
|
require 'deimos/test_helpers'
|
9
9
|
require 'active_support/testing/time_helpers'
|
10
|
+
require 'activerecord-import'
|
10
11
|
|
11
12
|
# Helpers for Executor/DbProducer
|
12
13
|
module TestRunners
|
@@ -141,17 +142,18 @@ RSpec.configure do |config|
|
|
141
142
|
Time.zone = 'EST'
|
142
143
|
ActiveRecord::Base.logger = Logger.new('/dev/null')
|
143
144
|
setup_db(DbConfigs::DB_OPTIONS.last)
|
144
|
-
Deimos.configure do |
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
145
|
+
Deimos.configure do |deimos_config|
|
146
|
+
deimos_config.phobos_config_file = File.join(File.dirname(__FILE__), 'phobos.yml')
|
147
|
+
deimos_config.schema_path = File.join(File.expand_path(__dir__), 'schemas')
|
148
|
+
deimos_config.reraise_consumer_errors = true
|
149
|
+
deimos_config.schema_registry_url = ENV['SCHEMA_REGISTRY'] || 'http://localhost:8081'
|
150
|
+
deimos_config.seed_broker = ENV['KAFKA_SEED_BROKER'] || 'localhost:9092'
|
151
|
+
deimos_config.logger = Logger.new('/dev/null')
|
152
|
+
deimos_config.logger.level = Logger::INFO
|
151
153
|
|
152
154
|
# Use Mock Metrics and Tracing for rspecs
|
153
|
-
|
154
|
-
|
155
|
+
deimos_config.metrics = Deimos::Metrics::Mock.new
|
156
|
+
deimos_config.tracer = Deimos::Tracing::Mock.new
|
155
157
|
end
|
156
158
|
end
|
157
159
|
|
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.0.0.pre.
|
4
|
+
version: 1.0.0.pre.beta23
|
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-08-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro-patches
|
@@ -315,7 +315,7 @@ files:
|
|
315
315
|
- README.md
|
316
316
|
- Rakefile
|
317
317
|
- bin/deimos
|
318
|
-
- deimos-
|
318
|
+
- deimos-ruby.gemspec
|
319
319
|
- docker-compose.yml
|
320
320
|
- docs/DATABASE_BACKEND.md
|
321
321
|
- docs/PULL_REQUEST_TEMPLATE.md
|