parallel_minion 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parallel_minion/minion.rb +15 -14
- data/lib/parallel_minion/version.rb +1 -1
- data/test/minion_scope_test.rb +1 -1
- data/test/minion_test.rb +32 -1
- data/test/test_db.sqlite3 +0 -0
- data/test/test_helper.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec80ef2321aa78ba6f8b6dc7b16452f1ccb15a9b
|
4
|
+
data.tar.gz: f3a394698da183ce6e64c8137ac7cf50cae98943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 946b4306251796613bf5a44b89d32016aa0a9133048caaaa698206151aeb5e9dc4684e377230d767b2fb8bcc2f952a83c18c140f96bcb7e5c44fdee10f88c16c
|
7
|
+
data.tar.gz: 1f52084ea14e186ff3796f8276fbc879bb99ada6d0b05fead4513b26a4611a471064c2ebbbc0cdb27ced7e1e9a41135674083436b2737108a54b921f640fb1fc
|
@@ -313,20 +313,21 @@ module ParallelMinion
|
|
313
313
|
Thread.current.name = "#{description}-#{Thread.current.object_id}"
|
314
314
|
|
315
315
|
# Copy logging tags from parent thread, if any
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
316
|
+
SemanticLogger.tagged(*tags) do
|
317
|
+
SemanticLogger.named_tagged(named_tags) do
|
318
|
+
logger.public_send(self.class.started_log_level, "Started #{description}")
|
319
|
+
begin
|
320
|
+
proc = Proc.new { run_in_scope(scopes, &block) }
|
321
|
+
logger.measure(self.class.completed_log_level, "Completed #{description}", log_exception: log_exception, metric: metric, &proc)
|
322
|
+
rescue Exception => exc
|
323
|
+
@exception = exc
|
324
|
+
nil
|
325
|
+
ensure
|
326
|
+
@duration = Time.now - start_time
|
327
|
+
# Return any database connections used by this thread back to the pool
|
328
|
+
ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
|
329
|
+
end
|
330
|
+
end
|
330
331
|
end
|
331
332
|
end
|
332
333
|
end
|
data/test/minion_scope_test.rb
CHANGED
data/test/minion_test.rb
CHANGED
@@ -11,7 +11,7 @@ class MinionTest < Minitest::Test
|
|
11
11
|
describe enabled ? 'enabled' : 'disabled' do
|
12
12
|
before do
|
13
13
|
ParallelMinion::Minion.enabled = enabled
|
14
|
-
$log_structs
|
14
|
+
$log_structs.clear
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'without parameters' do
|
@@ -73,12 +73,43 @@ class MinionTest < Minitest::Test
|
|
73
73
|
SemanticLogger.tagged('TAG') do
|
74
74
|
assert_equal 'TAG', SemanticLogger.tags.last
|
75
75
|
minion = ParallelMinion::Minion.new(description: 'Tag Test') do
|
76
|
+
logger.info "Tag Test"
|
76
77
|
logger.tags.last
|
77
78
|
end
|
78
79
|
end
|
79
80
|
assert_equal 'TAG', minion.result
|
80
81
|
end
|
81
82
|
|
83
|
+
it 'copy across named tags' do
|
84
|
+
minion = nil
|
85
|
+
SemanticLogger.named_tagged(tag: 'TAG') do
|
86
|
+
assert_equal({tag: 'TAG'}, SemanticLogger.named_tags)
|
87
|
+
minion = ParallelMinion::Minion.new(description: 'Named Tags Test') do
|
88
|
+
logger.info "Named Tags Test"
|
89
|
+
SemanticLogger.named_tags
|
90
|
+
end
|
91
|
+
end
|
92
|
+
assert_equal({tag: 'TAG'}, minion.result)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'copy across tags and named tags' do
|
96
|
+
minion = nil
|
97
|
+
SemanticLogger.tagged('TAG') do
|
98
|
+
SemanticLogger.named_tagged(tag: 'TAG') do
|
99
|
+
assert_equal({tag: 'TAG'}, SemanticLogger.named_tags)
|
100
|
+
assert_equal 'TAG', SemanticLogger.tags.last
|
101
|
+
minion = ParallelMinion::Minion.new(description: 'Tags Test') do
|
102
|
+
logger.info "Tags Test"
|
103
|
+
[SemanticLogger.named_tags, SemanticLogger.tags.last]
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_equal({tag: 'TAG'}, minion.result.first)
|
107
|
+
assert_equal 'TAG', minion.result.last
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
82
113
|
it 'include metric' do
|
83
114
|
metric_name = 'model/method'
|
84
115
|
hash = {value: 23}
|
data/test/test_db.sqlite3
CHANGED
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'parallel_minion'
|
@@ -8,6 +8,7 @@ SemanticLogger.default_level = :trace
|
|
8
8
|
SemanticLogger.add_appender(file_name: 'test.log', formatter: :color)
|
9
9
|
|
10
10
|
# Setup global callback for metric so that it can be tested below
|
11
|
+
$log_structs = []
|
11
12
|
SemanticLogger.on_metric do |log_struct|
|
12
|
-
|
13
|
+
$log_structs << log_struct.dup
|
13
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_minion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic_logger
|