background_worker 0.0.4 → 0.0.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcc18679c11c98ef7f0da1d7d5112004edd1bfb4
|
4
|
+
data.tar.gz: 3d4cacb66997222274d85dde11e5787c3fad9ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37680e16cc121d912e38df598045df83c3e8e3fce5dedb168830932ac1e126d3de8fbfdb34860f0806c4999f26f4a891a7589310adfb323a7810aa4e4cab5553
|
7
|
+
data.tar.gz: 4002280277529ea9af57c9714d19f1649a920719501e06eb1c9c63c521a295ce4acbb980dc652509f7cd9b10d7257e4725cba829bbb484275c8b17a6eb526967
|
@@ -9,10 +9,10 @@ module BackgroundWorker
|
|
9
9
|
def initialize(options = {})
|
10
10
|
Time.zone = Setting.time_zone
|
11
11
|
|
12
|
-
@uid = options[
|
12
|
+
@uid = options[:uid]
|
13
13
|
|
14
14
|
# Store state persistently, to enable status checkups & progress reporting
|
15
|
-
@state = BackgroundWorker::PersistentState.new(@uid, options.except(
|
15
|
+
@state = BackgroundWorker::PersistentState.new(@uid, options.except(:uid))
|
16
16
|
log("Created #{self.class}")
|
17
17
|
log("Options are: #{options.pretty_inspect}")
|
18
18
|
end
|
@@ -61,16 +61,18 @@ module BackgroundWorker
|
|
61
61
|
|
62
62
|
# Public method to do in background...
|
63
63
|
def perform_in_background(method_name, options = {})
|
64
|
+
opts = options.symbolize_keys
|
65
|
+
|
64
66
|
method_name = method_name.to_sym
|
65
|
-
|
67
|
+
opts[:uid] ||= BackgroundWorker::Uid.new(to_s, method_name).generate
|
66
68
|
|
67
69
|
# Store into shared-cache before kicking job off
|
68
|
-
BackgroundWorker::PersistentState.new(
|
70
|
+
BackgroundWorker::PersistentState.new(opts[:uid], opts.except(:uid))
|
69
71
|
|
70
72
|
# Enqueue to the background queue
|
71
|
-
BackgroundWorker.enqueue(self, method_name,
|
73
|
+
BackgroundWorker.enqueue(self, method_name, opts)
|
72
74
|
|
73
|
-
|
75
|
+
opts[:uid]
|
74
76
|
end
|
75
77
|
|
76
78
|
# This method is called by the job runner
|
@@ -3,7 +3,7 @@ module BackgroundWorker
|
|
3
3
|
attr_reader :worker, :method_name, :options
|
4
4
|
|
5
5
|
def initialize(worker, method_name, options)
|
6
|
-
fail ArgumentError, "'uid' is required to identify worker" unless options[
|
6
|
+
fail ArgumentError, "'uid' is required to identify worker" unless options[:uid].present?
|
7
7
|
@worker = worker
|
8
8
|
@method_name = method_name
|
9
9
|
@options = options
|
@@ -15,7 +15,7 @@ module BackgroundWorker
|
|
15
15
|
|
16
16
|
rescue StandardError => e
|
17
17
|
log_worker_error(e)
|
18
|
-
BackgroundWorker.after_exception
|
18
|
+
BackgroundWorker.after_exception(e)
|
19
19
|
|
20
20
|
ensure
|
21
21
|
log_worker_finality
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: background_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|