deimos-ruby 1.8.5 → 1.9.2

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: fb39b256f4c8fe4df29db4eb3605b3131d32910b09117d6bed254a06a887d615
4
- data.tar.gz: 0d326e5d41ccc69b1da7670ee7a8b57655aae6f434b11365dd33b3297f75f488
3
+ metadata.gz: 32eb1834570b6a1ea7d61274bf35be7365f16f1bb818c5c1148459bbc5a0b87a
4
+ data.tar.gz: eb1ea3e922b947c631f05c0e1a41ce65a3c7a366b42e9b5884de499fff14817b
5
5
  SHA512:
6
- metadata.gz: 3e1f504e2b62f5e6a530ab79ced9e6116954131efe65885fc86fe3148d2fa019f8c6ddc803b723919ba3240dbbbddfa6747d8e8cb4a3dd36bfb534c87fb22870
7
- data.tar.gz: efbaa2ca661b9dffbd815efea85da62af3486a4a4770f9b3601a4f1722dd1a995ea61aa7f3e79eb1339b7ecf79ad8532a2a04c6e1e52371987ac757d63a5cb3a
6
+ metadata.gz: f9d27f061f4ddcc3db165c08aaa09c02d80471cfa8b815cb2fc91909a6992615a49697870f517e70fae958d8bd8fa022b2369310f839c5bcba60a415c9a95750
7
+ data.tar.gz: '0578c18592f11f646ae89b44a12c712ef86403b282ce9624c7e3127f5d54ba9f20faa634fd463e03b1287dd84d4bfddbecc2ee20e503a76b2f83a700c491b72e'
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+
11
+ ## 1.9.2 - 2021-01-29
12
+
13
+ - ### Fixes :wrench:
14
+
15
+ - Fix for `uninitialized constant ActiveSupport::Autoload` in certain circumstances
16
+ - Removed unnecessary monkey patch which was crashing on newer versions of ruby-kafka
17
+
18
+ ## 1.9.0 - 2021-01-28
19
+
20
+ - ### Roadmap :car:
21
+
22
+ - Bumped the version of ruby-kafka to latest
23
+
24
+ - ### Fixes :wrench:
25
+
26
+ - Prevents DB Poller from reconnecting to DB if there is an open transaction
27
+ - Replaces `before` by `prepend_before` for more consistent test setups.
28
+ - Adds validation in the `kafka_producers` method (fixes [#90](https://github.com/flipp-oss/deimos/issues/90))
29
+
30
+ ## 1.8.7 - 2021-01-14
31
+
32
+ - ### Roadmap :car:
33
+ - Update Phobos version to allow version 1.9 or 2.x.
34
+
35
+ ## 1.8.6 - 2021-01-14
36
+
37
+ - ### Fixes :wrench:
38
+ - Fix for configuration bug with Ruby 3.0 (** instead of passing hash)
39
+
10
40
  ## 1.8.5 - 2021-01-13
11
41
 
12
42
  - ### Fixes :wrench:
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.8.5)
4
+ deimos-ruby (1.9.1)
5
5
  avro_turf (~> 0.11)
6
- phobos (~> 1.9)
7
- ruby-kafka (~> 0.7)
6
+ phobos (>= 1.9, < 3.0)
7
+ ruby-kafka (< 2)
8
8
  sigurd (= 0.0.1)
9
9
 
10
10
  GEM
@@ -71,7 +71,7 @@ GEM
71
71
  minitest (>= 5.1)
72
72
  tzinfo (~> 2.0)
73
73
  zeitwerk (~> 2.3)
74
- ast (2.4.1)
74
+ ast (2.4.2)
75
75
  avro (1.9.2)
76
76
  multi_json
77
77
  avro_turf (0.11.0)
@@ -79,21 +79,21 @@ GEM
79
79
  excon (~> 0.45)
80
80
  builder (3.2.4)
81
81
  coderay (1.1.3)
82
- concurrent-ruby (1.1.6)
83
- concurrent-ruby-ext (1.1.6)
84
- concurrent-ruby (= 1.1.6)
82
+ concurrent-ruby (1.1.8)
83
+ concurrent-ruby-ext (1.1.8)
84
+ concurrent-ruby (= 1.1.8)
85
85
  crass (1.0.6)
86
86
  database_cleaner (1.8.5)
87
- ddtrace (0.37.0)
87
+ ddtrace (0.45.0)
88
88
  msgpack
89
89
  diff-lcs (1.4.4)
90
90
  digest-crc (0.6.3)
91
91
  rake (>= 12.0.0, < 14.0.0)
92
- dogstatsd-ruby (4.8.1)
92
+ dogstatsd-ruby (4.8.2)
93
93
  erubi (1.10.0)
94
94
  excon (0.78.1)
95
95
  exponential-backoff (0.0.4)
96
- ffi (1.13.1)
96
+ ffi (1.14.2)
97
97
  formatador (0.2.5)
98
98
  globalid (0.4.2)
99
99
  activesupport (>= 4.2.0)
@@ -111,22 +111,22 @@ GEM
111
111
  guard (~> 2.1)
112
112
  guard-compat (~> 1.1)
113
113
  rspec (>= 2.99.0, < 4.0)
114
- guard-rubocop (1.3.0)
114
+ guard-rubocop (1.4.0)
115
115
  guard (~> 2.0)
116
- rubocop (~> 0.20)
116
+ rubocop (< 2.0)
117
117
  i18n (1.8.7)
118
118
  concurrent-ruby (~> 1.0)
119
- listen (3.2.1)
119
+ listen (3.4.1)
120
120
  rb-fsevent (~> 0.10, >= 0.10.3)
121
121
  rb-inotify (~> 0.9, >= 0.9.10)
122
122
  little-plugger (1.1.4)
123
123
  logging (2.3.0)
124
124
  little-plugger (~> 1.1)
125
125
  multi_json (~> 1.14)
126
- loofah (2.8.0)
126
+ loofah (2.9.0)
127
127
  crass (~> 1.0.2)
128
128
  nokogiri (>= 1.5.9)
129
- lumberjack (1.2.6)
129
+ lumberjack (1.2.8)
130
130
  mail (2.7.1)
131
131
  mini_mime (>= 0.1.1)
132
132
  marcel (0.3.3)
@@ -136,7 +136,7 @@ GEM
136
136
  mini_mime (1.0.2)
137
137
  mini_portile2 (2.5.0)
138
138
  minitest (5.14.3)
139
- msgpack (1.3.3)
139
+ msgpack (1.4.1)
140
140
  multi_json (1.15.0)
141
141
  mysql2 (0.5.3)
142
142
  nenv (0.3.0)
@@ -147,11 +147,11 @@ GEM
147
147
  notiffany (0.1.3)
148
148
  nenv (~> 0.1)
149
149
  shellany (~> 0.0)
150
- parallel (1.19.2)
151
- parser (2.7.1.4)
150
+ parallel (1.20.1)
151
+ parser (3.0.0.0)
152
152
  ast (~> 2.4.1)
153
153
  pg (1.2.3)
154
- phobos (1.9.0)
154
+ phobos (2.0.2)
155
155
  activesupport (>= 3.0.0)
156
156
  concurrent-ruby (>= 1.0.2)
157
157
  concurrent-ruby-ext (>= 1.0.2)
@@ -197,29 +197,29 @@ GEM
197
197
  rb-fsevent (0.10.4)
198
198
  rb-inotify (0.10.1)
199
199
  ffi (~> 1.0)
200
- regexp_parser (1.7.1)
200
+ regexp_parser (2.0.3)
201
201
  rexml (3.2.4)
202
- rspec (3.9.0)
203
- rspec-core (~> 3.9.0)
204
- rspec-expectations (~> 3.9.0)
205
- rspec-mocks (~> 3.9.0)
206
- rspec-core (3.9.2)
207
- rspec-support (~> 3.9.3)
208
- rspec-expectations (3.9.2)
202
+ rspec (3.10.0)
203
+ rspec-core (~> 3.10.0)
204
+ rspec-expectations (~> 3.10.0)
205
+ rspec-mocks (~> 3.10.0)
206
+ rspec-core (3.10.1)
207
+ rspec-support (~> 3.10.0)
208
+ rspec-expectations (3.10.1)
209
209
  diff-lcs (>= 1.2.0, < 2.0)
210
- rspec-support (~> 3.9.0)
211
- rspec-mocks (3.9.1)
210
+ rspec-support (~> 3.10.0)
211
+ rspec-mocks (3.10.1)
212
212
  diff-lcs (>= 1.2.0, < 2.0)
213
- rspec-support (~> 3.9.0)
214
- rspec-rails (4.0.1)
213
+ rspec-support (~> 3.10.0)
214
+ rspec-rails (4.0.2)
215
215
  actionpack (>= 4.2)
216
216
  activesupport (>= 4.2)
217
217
  railties (>= 4.2)
218
- rspec-core (~> 3.9)
219
- rspec-expectations (~> 3.9)
220
- rspec-mocks (~> 3.9)
221
- rspec-support (~> 3.9)
222
- rspec-support (3.9.3)
218
+ rspec-core (~> 3.10)
219
+ rspec-expectations (~> 3.10)
220
+ rspec-mocks (~> 3.10)
221
+ rspec-support (~> 3.10)
222
+ rspec-support (3.10.1)
223
223
  rspec_junit_formatter (0.4.1)
224
224
  rspec-core (>= 2, < 4, != 2.12.0)
225
225
  rubocop (0.88.0)
@@ -231,13 +231,13 @@ GEM
231
231
  rubocop-ast (>= 0.1.0, < 1.0)
232
232
  ruby-progressbar (~> 1.7)
233
233
  unicode-display_width (>= 1.4.0, < 2.0)
234
- rubocop-ast (0.2.0)
235
- parser (>= 2.7.0.1)
234
+ rubocop-ast (0.8.0)
235
+ parser (>= 2.7.1.5)
236
236
  rubocop-rspec (1.42.0)
237
237
  rubocop (>= 0.87.0)
238
- ruby-kafka (0.7.10)
238
+ ruby-kafka (1.3.0)
239
239
  digest-crc
240
- ruby-progressbar (1.10.1)
240
+ ruby-progressbar (1.11.0)
241
241
  shellany (0.0.1)
242
242
  sigurd (0.0.1)
243
243
  concurrent-ruby (~> 1)
@@ -250,7 +250,7 @@ GEM
250
250
  activesupport (>= 4.0)
251
251
  sprockets (>= 3.0.0)
252
252
  sqlite3 (1.4.2)
253
- thor (1.0.1)
253
+ thor (1.1.0)
254
254
  tzinfo (2.0.4)
255
255
  concurrent-ruby (~> 1.0)
256
256
  unicode-display_width (1.7.0)
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency('avro_turf', '~> 0.11')
22
- spec.add_runtime_dependency('phobos', '~> 1.9')
23
- spec.add_runtime_dependency('ruby-kafka', '~> 0.7')
22
+ spec.add_runtime_dependency('phobos', '>= 1.9', '< 3.0')
23
+ spec.add_runtime_dependency('ruby-kafka', '< 2')
24
24
  spec.add_runtime_dependency('sigurd', '0.0.1')
25
25
 
26
26
  spec.add_development_dependency('activerecord-import')
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support'
4
+
3
5
  require 'phobos'
4
6
  require 'deimos/version'
5
7
  require 'deimos/config/configuration'
@@ -18,7 +20,6 @@ require 'deimos/backends/test'
18
20
 
19
21
  require 'deimos/schema_backends/base'
20
22
 
21
- require 'deimos/monkey_patches/ruby_kafka_heartbeat'
22
23
  require 'deimos/monkey_patches/phobos_producer'
23
24
  require 'deimos/monkey_patches/phobos_cli'
24
25
 
@@ -67,7 +67,7 @@ module Deimos
67
67
  topic(kafka_config.topic) if kafka_config.topic.present? && klass.respond_to?(:topic)
68
68
  schema(kafka_config.schema) if kafka_config.schema.present?
69
69
  namespace(kafka_config.namespace) if kafka_config.namespace.present?
70
- key_config(kafka_config.key_config) if kafka_config.key_config.present?
70
+ key_config(**kafka_config.key_config) if kafka_config.key_config.present?
71
71
  end
72
72
  end
73
73
 
@@ -6,6 +6,9 @@ module Deimos
6
6
  module KafkaSource
7
7
  extend ActiveSupport::Concern
8
8
 
9
+ DEPRECATION_WARNING = 'The kafka_producer interface will be deprecated ' \
10
+ 'in future releases. Please use kafka_producers instead.'
11
+
9
12
  included do
10
13
  after_create(:send_kafka_event_on_create)
11
14
  after_update(:send_kafka_event_on_update)
@@ -64,19 +67,12 @@ module Deimos
64
67
 
65
68
  # @return [Array<Deimos::ActiveRecordProducer>] the producers to run.
66
69
  def kafka_producers
67
- raise NotImplementedError if self.method(:kafka_producer).
68
- owner == Deimos::KafkaSource
69
-
70
- [self.kafka_producer]
71
- end
72
-
73
- # Deprecated - use #kafka_producers instead.
74
- # @return [Deimos::ActiveRecordProducer] the producer to use.
75
- def kafka_producer
76
- raise NotImplementedError if self.method(:kafka_producers).
77
- owner == Deimos::KafkaSource
70
+ if self.respond_to?(:kafka_producer)
71
+ Deimos.config.logger.warn(message: DEPRECATION_WARNING)
72
+ return [self.kafka_producer]
73
+ end
78
74
 
79
- self.kafka_producers.first
75
+ raise NotImplementedError
80
76
  end
81
77
 
82
78
  # This is an internal method, part of the activerecord_import gem. It's
@@ -34,7 +34,7 @@ module Deimos
34
34
  end
35
35
  end
36
36
 
37
- config.before(:each) do
37
+ config.prepend_before(:each) do
38
38
  client = double('client').as_null_object
39
39
  allow(client).to receive(:time) do |*_args, &block|
40
40
  block.call
@@ -68,7 +68,7 @@ module Deimos
68
68
 
69
69
  # Grab the PollInfo or create if it doesn't exist.
70
70
  def retrieve_poll_info
71
- ActiveRecord::Base.connection.reconnect!
71
+ ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.open_transactions.positive?
72
72
  new_time = @config.start_from_beginning ? Time.new(0) : Time.zone.now
73
73
  @info = Deimos::PollInfo.find_by_producer(@config.producer_class) ||
74
74
  Deimos::PollInfo.create!(producer: @config.producer_class,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.8.5'
4
+ VERSION = '1.9.2'
5
5
  end
@@ -308,5 +308,74 @@ module KafkaSourceSpec
308
308
  }, widgets[1].id)
