lyber-core 8.1.0 → 9.0.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 +20 -6
- data/lib/lyber_core/version.rb +1 -1
- data/lib/lyber_core/workflow.rb +16 -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: aaaf768d39cc56a2ad9f40548a9734a1c03155a51cf5df81d8a224d3a773a562
|
|
4
|
+
data.tar.gz: 9ae8b44dc1843f6c7fda1e630851c8bd036f9537aebd610717543f0a9a4373c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1a9cb62f805fad5aa37ae205fcbaa8dc477d248184df92c114bef7451c05cc49bf379e2decb88b1d6a31f82a67c4fe5cf185e53ff48e97e0522f789771946bc
|
|
7
|
+
data.tar.gz: 27db999355b0bacf1e0f5bf76f33cb0abb03d197081481c9fd0ddf8dc391f5d2a8292eba43a64b07b40df196d6c1c3232f09c8509013e705a47d2f4845eaf63e
|
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)
|
|
55
56
|
@druid = druid
|
|
56
|
-
|
|
57
|
+
@version = version
|
|
58
|
+
Honeybadger.context(druid:, process:, workflow_name:, version:)
|
|
57
59
|
|
|
58
60
|
logger.info "#{druid} processing #{process} (#{workflow_name})"
|
|
61
|
+
return if skip_for_inactive_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,18 @@ 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
|
+
def skip_for_inactive_version?
|
|
125
|
+
return false if workflow.active_version?
|
|
126
|
+
|
|
127
|
+
msg = "Item #{druid} is queued for version #{version} of #{process} (#{workflow_name}), " \
|
|
128
|
+
'but that is not the active version. Skipping.'
|
|
129
|
+
logger.warn(msg)
|
|
130
|
+
workflow.skip!(msg)
|
|
131
|
+
|
|
132
|
+
true
|
|
119
133
|
end
|
|
120
134
|
|
|
121
135
|
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
|
|
@@ -29,24 +30,33 @@ module LyberCore
|
|
|
29
30
|
@process_response ||= workflow_response.process_for_recent_version(name: process)
|
|
30
31
|
end
|
|
31
32
|
|
|
33
|
+
# @return [Boolean] true if this workflow step is for the active version of the workflow
|
|
34
|
+
def active_version?
|
|
35
|
+
workflow_response.process_for(name: process, version:).active_version?
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
def start!(note)
|
|
33
|
-
workflow_process.update(status: 'started', elapsed: 1.0, note:)
|
|
39
|
+
workflow_process.update(status: 'started', elapsed: 1.0, note:, version:)
|
|
34
40
|
end
|
|
35
41
|
|
|
36
42
|
def complete!(status, elapsed, note)
|
|
37
|
-
workflow_process.update(status:, elapsed:, note:)
|
|
43
|
+
workflow_process.update(status:, elapsed:, note:, version:)
|
|
38
44
|
end
|
|
39
45
|
|
|
40
46
|
def retrying!
|
|
41
|
-
workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil)
|
|
47
|
+
workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil, version:)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def skip!(note)
|
|
51
|
+
workflow_process.update(status: 'skipped', elapsed: 0, note:, version:)
|
|
42
52
|
end
|
|
43
53
|
|
|
44
54
|
def error!(error_msg, error_text)
|
|
45
|
-
workflow_process.update_error(error_msg:, error_text:)
|
|
55
|
+
workflow_process.update_error(error_msg:, error_text:, version:)
|
|
46
56
|
end
|
|
47
57
|
|
|
48
58
|
delegate :context, :status, :lane_id, to: :process_response
|
|
49
59
|
|
|
50
|
-
attr_reader :object_client, :workflow_name, :process
|
|
60
|
+
attr_reader :object_client, :workflow_name, :process, :version
|
|
51
61
|
end
|
|
52
62
|
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:
|
|
4
|
+
version: 9.0.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: []
|