deimos-ruby 1.22.1 → 1.22.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1819694e6ec5bc9cad69f0a3d7edaad53d4daae80ee0af95312044d503e40d1
4
- data.tar.gz: 1577ab483b8fc8a16dc614c12156e2161a3ab2d372b45ee7825f30837fdc36e4
3
+ metadata.gz: 014d4e4a2682f57a22a065431a0de6ae0ca76fd64cb8e754f391f8f40edd8e3f
4
+ data.tar.gz: b7bec2abc1e5394ec435dc0a0ef86dbb9b26e379cca0db63f448a89c5b4717ad
5
5
  SHA512:
6
- metadata.gz: 1fc162b425d00a308679662d4a48753dbe1fac0ab252d329ad10622f894301de2e35dcc2ca3c0d9366b516ebbce7e8d008fd37ee1c2526d9f5a5be3188d6380f
7
- data.tar.gz: b09c3c0a0c7980b9bd2431754001c8b3f18d6a21981dbb7dd5b1336f60a3411e26c5c938b3d55e48039c2306ffac54bc2f95c4beac4700b994fdcf4168900ddc
6
+ metadata.gz: 6ac915ad65b58c77d08bf61c70f978f1ffd37ef58ae39d0e03156b778d5a36ba00de227b855b5ccbd0251d6eda1f4ea7e288b7328961d6fd790cc6a4423b9210
7
+ data.tar.gz: ca1d551a581a1a968746858a3d99aacc9ace8e7f342cfe4526cc9d27aa158360c2f858b1bf9cc1018c1848b26689b239a0b74f0ccbc2d00b085776ed34a52525
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
+ # 1.22.3 - 2023-06-13
11
+
12
+ - Fix: Don't update last_sent to current time on every poll.
13
+ - Feature: Allow for infinite retries in DB poller.
14
+
15
+ # 1.22.2 - 2023-05-10
16
+ - Feature: Add `DEIMOS_TASK_NAME` env variable when running a task (consumer, DB poller, DB producer).
17
+
10
18
  # 1.22.1 - 2023-05-01
11
19
 
12
20
  - Fix: Bug introduced with 1.22 when associations are not used
@@ -474,7 +474,8 @@ module Deimos # rubocop:disable Metrics/ModuleLength
474
474
  # time, it will run again immediately and the timeout
475
475
  # will be pushed to the next e.g. 1 minute.
476
476
  setting :run_every, 60
477
- # The number of times to retry production when encountering a *non-Kafka* error.
477
+ # The number of times to retry production when encountering a *non-Kafka* error. Set to nil
478
+ # for infinite retries.
478
479
  setting :retries, 1
479
480
  # Amount of time, in seconds, to wait before catching updates, to allow transactions
480
481
  # to complete but still pick up the right records. Should only be set for time-based mode.
@@ -124,7 +124,7 @@ module Deimos
124
124
  retry
125
125
  rescue StandardError => e
126
126
  Deimos.config.logger.error("Error publishing through DB poller: #{e.message}}")
127
- if retries < @config.retries
127
+ if @config.retries.nil? || retries < @config.retries
128
128
  retries += 1
129
129
  sleep(0.5)
130
130
  retry
@@ -12,20 +12,23 @@ module Deimos
12
12
  def process_updates
13
13
  Deimos.config.logger.info("Polling #{log_identifier}")
14
14
  status = PollStatus.new(0, 0, 0)
15
+ first_batch = true
15
16
 
16
17
  # poll_query gets all the relevant data from the database, as defined
17
18
  # by the producer itself.
18
19
  loop do
19
20
  Deimos.config.logger.debug("Polling #{log_identifier}, batch #{status.current_batch}")
20
21
  batch = fetch_results.to_a
21
- if batch.empty?
22
- @info.touch(:last_sent)
23
- break
24
- end
22
+ break if batch.empty?
25
23
 
24
+ first_batch = false
26
25
  success = process_batch_with_span(batch, status)
27
26
  finalize_batch(batch, success)
28
27
  end
28
+
29
+ # If there were no results at all, we update last_sent so that we still get a wait
30
+ # before the next poll.
31
+ @info.touch(:last_sent) if first_batch
29
32
  Deimos.config.logger.info("Poll #{log_identifier} complete (#{status.report}")
30
33
  end
31
34
 
@@ -30,20 +30,23 @@ module Deimos
30
30
  time_to = Time.zone.now - @config.delay_time
31
31
  Deimos.config.logger.info("Polling #{log_identifier} from #{time_from} to #{time_to}")
32
32
  status = PollStatus.new(0, 0, 0)
33
+ first_batch = true
33
34
 