309
309
  end
310
310
  end
311
+
312
+ context 'with AR models that implement the kafka_producer interface' do
313
+ before(:each) do
314
+ # Dummy class we can include the mixin in. Has a backing table created
315
+ # earlier and has the import hook disabled
316
+ deprecated_class = Class.new(ActiveRecord::Base) do
317
+ include Deimos::KafkaSource
318
+ self.table_name = 'widgets'
319
+
320
+ # :nodoc:
321
+ def self.kafka_config
322
+ {
323
+ update: true,
324
+ delete: true,
325
+ import: false,
326
+ create: true
327
+ }
328
+ end
329
+
330
+ # :nodoc:
331
+ def self.kafka_producer
332
+ WidgetProducer
333
+ end
334
+ end
335
+ stub_const('WidgetDeprecated', deprecated_class)
336
+ WidgetDeprecated.reset_column_information
337
+ end
338
+
339
+ it 'logs a warning and sends the message as usual' do
340
+ expect(Deimos.config.logger).to receive(:warn).with({ message: WidgetDeprecated::DEPRECATION_WARNING })
341
+ widget = WidgetDeprecated.create(widget_id: 1, name: 'Widget 1')
342
+ expect('my-topic').to have_sent({
343
+ widget_id: 1,
344
+ name: 'Widget 1',
345
+ id: widget.id,
346
+ created_at: anything,
347
+ updated_at: anything
348
+ }, widget.id)
349
+ end
350
+ end
351
+
352
+ context 'with AR models that do not implement any producer interface' do
353
+ before(:each) do
354
+ # Dummy class we can include the mixin in. Has a backing table created
355
+ # earlier and has the import hook disabled
356
+ buggy_class = Class.new(ActiveRecord::Base) do
357
+ include Deimos::KafkaSource
358
+ self.table_name = 'widgets'
359
+
360
+ # :nodoc:
361
+ def self.kafka_config
362
+ {
363
+ update: true,
364
+ delete: true,
365
+ import: false,
366
+ create: true
367
+ }
368
+ end
369
+ end
370
+ stub_const('WidgetBuggy', buggy_class)
371
+ WidgetBuggy.reset_column_information
372
+ end
373
+
374
+ it 'raises a NotImplementedError exception' do
375
+ expect {
376
+ WidgetBuggy.create(widget_id: 1, name: 'Widget 1')
377
+ }.to raise_error(NotImplementedError)
378
+ end
379
+ end
311
380
  end
