lyber-core 4.1.5 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c9b8675c858e0dbf15994666e5f8f9a069f0aa21
4
- data.tar.gz: 1d8111d21ff39fcd244976e702f14096c8ba8290
2
+ SHA256:
3
+ metadata.gz: 238ef0f4203fa0303db394acaa64de7baa7180b711c8716e32778519c7a53410
4
+ data.tar.gz: 7cf2b763be36843efd52572cb6d5545326831fe6bb2379223d7127f50d99f271
5
5
  SHA512:
6
- metadata.gz: cfcadb4929c95bdfb28b5e223a639ee1d83215610304190540a54460effb1cdaf4855cb1cefc78632801308a51888724c586741a5753f5b4c8da2d47d3417135
7
- data.tar.gz: 81c6b4c966488601c0ace0485414eb253da37783cd96a03622bd636e4a76702ecca0e14b03471b27506304b2d9b1ef888ba49abab349950161e6b008b87e3eaf
6
+ metadata.gz: b0b0c7c39594aa2ffac22e48a58e02d0b421088affda0f2e5197dcfb30341912c54b67da455b623a4fdbf0541a7ecc4a48d1f96d05526f13320e2d72288fb402
7
+ data.tar.gz: 2b8240abf814d1063838081abb58ac1eddab4c274d3c5595eeb9798a6aad2e8098a1c7a8326f3f9748e5ade519ad821e98577d9639810f77a59af6f1fc76b9d6
@@ -1,6 +1,4 @@
1
- require 'dor-workflow-service'
2
-
3
- require 'lyber_core/base'
1
+ require 'dor-services'
4
2
  require 'lyber_core/log'
5
3
  require 'lyber_core/robot'
6
4
  require 'lyber_core/return_state'
@@ -51,7 +51,7 @@ module LyberCore
51
51
  @workflow_name = workflow_name
52
52
  @step_name = step_name
53
53
  @check_queued_status = opts.fetch(:check_queued_status, true)
54
- @workflow_service = opts.fetch(:workflow_service, Dor::WorkflowService)
54
+ @workflow_service = opts.fetch(:workflow_service) { Dor::Config.workflow.client }
55
55
  end
56
56
 
57
57
  # Sets up logging, timing and error handling of the job
@@ -78,7 +78,6 @@ module LyberCore
78
78
  else
79
79
  workflow_state = 'completed'
80
80
  end
81
-
82
81
  # update the workflow status from its current state to the state returned by perform (or 'completed' as the default)
83
82
  workflow_service.update_workflow_status(@repo, druid, @workflow_name, @step_name, workflow_state, elapsed: elapsed, note: note)
84
83
  LyberCore::Log.info "Finished #{druid} in #{sprintf('%0.4f', elapsed)}s"
@@ -96,7 +95,7 @@ module LyberCore
96
95
  private
97
96
 
98
97
  def item_queued?(druid)
99
- status = workflow_service.get_workflow_status(@repo, druid, @workflow_name, @step_name)
98
+ status = workflow_service.workflow_status(@repo, druid, @workflow_name, @step_name)
100
99
  return true if status =~ /queued/i
101
100
  LyberCore::Log.warn "Item #{druid} is not queued, but has status of '#{status}'. Will skip processing"
102
101
  false
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.1.5
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alpana Pande
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2018-06-20 00:00:00.000000000 Z
19
+ date: 2019-05-07 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activesupport
@@ -33,25 +33,19 @@ dependencies:
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  - !ruby/object:Gem::Dependency
36
- name: dor-workflow-service
36
+ name: dor-services
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '1.7'
42
- - - "<"
39
+ - - "~>"
43
40
  - !ruby/object:Gem::Version
44
- version: '3'
41
+ version: '7.0'
45
42
  type: :runtime
46
43
  prerelease: false
47
44
  version_requirements: !ruby/object:Gem::Requirement
48
45
  requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: '1.7'
52
- - - "<"
46
+ - - "~>"
53
47
  - !ruby/object:Gem::Version
54
- version: '3'
48
+ version: '7.0'
55
49
  - !ruby/object:Gem::Dependency
56
50
  name: coveralls
57
51
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +156,6 @@ files:
162
156
  - LICENSE
163
157
  - README.md
164
158
  - lib/lyber_core.rb
165
- - lib/lyber_core/base.rb
166
159
  - lib/lyber_core/log.rb
