oai_schedules 0.7.0 → 0.8.0
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/CHANGELOG.md +5 -0
- data/lib/oai_schedules/manager.rb +30 -6
- data/lib/oai_schedules/version.rb +1 -1
- 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: 86d2572fbf72c1d75ab9b83efcbb739726962127953458f438cf5ac20278997d
|
4
|
+
data.tar.gz: b4fe62d6a8280e9bd55c2337d10615768808d0d5ccbeef469a8ad4a7a55b0b05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1294b5a37cf3d9ef098c5d1484d1853e5c5990148348b735c7a22809cbab963c1d22e1fae8b3ab525107a21368483ac8eb600f954293dde41a6039db4fed6097
|
7
|
+
data.tar.gz: bc8a60e47cd6f1778483556e644362e976b97456b5c30ae6c320b526b55958e2852011c002c3268afd15c003f835a03b847d0a9173f4590e418ccfece198f447
|
data/CHANGELOG.md
CHANGED
@@ -231,11 +231,14 @@ module OAISchedules
|
|
231
231
|
state["resumption_token"] = nil
|
232
232
|
state["expiration_date_resumption_token"] = nil
|
233
233
|
state["datetime_now"] = get_datetime_now
|
234
|
+
state["datetime_next_harvesting"] = nil
|
234
235
|
state["count_success"] = 0
|
235
236
|
state["count_fails"] = 0
|
236
237
|
state["done"] = false
|
237
238
|
state["count_harvested_records"] = 0
|
238
239
|
state["latest_harvested_records_datestamp"] = nil
|
240
|
+
state["harvesting"] = false
|
241
|
+
state["error"] = nil
|
239
242
|
end
|
240
243
|
|
241
244
|
|
@@ -259,8 +262,7 @@ module OAISchedules
|
|
259
262
|
task = @schedules[name][:task]
|
260
263
|
interval_s_safe = 60
|
261
264
|
begin
|
262
|
-
|
263
|
-
interval_s = duration.to_seconds
|
265
|
+
interval_s = interval_iso8601_to_seconds(@schedules[name][:content]["interval"])
|
264
266
|
@logger.info("#{name}: task interval (s): #{interval_s}")
|
265
267
|
th_interval_s = 0.1 # protects from negative, 0 or small time intervals
|
266
268
|
if interval_s < th_interval_s
|
@@ -338,7 +340,9 @@ module OAISchedules
|
|
338
340
|
|
339
341
|
|
340
342
|
def logic(name, content, state_machine, state)
|
343
|
+
state["datetime_next_harvesting"] = get_datetime_next_schedule_tick_from_now(content["interval"])
|
341
344
|
loop do
|
345
|
+
# sleep(3)
|
342
346
|
@logger.info("#{name}: handling state: #{state_machine.state}")
|
343
347
|
case state_machine.state
|
344
348
|
when StateHarvesting::NOT_IDENTIFIED
|
@@ -353,7 +357,8 @@ module OAISchedules
|
|
353
357
|
when StateHarvesting::IDLE
|
354
358
|
state_machine.add_event(EventHarvesting::REQUEST_HARVEST)
|
355
359
|
when StateHarvesting::HARVESTING
|
356
|
-
use_resumption_token = false
|
360
|
+
use_resumption_token = false # don't change
|
361
|
+
state["harvesting"] = true
|
357
362
|
format = content["format"] || ""
|
358
363
|
fmt_dt = content.dig("repository", "granularity")
|
359
364
|
from = convert_datetime(content["from"], fmt_dt) || ""
|
@@ -400,7 +405,6 @@ module OAISchedules
|
|
400
405
|
state["expiration_date_resumption_token"] = data_token["_expirationDate"]
|
401
406
|
end
|
402
407
|
end
|
403
|
-
state["datetime_now"] = get_datetime_now
|
404
408
|
n_records = data["record"].size
|
405
409
|
state["count_harvested_records"] += n_records
|
406
410
|
if n_records > 0
|
@@ -416,6 +420,7 @@ module OAISchedules
|
|
416
420
|
error = e
|
417
421
|
end
|
418
422
|
if error.nil?
|
423
|
+
state["error"] = nil
|
419
424
|
if use_resumption_token
|
420
425
|
if state["resumption_token"].nil?
|
421
426
|
state_machine.add_event(EventHarvesting::DONE_HARVEST)
|
@@ -424,11 +429,19 @@ module OAISchedules
|
|
424
429
|
to_pause = false
|
425
430
|
end
|
426
431
|
else
|
427
|
-
|
428
|
-
to_pause = true
|
432
|
+
to_pause = false
|
429
433
|
end
|
434
|
+
else
|
435
|
+
state["error"] = {
|
436
|
+
"message" => error.message,
|
437
|
+
"backtrace" => error.backtrace
|
438
|
+
}
|
439
|
+
state_machine.add_event(EventHarvesting::DONE_HARVEST)
|
440
|
+
to_pause = true
|
430
441
|
end
|
431
442
|
state["done"] = done
|
443
|
+
state["harvesting"] = !to_pause
|
444
|
+
state["datetime_now"] = get_datetime_now
|
432
445
|
end
|
433
446
|
path_file_state = get_path_state_file_from_schedule_name(name)
|
434
447
|
@logger.info("#{name}: writing to state file #{path_file_state}")
|
@@ -570,6 +583,17 @@ module OAISchedules
|
|
570
583
|
DateTime.now.strftime('%FT%TZ')
|
571
584
|
end
|
572
585
|
|
586
|
+
def interval_iso8601_to_seconds(str_interval)
|
587
|
+
ISO8601::Duration.new(str_interval).to_seconds
|
588
|
+
end
|
589
|
+
|
590
|
+
def get_datetime_next_schedule_tick_from_now(str_interval)
|
591
|
+
interval_s = interval_iso8601_to_seconds(str_interval)
|
592
|
+
dt = DateTime.now
|
593
|
+
dt += 1.0*interval_s/(24*60*60)
|
594
|
+
dt.strftime('%FT%TZ')
|
595
|
+
end
|
596
|
+
|
573
597
|
end
|
574
598
|
|
575
599
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oai_schedules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Monari
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: concurrent-ruby
|