312
381
  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.8.5
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf
@@ -28,30 +28,36 @@ dependencies:
28
28
  name: phobos
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.9'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '1.9'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: ruby-kafka
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - "<"
46
52
  - !ruby/object:Gem::Version
47
- version: '0.7'
53
+ version: '2'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - "<"
53
59
  - !ruby/object:Gem::Version
54
- version: '0.7'
60
+ version: '2'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: sigurd
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -380,7 +386,6 @@ files:
380
386
  - lib/deimos/metrics/provider.rb
381
387
  - lib/deimos/monkey_patches/phobos_cli.rb
382
388
  - lib/deimos/monkey_patches/phobos_producer.rb
383
- - lib/deimos/monkey_patches/ruby_kafka_heartbeat.rb
384
389
  - lib/deimos/poll_info.rb
385
390
  - lib/deimos/producer.rb
386
391
  - lib/deimos/railtie.rb
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Kafka
4
- class Heartbeat
5
- def initialize(group:, interval:, instrumenter:)
6
- @group = group
7
- @interval = interval
8
- @last_heartbeat = Time.now
9
- @instrumenter = instrumenter
10
- end
11
-
12
- def trigger!
13
- @instrumenter.instrument('heartbeat.consumer',
14
- group_id: @group.group_id,
15
- topic_partitions: @group.assigned_partitions) do
16
- @group.heartbeat
17
- @last_heartbeat = Time.now
18
- end
19
- end
20
- end
21
-
22
- class Client
23
- def consumer(
24
- group_id:,
25
- session_timeout: 30,
26
- offset_commit_interval: 10,
27
- offset_commit_threshold: 0,
28
- heartbeat_interval: 10,
29
- offset_retention_time: nil,
30
- fetcher_max_queue_size: 100
31
- )
32
- cluster = initialize_cluster
33
-
34
- instrumenter = DecoratingInstrumenter.new(@instrumenter,
35
- group_id: group_id)
36
-
37
- # The Kafka protocol expects the retention time to be in ms.
38
- retention_time = (offset_retention_time && offset_retention_time * 1_000) || -1
39
-
40
- group = ConsumerGroup.new(
41
- cluster: cluster,
42
- logger: @logger,
43
- group_id: group_id,
44
- session_timeout: session_timeout,
45
- retention_time: retention_time,
46
- instrumenter: instrumenter
47
- )
48
-
49
- fetcher = Fetcher.new(
50
- cluster: initialize_cluster,
51
- group: group,
52
- logger: @logger,
53
- instrumenter: instrumenter,
54
- max_queue_size: fetcher_max_queue_size
55
- )
56
-
57
- offset_manager = OffsetManager.new(
58
- cluster: cluster,
59
- group: group,
60
- fetcher: fetcher,
61
- logger: @logger,
62
- commit_interval: offset_commit_interval,
63
- commit_threshold: offset_commit_threshold,
64
- offset_retention_time: offset_retention_time
65
- )
66
-
67
- heartbeat = Heartbeat.new(
68
- group: group,
69
- interval: heartbeat_interval,
70
- instrumenter: instrumenter
71
- )
72
-
73
- Consumer.new(
74
- cluster: cluster,
75
- logger: @logger,
76
- instrumenter: instrumenter,
77
- group: group,
78
- offset_manager: offset_manager,
79
- fetcher: fetcher,
80
- session_timeout: session_timeout,
81
- heartbeat: heartbeat
82
- )
83
- end
84
- end
85
- end