34
35
  # poll_query gets all the relevant data from the database, as defined
35
36
  # by the producer itself.
36
37
  loop do
37
38
  Deimos.config.logger.debug("Polling #{log_identifier}, batch #{status.current_batch}")
38
39
  batch = fetch_results(time_from, time_to).to_a
39
- if batch.empty?
40
- @info.touch(:last_sent)
41
- break
42
- end
40
+ break if batch.empty?
43
41
 
42
+ first_batch = false
44
43
  process_and_touch_info(batch, status)
45
44
  time_from = last_updated(batch.last)
46
45
  end
46
+
47
+ # If there were no results at all, we update last_sent so that we still get a wait
48
+ # before the next poll.
49
+ @info.touch(:last_sent) if first_batch
47
50
  Deimos.config.logger.info("Poll #{log_identifier} complete at #{time_to} (#{status.report})")
48
51
  end
49
52
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.22.1'
4
+ VERSION = '1.22.3'
5
5
  end
@@ -12,6 +12,7 @@ namespace :deimos do
12
12
  config.producers.backend = :kafka if config.producers.backend == :kafka_async
13
13
  end
14
14
  ENV['DEIMOS_RAKE_TASK'] = 'true'
15
+ ENV['DEIMOS_TASK_NAME'] = 'consumer'
15
16
  STDOUT.sync = true
16
17
  Rails.logger.info('Running deimos:start rake task.')
17
18
  Phobos::CLI::Commands.start(%w(start --skip_config))
@@ -20,6 +21,7 @@ namespace :deimos do
20
21
  desc 'Starts the Deimos database producer'
21
22
  task db_producer: :environment do
22
23
  ENV['DEIMOS_RAKE_TASK'] = 'true'
24
+ ENV['DEIMOS_TASK_NAME'] = 'db_producer'
23
25
  STDOUT.sync = true
24
26
  Rails.logger.info('Running deimos:db_producer rake task.')
25
27
  thread_count = ENV['THREAD_COUNT'].to_i.zero? ? 1 : ENV['THREAD_COUNT'].to_i
@@ -28,6 +30,7 @@ namespace :deimos do
28
30
 
29
31
  task db_poller: :environment do
30
32
  ENV['DEIMOS_RAKE_TASK'] = 'true'
33
+ ENV['DEIMOS_TASK_NAME'] = 'db_poller'
31
34
  STDOUT.sync = true
32
35
  Rails.logger.info('Running deimos:db_poller rake task.')
33
36
  Deimos::Utils::DbPoller.start!
@@ -324,13 +324,18 @@ each_db_config(Deimos::Utils::DbPoller::Base) do
324
324
  poller.process_updates
325
325
  poller.process_updates
326
326
 
327
- expect(MyProducer).to have_received(:poll_query).twice.
327
+ expect(MyProducer).to have_received(:poll_query).
328
328
  with(time_from: time_value(secs: -1),
329
329
  time_to: time_value(secs: 120), # plus 122 seconds minus 2 seconds
330
330
  column_name: :updated_at,
331
331
  min_id: last_widget.id)
332
+ expect(MyProducer).to have_received(:poll_query).
333
+ with(time_from: time_value(secs: 122),
334
+ time_to: time_value(secs: 120), # yes this is weird but it's because of travel_to
335
+ column_name: :updated_at,
336
+ min_id: last_widget.id)
332
337
  expect(Deimos.config.logger).to have_received(:info).
333
- with('Poll my-topic-with-id complete at 2015-05-05 00:59:58 -0400 (3 batches, 0 errored batches, 7 processed messages)')
338
+ with('Poll MyProducer: ["my-topic-with-id"] complete at 2015-05-05 00:59:58 -0400 (3 batches, 0 errored batches, 7 processed messages)')
334
339
  end
335
340
 
336
341
  it 'should update PollInfo timestamp after processing' do
@@ -382,7 +387,7 @@ each_db_config(Deimos::Utils::DbPoller::Base) do
382
387
  expect(info.last_sent.in_time_zone).to eq(time_value(mins: -61, secs: 30))
383
388
  expect(info.last_sent_id).to eq(widgets[6].id)
384
389
  expect(Deimos.config.logger).to have_received(:info).
385
- with('Poll my-topic-with-id complete at 2015-05-05 00:59:58 -0400 (2 batches, 1 errored batches, 7 processed messages)')
390
+ with('Poll MyProducer: ["my-topic-with-id"] complete at 2015-05-05 00:59:58 -0400 (2 batches, 1 errored batches, 7 processed messages)')
386
391
  end
387
392
  end
388
393
  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.22.1
4
+ version: 1.22.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf