lyber-core 8.1.0 → 8.2.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/lib/lyber_core/robot.rb +23 -5
- data/lib/lyber_core/version.rb +1 -1
- data/lib/lyber_core/workflow.rb +11 -6
- 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: 36bd350f4d9c4ce74e6da529f8fe9dddd89a8f2c71daa79ccad91fdc9efa00f3
|
|
4
|
+
data.tar.gz: '0122852b4e4e24cef6844b8aef7026c75bcd9573947b6c0c002208bd61838315'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84d64ade10a163e0092643301e0ead58e695f5506c38651e95965ebae44e128dd619990055c2b0a23cba201e4c816428d57d65f1b9db2c5955337ece3bcee148
|
|
7
|
+
data.tar.gz: 8b55154f52c0df55d7fa029ae22e1bd54747e10cb56763e0a71ffd44b1e3608e7d084f8d0c1feda15fc8a981c0d53a986b3b3ff36e5d8156fc9b391523db5c8b
|
data/lib/lyber_core/robot.rb
CHANGED
|
@@ -12,14 +12,15 @@ module LyberCore
|
|
|
12
12
|
sidekiq_retries_exhausted do |job, ex|
|
|
13
13
|
# When all the retries are exhausted, update the workflow to error.
|
|
14
14
|
robot = job['class'].constantize.new
|
|
15
|
-
druid = job['args']
|
|
15
|
+
druid, version = job['args']
|
|
16
16
|
workflow = Workflow.new(object_client: Dor::Services::Client.object(druid),
|
|
17
17
|
workflow_name: robot.workflow_name,
|
|
18
|
-
process: robot.process
|
|
18
|
+
process: robot.process,
|
|
19
|
+
version:)
|
|
19
20
|
workflow.error!(ex.message, Socket.gethostname)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
attr_reader :workflow_name, :process, :druid, :retriable_exceptions
|
|
23
|
+
attr_reader :workflow_name, :process, :druid, :version, :retriable_exceptions
|
|
23
24
|
attr_accessor :check_queued_status
|
|
24
25
|
|
|
25
26
|
# These methods are delegated to the workflow ivar as a convenient way for child classes to interact
|
|
@@ -51,11 +52,13 @@ module LyberCore
|
|
|
51
52
|
# Calls the #perform_work method, then sets workflow to 'completed' or 'error' depending on success
|
|
52
53
|
# rubocop:disable Metrics/AbcSize
|
|
53
54
|
# rubocop:disable Metrics/MethodLength
|
|
54
|
-
def perform(druid)
|
|
55
|
+
def perform(druid, version = nil)
|
|
55
56
|
@druid = druid
|
|
57
|
+
@version = version
|
|
56
58
|
Honeybadger.context(druid:, process:, workflow_name:)
|
|
57
59
|
|
|
58
60
|
logger.info "#{druid} processing #{process} (#{workflow_name})"
|
|
61
|
+
return skip_for_superseded_version! if superseded_version?
|
|
59
62
|
return unless check_item_queued_or_retry?
|
|
60
63
|
|
|
61
64
|
# this is the default note to pass back to workflow service,
|
|
@@ -115,7 +118,22 @@ module LyberCore
|
|
|
115
118
|
end
|
|
116
119
|
|
|
117
120
|
def workflow
|
|
118
|
-
@workflow ||= Workflow.new(object_client:, workflow_name:, process:)
|
|
121
|
+
@workflow ||= Workflow.new(object_client:, workflow_name:, process:, version:)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# @return [Boolean] true if a version was provided and it no longer matches the object's current version,
|
|
125
|
+
# meaning a newer version has superseded the one this job was queued for
|
|
126
|
+
def superseded_version?
|
|
127
|
+
return false if version.nil?
|
|
128
|
+
|
|
129
|
+
cocina_object.version.to_i != version.to_i
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def skip_for_superseded_version!
|
|
133
|
+
msg = "Item #{druid} is queued for version #{version} but the current object version is " \
|
|
134
|
+
"#{cocina_object.version}. Skipping #{process} (#{workflow_name})."
|
|
135
|
+
logger.warn(msg)
|
|
136
|
+
workflow.skip!(msg)
|
|
119
137
|
end
|
|
120
138
|
|
|
121
139
|
def check_item_queued_or_retry? # rubocop:disable Metrics/AbcSize
|
data/lib/lyber_core/version.rb
CHANGED
data/lib/lyber_core/workflow.rb
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
module LyberCore
|
|
4
4
|
# This encapsulates the workflow operations that lyber-core does
|
|
5
5
|
class Workflow
|
|
6
|
-
def initialize(object_client:, workflow_name:, process:)
|
|
6
|
+
def initialize(object_client:, workflow_name:, process:, version:)
|
|
7
7
|
@object_client = object_client
|
|
8
8
|
@workflow_name = workflow_name
|
|
9
9
|
@process = process
|
|
10
|
+
@version = version
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
# @return [Dor::Services::Client::ObjectWorkflow] for druid/workflow/step on which this instance was initialized
|
|
@@ -30,23 +31,27 @@ module LyberCore
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def start!(note)
|
|
33
|
-
workflow_process.update(status: 'started', elapsed: 1.0, note:)
|
|
34
|
+
workflow_process.update(status: 'started', elapsed: 1.0, note:, version:)
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def complete!(status, elapsed, note)
|
|
37
|
-
workflow_process.update(status:, elapsed:, note:)
|
|
38
|
+
workflow_process.update(status:, elapsed:, note:, version:)
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def retrying!
|
|
41
|
-
workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil)
|
|
42
|
+
workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil, version:)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def skip!(note)
|
|
46
|
+
workflow_process.update(status: 'skipped', elapsed: 0, note:, version:)
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def error!(error_msg, error_text)
|
|
45
|
-
workflow_process.update_error(error_msg:, error_text:)
|
|
50
|
+
workflow_process.update_error(error_msg:, error_text:, version:)
|
|
46
51
|
end
|
|
47
52
|
|
|
48
53
|
delegate :context, :status, :lane_id, to: :process_response
|
|
49
54
|
|
|
50
|
-
attr_reader :object_client, :workflow_name, :process
|
|
55
|
+
attr_reader :object_client, :workflow_name, :process, :version
|
|
51
56
|
end
|
|
52
57
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lyber-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alpana Pande
|
|
@@ -15,7 +15,7 @@ authors:
|
|
|
15
15
|
- Peter Mangiafico
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date:
|
|
18
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: activesupport
|
|
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
265
265
|
- !ruby/object:Gem::Version
|
|
266
266
|
version: 1.3.6
|
|
267
267
|
requirements: []
|
|
268
|
-
rubygems_version: 3.6.
|
|
268
|
+
rubygems_version: 3.6.9
|
|
269
269
|
specification_version: 4
|
|
270
270
|
summary: Core services used by the SUL Digital Library
|
|
271
271
|
test_files: []
|