167
160
  - lib/lyber_core/return_state.rb
168
161
  - lib/lyber_core/robot.rb
@@ -187,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
180
  version: 1.3.6
188
181
  requirements: []
189
182
  rubyforge_project:
190
- rubygems_version: 2.6.11
183
+ rubygems_version: 2.7.6
191
184
  signing_key:
192
185
  specification_version: 4
193
186
  summary: Core services used by the SUL Digital Library
@@ -1,91 +0,0 @@
1
- require 'benchmark'
2
- require 'active_support'
3
-
4
- module LyberCore
5
- # The skeleton of robots, a replacement for LyberCore::Robot
6
- # @example To migrate from LyberCore::Robot, replace
7
- # class MyRobot
8
- # include LyberCore::Robot
9
- # def initialize
10
- # new(REPOSITORY, WORKFLOW_NAME, ROBOT_NAME)
11
- # end
12
- # def perform ...
13
- # end
14
- # @example Usage: implement self.worker and override #perform, as before
15
- # class MyRobot < LyberCore::Base
16
- # def self.worker
17
- # new('sdr', 'preservationIngestWF', 'ingest-poison')
18
- # end
19
- # def perform ...
20
- # end
21
- class Base
22
- # Called by job-manager: instantiate the Robot and call #work with the druid
23
- # @param [String] druid
24
- # @note Override the instance method #perform, probably not this one
25
- def self.perform(druid)
26
- worker.work(druid)
27
- end
28
-
29
- # get an instance, without knowing the params for .new()
30
- # @return [LyberCore::Base]
31
- def self.worker
32
- raise NotImplementedError, 'Implement class method self.worker on the subclass'
33
- end
34
-
35
- attr_accessor :repo, :workflow_name, :step_name, :check_queued_status, :workflow_service
36
-
37
- def initialize(repo, workflow_name, step_name, opts = {})
38
- Signal.trap('QUIT') { puts "#{Process.pid} ignoring SIGQUIT" } # SIGQUIT ignored to let the robot finish
39
- @repo = repo
40
- @workflow_name = workflow_name
41
- @step_name = step_name
42
- @check_queued_status = opts.fetch(:check_queued_status, true)
43
- @workflow_service = opts.fetch(:workflow_service, Dor::WorkflowService)
44
- end
45
-
46
- # @return [Logger]
47
- def logger
48
- unless @log_init # one time
49
- LyberCore::Log.set_logfile($stdout) # let process manager(bluepill) handle logging
50
- @log_init = true
51
- end
52
- LyberCore::Log
53
- end
54
-
55
- # Sets up logging, timing and error handling of the job
56
- # Calls the #perform method, then sets workflow to 'completed' or 'error' depending on success
57
- def work(druid)
58
- logger.info "#{druid} processing"
59
- return if check_queued_status && !item_queued?(druid)
60
- result = nil
61
- elapsed = Benchmark.realtime { result = perform(druid) }
62
- if result.is_a?(LyberCore::Robot::ReturnState)
63
- workflow_state = result.status
64
- note = result.note unless result.note.blank?
65
- else
66
- workflow_state = 'completed' # default
67
- end
68
- note ||= Socket.gethostname # default
69
- workflow_service.update_workflow_status(repo, druid, workflow_name, step_name, workflow_state, elapsed: elapsed, note: note)
70
- logger.info "Finished #{druid} in #{format('%0.4f', elapsed)}s"
71
- rescue StandardError => e
72
- Honeybadger.notify(e) if defined? Honeybadger
73
- begin
74
- logger.error e.message + "\n" + e.backtrace.join("\n")
75
- workflow_service.update_workflow_error_status(repo, druid, workflow_name, step_name, e.message, error_text: Socket.gethostname)
76
- rescue StandardError => e2
77
- logger.error "Cannot set #{druid} to status='error'\n" + e2.message + "\n" + e2.backtrace.join("\n")
78
- raise e2 # send exception to Resque failed queue
79
- end
80
- end
81
-
82
- private
83
-
84
- def item_queued?(druid)
85
- status = workflow_service.get_workflow_status(repo, druid, workflow_name, step_name)
86
- return true if status =~ /queued/i
87
- logger.warn "Item #{druid} is not queued, but has status of '#{status}'. Will skip processing"
88
- false
89
- end
90
- end
91
- end