postburner 1.0.0.pre.24 → 1.0.0.rc.1
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd9830a1ebdf2cded8cba28a7750c1610c75cba7c3954b8846c92eb7455fac64
|
|
4
|
+
data.tar.gz: 50c0d435d1f673bac9f5226c31672d78b7ef9c85453a276b72633f215f27d736
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a6522ef8f294e80abd08c401357cf1c0cff967d94cf7d09d84377cdf923c7734712329ef3039e8c51828e8936bea5bf8862cdbfe409b27700138f957c158282
|
|
7
|
+
data.tar.gz: 93806d46b3e1e0ef21ee01627d09ec97b7c092b65877b8d75756b227cb7c99771f4fcafe509997e40867557fa8ad0beb54f136e28c1f68d1da0aceef5328343a
|
|
@@ -5,15 +5,14 @@ module Postburner
|
|
|
5
5
|
# Handles execution of ActiveJob jobs from Beanstalkd payloads.
|
|
6
6
|
#
|
|
7
7
|
# Supports both default jobs (fast, no PostgreSQL) and tracked jobs
|
|
8
|
-
# (full audit trail). Also handles
|
|
9
|
-
# for backward compatibility.
|
|
8
|
+
# (full audit trail). Also handles native Postburner::Job format.
|
|
10
9
|
#
|
|
11
10
|
class Execution
|
|
12
11
|
class << self
|
|
13
12
|
# Executes a job from a Beanstalkd payload.
|
|
14
13
|
#
|
|
15
|
-
# Automatically detects payload type (default, tracked, or
|
|
16
|
-
# and routes to the appropriate execution path.
|
|
14
|
+
# Automatically detects payload type (default, tracked, or native
|
|
15
|
+
# Postburner::Job) and routes to the appropriate execution path.
|
|
17
16
|
#
|
|
18
17
|
# @param payload_json [String] JSON payload from Beanstalkd
|
|
19
18
|
#
|
|
@@ -24,8 +23,8 @@ module Postburner
|
|
|
24
23
|
def execute(payload_json, beanstalk_job: nil)
|
|
25
24
|
payload = Payload.parse(payload_json)
|
|
26
25
|
|
|
27
|
-
if Payload.
|
|
28
|
-
|
|
26
|
+
if Payload.native_format?(payload)
|
|
27
|
+
execute_native(payload, beanstalk_job: beanstalk_job)
|
|
29
28
|
elsif Payload.tracked?(payload)
|
|
30
29
|
execute_tracked(payload, beanstalk_job: beanstalk_job)
|
|
31
30
|
else
|
|
@@ -88,15 +87,15 @@ module Postburner
|
|
|
88
87
|
job.perform_now
|
|
89
88
|
end
|
|
90
89
|
|
|
91
|
-
# Executes a
|
|
90
|
+
# Executes a native Postburner::Job.
|
|
92
91
|
#
|
|
93
|
-
#
|
|
92
|
+
# Native format: { "class" => "JobClassName", "args" => [job_id] }
|
|
94
93
|
#
|
|
95
|
-
# @param payload [Hash] Parsed
|
|
94
|
+
# @param payload [Hash] Parsed native payload
|
|
96
95
|
#
|
|
97
96
|
# @return [void]
|
|
98
97
|
#
|
|
99
|
-
def
|
|
98
|
+
def execute_native(payload, beanstalk_job: nil)
|
|
100
99
|
job_class = payload['class'].constantize
|
|
101
100
|
job_id = payload['args'].first
|
|
102
101
|
|
|
@@ -145,17 +145,20 @@ module Postburner
|
|
|
145
145
|
payload['tracked'] == true || payload[:tracked] == true
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
# Detects if a parsed payload is
|
|
148
|
+
# Detects if a parsed payload is a native Postburner::Job format
|
|
149
|
+
# (as opposed to an ActiveJob adapter payload).
|
|
149
150
|
#
|
|
150
|
-
#
|
|
151
|
+
# Native format: { "class" => "JobClassName", "args" => [job_id] }
|
|
151
152
|
#
|
|
152
153
|
# @param payload [Hash] Parsed payload
|
|
153
154
|
#
|
|
154
|
-
# @return [Boolean] true if
|
|
155
|
+
# @return [Boolean] true if native Postburner::Job format
|
|
155
156
|
#
|
|
156
|
-
def
|
|
157
|
+
def native_format?(payload)
|
|
157
158
|
payload.key?('class') && payload.key?('args') && !payload.key?('v')
|
|
158
159
|
end
|
|
160
|
+
|
|
161
|
+
alias_method :legacy_format?, :native_format?
|
|
159
162
|
end
|
|
160
163
|
end
|
|
161
164
|
end
|
|
@@ -87,15 +87,15 @@ module Postburner
|
|
|
87
87
|
|
|
88
88
|
# Build job payload from a parsed Beanstalkd payload hash.
|
|
89
89
|
#
|
|
90
|
-
# Handles both ActiveJob format and
|
|
90
|
+
# Handles both ActiveJob format and native Postburner::Job format.
|
|
91
91
|
#
|
|
92
92
|
# @param payload [Hash] Parsed JSON payload from Beanstalkd
|
|
93
93
|
# @param beanstalk_job_id [Integer, nil] Beanstalkd job ID
|
|
94
94
|
# @return [Hash] Standardized job payload
|
|
95
95
|
#
|
|
96
96
|
def job_payload_from_hash(payload, beanstalk_job_id: nil)
|
|
97
|
-
if Postburner::ActiveJob::Payload.
|
|
98
|
-
#
|
|
97
|
+
if Postburner::ActiveJob::Payload.native_format?(payload)
|
|
98
|
+
# Native Postburner::Job format: { "class" => "JobClass", "args" => [id] }
|
|
99
99
|
{
|
|
100
100
|
class: payload['class'],
|
|
101
101
|
id: payload['args']&.first,
|
data/lib/postburner/version.rb
CHANGED
data/lib/postburner/worker.rb
CHANGED
|
@@ -260,7 +260,15 @@ module Postburner
|
|
|
260
260
|
logger.info "[Postburner::Worker] Mode: Single process (forks: 0)"
|
|
261
261
|
|
|
262
262
|
@gc_count = Concurrent::AtomicFixnum.new(0)
|
|
263
|
-
|
|
263
|
+
# gc_limit is disabled in single process mode — there is no parent process
|
|
264
|
+
# to restart the child, so exiting would rely on an external supervisor
|
|
265
|
+
# (Docker, systemd) to restart the entire process. Use forks: 1+ to enable
|
|
266
|
+
# gc_limit with automatic in-process restarts.
|
|
267
|
+
@gc_limit = nil
|
|
268
|
+
if worker_config[:gc_limit]
|
|
269
|
+
logger.debug "[Postburner::Worker] gc_limit disabled in single process mode" \
|
|
270
|
+
" (use forks: 1+ to enable)"
|
|
271
|
+
end
|
|
264
272
|
|
|
265
273
|
thread_count = worker_config[:threads]
|
|
266
274
|
@pool = Concurrent::FixedThreadPool.new(thread_count)
|
|
@@ -645,8 +653,8 @@ module Postburner
|
|
|
645
653
|
# @return [String] Human-readable job description
|
|
646
654
|
# @api private
|
|
647
655
|
def format_job_description(payload)
|
|
648
|
-
if Postburner::ActiveJob::Payload.
|
|
649
|
-
#
|
|
656
|
+
if Postburner::ActiveJob::Payload.native_format?(payload)
|
|
657
|
+
# Native Postburner::Job format: { "class" => "HeartbeatJob", "args" => [123] }
|
|
650
658
|
job_class = payload['class'] || 'UnknownJob'
|
|
651
659
|
job_id = payload['args']&.first
|
|
652
660
|
job_id ? "#{job_class}##{job_id}" : job_class
|
|
@@ -679,7 +687,7 @@ module Postburner
|
|
|
679
687
|
begin
|
|
680
688
|
payload = JSON.parse(beanstalk_job.body)
|
|
681
689
|
|
|
682
|
-
if payload['tracked'] || Postburner::ActiveJob::Payload.
|
|
690
|
+
if payload['tracked'] || Postburner::ActiveJob::Payload.native_format?(payload)
|
|
683
691
|
handle_postburner_job_error(beanstalk_job, payload, error)
|
|
684
692
|
else
|
|
685
693
|
handle_default_job_error(beanstalk_job, payload, error)
|
|
@@ -705,7 +713,7 @@ module Postburner
|
|
|
705
713
|
# @return [void]
|
|
706
714
|
# @api private
|
|
707
715
|
def handle_postburner_job_error(beanstalk_job, payload, error)
|
|
708
|
-
job_id = if Postburner::ActiveJob::Payload.
|
|
716
|
+
job_id = if Postburner::ActiveJob::Payload.native_format?(payload)
|
|
709
717
|
payload['args']&.first
|
|
710
718
|
else
|
|
711
719
|
payload['postburner_job_id']
|