deimos-ruby 1.22.2 → 1.22.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/deimos/config/configuration.rb +2 -1
- data/lib/deimos/utils/db_poller/base.rb +1 -1
- data/lib/deimos/utils/db_poller/state_based.rb +7 -4
- data/lib/deimos/utils/db_poller/time_based.rb +7 -4
- data/lib/deimos/version.rb +1 -1
- data/spec/utils/db_poller_spec.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 014d4e4a2682f57a22a065431a0de6ae0ca76fd64cb8e754f391f8f40edd8e3f
|
4
|
+
data.tar.gz: b7bec2abc1e5394ec435dc0a0ef86dbb9b26e379cca0db63f448a89c5b4717ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ac915ad65b58c77d08bf61c70f978f1ffd37ef58ae39d0e03156b778d5a36ba00de227b855b5ccbd0251d6eda1f4ea7e288b7328961d6fd790cc6a4423b9210
|
7
|
+
data.tar.gz: ca1d551a581a1a968746858a3d99aacc9ace8e7f342cfe4526cc9d27aa158360c2f858b1bf9cc1018c1848b26689b239a0b74f0ccbc2d00b085776ed34a52525
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,11 @@ 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
|
+
|
10
15
|
# 1.22.2 - 2023-05-10
|
11
16
|
- Feature: Add `DEIMOS_TASK_NAME` env variable when running a task (consumer, DB poller, DB producer).
|
12
17
|
|
@@ -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
|
|
data/lib/deimos/version.rb
CHANGED
@@ -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).
|
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.
|
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-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|