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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ec6fafacfe5cf2b3e090a1e1ed733fd6c3bc33
4
- data.tar.gz: a054a763962d6ee10fb8bc75587ec4d1c5f3d456
3
+ metadata.gz: ec80ef2321aa78ba6f8b6dc7b16452f1ccb15a9b
4
+ data.tar.gz: f3a394698da183ce6e64c8137ac7cf50cae98943
5
5
  SHA512:
6
- metadata.gz: 13909e2ad5221826dd9ac6cbbd15364566e4cf6b76fc33bc77d7cc8c35acc6ddb06cc3b53845bb6df053b031a13fb20808ce10c7e2f7bbb141912e2a86a03aff
7
- data.tar.gz: 01b7b72f77160109e4bfa9ab995c6f98be128a7e837bc284d3932f399cdae9389b866d83a534d5ec618425c201d3607d5ff19b06bf803a3054da4edc409bcaa5
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
- proc = Proc.new { run_in_scope(scopes, &block) }
317
- proc2 = tags ? Proc.new { SemanticLogger.tagged(*tags, &proc) } : proc
318
- proc3 = named_tags ? Proc.new { SemanticLogger.named_tagged(named_tags, &proc2) } : proc2
319
-
320
- logger.public_send(self.class.started_log_level, "Started #{description}")
321
- begin
322
- logger.measure(self.class.completed_log_level, "Completed #{description}", log_exception: log_exception, metric: metric, &proc3)
323
- rescue Exception => exc
324
- @exception = exc
325
- nil
326
- ensure
327
- @duration = Time.now - start_time
328
- # Return any database connections used by this thread back to the pool
329
- ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
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
@@ -1,3 +1,3 @@
1
1
  module ParallelMinion #:nodoc
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -1,4 +1,4 @@
1
- require_relative './test_helper'
1
+ require_relative 'test_helper'
2
2
  require 'erb'
3
3
  require 'active_record'
4
4
 
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
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
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
- ($log_structs ||= []) << log_struct.dup
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.0
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-03-24 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic_logger