joblin 0.1.7 → 0.1.8
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/joblin/batching/batch.rb +9 -0
- data/lib/joblin/batching/callback.rb +8 -4
- data/lib/joblin/batching/compat/active_job.rb +4 -0
- data/lib/joblin/batching/compat/sidekiq.rb +2 -0
- data/lib/joblin/batching/context_hash.rb +6 -0
- data/lib/joblin/batching/jobs/managed_batch_job.rb +2 -1
- data/lib/joblin/version.rb +1 -1
- data/spec/internal/log/test.log +3026 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02c41b7e3748391c7d5c36103ead3ffb33e7909177a33c60152d09aca5dda958
|
|
4
|
+
data.tar.gz: bb14374eea4fb7a4b23d66a6753af68a962af0708f9f061ea4042edc010bef51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 132d951a8a4c8be1fa526566f65c651883c45e621acb38034fdb581034ade56f9292b80c710196be0b6ca87cd535f07c0e065d7f17398c2772c9a380bd51ca36
|
|
7
|
+
data.tar.gz: 74fad3df093c9b1bcc3c547f821d727d6873827e77fa01c5578994e9b8cd390fbdb2759bc48476682806900577cf1503606cda83094471730fdcdfef0e1e01a8
|
|
@@ -257,6 +257,15 @@ module Joblin::Batching
|
|
|
257
257
|
current&.context || {}
|
|
258
258
|
end
|
|
259
259
|
|
|
260
|
+
def apply_apm_tags!
|
|
261
|
+
if defined?(Sentry)
|
|
262
|
+
scope = Sentry.get_current_scope
|
|
263
|
+
scope.set_tags({
|
|
264
|
+
"joblin.batch_id" => current.bid,
|
|
265
|
+
})
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
260
269
|
# Perform a success/failure/complete/etc transaction against Redis, checking
|
|
261
270
|
# if any callbacks should be triggered
|
|
262
271
|
def with_callback_check(bid, except: [], only: Callback::VALID_CALLBACKS, &blk)
|
|
@@ -3,6 +3,8 @@ module Joblin::Batching
|
|
|
3
3
|
module Callback
|
|
4
4
|
mattr_accessor :worker_class
|
|
5
5
|
|
|
6
|
+
CLEANUP_STAGNATED_BATCHES = false
|
|
7
|
+
|
|
6
8
|
VALID_CALLBACKS = %i[success complete death stagnated].freeze
|
|
7
9
|
|
|
8
10
|
module CallbackWorkerCommon
|
|
@@ -56,18 +58,20 @@ module Joblin::Batching
|
|
|
56
58
|
r.srem("BID-#{bid}-pending_callbacks", "#{event}-finalize")
|
|
57
59
|
end
|
|
58
60
|
|
|
59
|
-
if
|
|
61
|
+
# This is a callback for a callback. In this case we need to check if we should cleanup the original bid.
|
|
62
|
+
if event == :success || (CLEANUP_STAGNATED_BATCHES && event == :stagnated)
|
|
60
63
|
if opts['origin'].present?
|
|
61
|
-
# This is a callback for a callback. In this case we need to check if we should cleanup the original bid.
|
|
62
64
|
origin_bid = opts['origin']['for_bid']
|
|
63
|
-
_, pending, success_ran = Batch.redis do |r|
|
|
65
|
+
_, pending, success_ran, stagnated_ran = Batch.redis do |r|
|
|
64
66
|
r.multi do |r|
|
|
65
67
|
r.srem("BID-#{origin_bid}-pending_callbacks", opts['origin']['event'])
|
|
66
68
|
r.scard("BID-#{origin_bid}-pending_callbacks")
|
|
67
69
|
r.hget("BID-#{origin_bid}", "success")
|
|
70
|
+
r.hget("BID-#{origin_bid}", "stagnated")
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
|
-
|
|
73
|
+
|
|
74
|
+
Batch.cleanup_redis(origin_bid) if pending == 0 && (success_ran == 'true' || (stagnated_ran == 'true' && CLEANUP_STAGNATED_BATCHES))
|
|
71
75
|
end
|
|
72
76
|
|
|
73
77
|
if (Batch.redis {|r| r.scard("BID-#{bid}-pending_callbacks") }) == 0
|
|
@@ -64,6 +64,7 @@ module Joblin::Batching
|
|
|
64
64
|
prev_batch = Thread.current[CURRENT_BATCH_THREAD_KEY]
|
|
65
65
|
begin
|
|
66
66
|
Thread.current[CURRENT_BATCH_THREAD_KEY] = Batch.new(bid)
|
|
67
|
+
Batch.apply_apm_tags!
|
|
67
68
|
yield
|
|
68
69
|
Thread.current[CURRENT_BATCH_THREAD_KEY].save_context_changes
|
|
69
70
|
Batch.process_successful_job(bid, msg['jid'])
|
|
@@ -74,6 +75,7 @@ module Joblin::Batching
|
|
|
74
75
|
Thread.current[CURRENT_BATCH_THREAD_KEY] = prev_batch
|
|
75
76
|
end
|
|
76
77
|
else
|
|
78
|
+
Batch.apply_apm_tags!
|
|
77
79
|
yield
|
|
78
80
|
end
|
|
79
81
|
end
|
|
@@ -2,7 +2,7 @@ require_relative './base_job'
|
|
|
2
2
|
|
|
3
3
|
module Joblin::Batching
|
|
4
4
|
class ManagedBatchJob < BaseJob
|
|
5
|
-
def self.make_batch(sub_jobs, ordered: true, concurrency: nil, context: nil, preflight_check: nil, desc_prefix: nil, &blk)
|
|
5
|
+
def self.make_batch(sub_jobs, ordered: true, concurrency: nil, context: nil, preflight_check: nil, description: nil, desc_prefix: nil, &blk)
|
|
6
6
|
desc_prefix ||= ''
|
|
7
7
|
|
|
8
8
|
if concurrency == 0 || concurrency == nil || concurrency == true
|
|
@@ -46,6 +46,7 @@ module Joblin::Batching
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
root_batch.context = context
|
|
49
|
+
root_batch.description = description if description.present?
|
|
49
50
|
|
|
50
51
|
blk.call(ManagedBatchProxy.new(root_batch)) if blk.present?
|
|
51
52
|
|
data/lib/joblin/version.rb
CHANGED