postburner 0.9.0.rc.1 → 1.0.0.pre.2
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/README.md +1082 -507
- data/app/models/postburner/job.rb +163 -39
- data/app/models/postburner/tracked_job.rb +83 -0
- data/bin/postburner +91 -0
- data/bin/rails +14 -0
- data/config/environment.rb +3 -0
- data/config/postburner.yml +22 -0
- data/config/postburner.yml.example +142 -0
- data/lib/generators/postburner/install/install_generator.rb +10 -0
- data/lib/generators/postburner/install/templates/config/postburner.yml +142 -0
- data/lib/postburner/active_job/adapter.rb +176 -0
- data/lib/postburner/active_job/execution.rb +109 -0
- data/lib/postburner/active_job/payload.rb +157 -0
- data/lib/postburner/beanstalkd.rb +97 -0
- data/lib/postburner/configuration.rb +202 -0
- data/lib/postburner/connection.rb +113 -0
- data/lib/postburner/engine.rb +1 -1
- data/lib/postburner/queue_config.rb +151 -0
- data/lib/postburner/strategies/queue.rb +20 -6
- data/lib/postburner/tracked.rb +171 -0
- data/lib/postburner/version.rb +1 -1
- data/lib/postburner/workers/base.rb +210 -0
- data/lib/postburner/workers/worker.rb +480 -0
- data/lib/postburner.rb +78 -7
- metadata +44 -11
data/lib/postburner.rb
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
require "postburner/version"
|
|
2
|
+
require "postburner/configuration"
|
|
3
|
+
require "postburner/connection"
|
|
4
|
+
require "postburner/queue_config"
|
|
5
|
+
require "postburner/beanstalkd"
|
|
6
|
+
require "postburner/tracked"
|
|
7
|
+
require "postburner/active_job/payload"
|
|
8
|
+
require "postburner/active_job/execution"
|
|
9
|
+
require "postburner/active_job/adapter"
|
|
10
|
+
require "postburner/workers/base"
|
|
11
|
+
require "postburner/workers/worker"
|
|
2
12
|
require "postburner/engine"
|
|
3
13
|
require "postburner/strategies/queue"
|
|
4
14
|
require "postburner/strategies/nice_queue"
|
|
@@ -294,12 +304,12 @@ module Postburner
|
|
|
294
304
|
|
|
295
305
|
# Returns a cached Beanstalkd connection.
|
|
296
306
|
#
|
|
297
|
-
# Creates a new {
|
|
307
|
+
# Creates a new {Postburner::Connection} using the configured Beanstalkd
|
|
298
308
|
# URL and caches it. Automatically reconnects if the connection is stale.
|
|
299
309
|
#
|
|
300
310
|
# For most use cases, prefer {#connected} which handles connection cleanup.
|
|
301
311
|
#
|
|
302
|
-
# @return [
|
|
312
|
+
# @return [Postburner::Connection] Beanstalkd connection object
|
|
303
313
|
#
|
|
304
314
|
# @raise [Beaneater::NotConnected] if connection fails
|
|
305
315
|
#
|
|
@@ -313,9 +323,7 @@ module Postburner
|
|
|
313
323
|
# @see #connected
|
|
314
324
|
#
|
|
315
325
|
def self.connection
|
|
316
|
-
@_connection ||=
|
|
317
|
-
Backburner.configuration.beanstalk_url
|
|
318
|
-
)
|
|
326
|
+
@_connection ||= Postburner::Connection.new
|
|
319
327
|
@_connection.reconnect! unless @_connection.connected?
|
|
320
328
|
@_connection
|
|
321
329
|
end
|
|
@@ -328,11 +336,11 @@ module Postburner
|
|
|
328
336
|
#
|
|
329
337
|
# @overload connected
|
|
330
338
|
# Returns the cached Beanstalkd connection.
|
|
331
|
-
# @return [
|
|
339
|
+
# @return [Postburner::Connection] Beanstalkd connection
|
|
332
340
|
#
|
|
333
341
|
# @overload connected {|conn| ... }
|
|
334
342
|
# Yields connection and ensures cleanup.
|
|
335
|
-
# @yieldparam conn [
|
|
343
|
+
# @yieldparam conn [Postburner::Connection] Beanstalkd connection
|
|
336
344
|
# @return [void]
|
|
337
345
|
#
|
|
338
346
|
# @example With block (recommended)
|
|
@@ -387,4 +395,67 @@ module Postburner
|
|
|
387
395
|
|
|
388
396
|
# TODO
|
|
389
397
|
end
|
|
398
|
+
|
|
399
|
+
# Returns array of watched tube names with environment prefix.
|
|
400
|
+
#
|
|
401
|
+
# Expands configured queue names to full tube names and memoizes the result.
|
|
402
|
+
#
|
|
403
|
+
# @return [Array<String>] Array of expanded tube names
|
|
404
|
+
#
|
|
405
|
+
# @example
|
|
406
|
+
# Postburner.watched_tube_names
|
|
407
|
+
# # => ['postburner.production.default', 'postburner.production.critical']
|
|
408
|
+
#
|
|
409
|
+
def self.watched_tube_names
|
|
410
|
+
@__watched_tube_names ||= configuration.queue_names.map { |q| configuration.expand_tube_name(q) }
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
# Returns array of watched Beaneater::Tube instances.
|
|
414
|
+
#
|
|
415
|
+
# Creates Beaneater tube instances for all configured queues and memoizes the result.
|
|
416
|
+
#
|
|
417
|
+
# @return [Array<Beaneater::Tube>] Array of tube instances
|
|
418
|
+
#
|
|
419
|
+
# @example
|
|
420
|
+
# Postburner.watched_tubes.each { |tube| puts tube.stats }
|
|
421
|
+
#
|
|
422
|
+
def self.watched_tubes
|
|
423
|
+
@__watched_tubes ||= watched_tube_names.map { |tube_name| connection.tubes[tube_name] }
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# Returns statistics and introspection data about Beanstalkd and configured queues.
|
|
427
|
+
#
|
|
428
|
+
# Provides Beaneater tube instances for configured tubes and all tubes that exist
|
|
429
|
+
# on the Beanstalkd server. Tube instances support introspection methods:
|
|
430
|
+
#
|
|
431
|
+
# - tube.name - Tube name
|
|
432
|
+
# - tube.stats - Tube statistics hash (current-jobs-ready, current-jobs-buried, etc.)
|
|
433
|
+
# - tube.peek_ready - Next ready job
|
|
434
|
+
# - tube.peek_delayed - Next delayed job
|
|
435
|
+
# - tube.peek_buried - Next buried job
|
|
436
|
+
# - tube.kick(n) - Kick n buried jobs back to ready
|
|
437
|
+
# - tube.pause(delay) - Pause tube for delay seconds
|
|
438
|
+
# - tube.clear - Delete all jobs in tube
|
|
439
|
+
#
|
|
440
|
+
# @return [Hash] Statistics hash with the following keys:
|
|
441
|
+
# - watched_tubes: Array of configured/watched Beaneater::Tube instances
|
|
442
|
+
# - tubes: Array of all Beaneater::Tube instances on the server
|
|
443
|
+
#
|
|
444
|
+
# @raise [Beaneater::NotConnected] if connection to Beanstalkd fails
|
|
445
|
+
#
|
|
446
|
+
# @example
|
|
447
|
+
# stats = Postburner.stats
|
|
448
|
+
# stats[:watched_tubes].each { |tube| puts "#{tube.name}: #{tube.stats}" }
|
|
449
|
+
# stats[:tubes].first.peek_ready
|
|
450
|
+
#
|
|
451
|
+
def self.stats
|
|
452
|
+
connected do |conn|
|
|
453
|
+
|
|
454
|
+
{
|
|
455
|
+
watched_tubes: self.watched_tubes,
|
|
456
|
+
# Get all tube instances that exist on Beanstalkd
|
|
457
|
+
tubes: conn.beanstalk.tubes.all
|
|
458
|
+
}
|
|
459
|
+
end
|
|
460
|
+
end
|
|
390
461
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: postburner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0.pre.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Smith
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -24,19 +24,19 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '7.2'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
27
|
+
name: beaneater
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- - "
|
|
30
|
+
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 1.
|
|
32
|
+
version: '1.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- - "
|
|
37
|
+
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 1.
|
|
39
|
+
version: '1.0'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: pg
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -79,10 +79,27 @@ dependencies:
|
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: 2.0.1
|
|
82
|
-
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: concurrent-ruby
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '1.2'
|
|
89
|
+
type: :runtime
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '1.2'
|
|
96
|
+
description: 'Fast Beanstalkd-backed job queue with optional PostgreSQL audit trail.
|
|
97
|
+
Dual-mode execution: lite jobs (Beanstalkd only) or tracked jobs (full audit with
|
|
98
|
+
logs, timing, errors).'
|
|
83
99
|
email:
|
|
84
100
|
- matt@nearapogee.com
|
|
85
|
-
executables:
|
|
101
|
+
executables:
|
|
102
|
+
- postburner
|
|
86
103
|
extensions: []
|
|
87
104
|
extra_rdoc_files: []
|
|
88
105
|
files:
|
|
@@ -102,23 +119,39 @@ files:
|
|
|
102
119
|
- app/models/postburner/application_record.rb
|
|
103
120
|
- app/models/postburner/job.rb
|
|
104
121
|
- app/models/postburner/mailer.rb
|
|
122
|
+
- app/models/postburner/tracked_job.rb
|
|
105
123
|
- app/views/layouts/postburner/application.html.haml
|
|
106
124
|
- app/views/postburner/jobs/index.html.haml
|
|
107
125
|
- app/views/postburner/jobs/show.html.haml
|
|
126
|
+
- bin/postburner
|
|
127
|
+
- bin/rails
|
|
108
128
|
- config/environment.rb
|
|
129
|
+
- config/postburner.yml
|
|
130
|
+
- config/postburner.yml.example
|
|
109
131
|
- config/routes.rb
|
|
110
132
|
- lib/generators/postburner/install/USAGE
|
|
111
133
|
- lib/generators/postburner/install/install_generator.rb
|
|
134
|
+
- lib/generators/postburner/install/templates/config/postburner.yml
|
|
112
135
|
- lib/generators/postburner/install/templates/migrations/create_postburner_jobs.rb.erb
|
|
113
136
|
- lib/postburner.rb
|
|
137
|
+
- lib/postburner/active_job/adapter.rb
|
|
138
|
+
- lib/postburner/active_job/execution.rb
|
|
139
|
+
- lib/postburner/active_job/payload.rb
|
|
140
|
+
- lib/postburner/beanstalkd.rb
|
|
141
|
+
- lib/postburner/configuration.rb
|
|
142
|
+
- lib/postburner/connection.rb
|
|
114
143
|
- lib/postburner/engine.rb
|
|
144
|
+
- lib/postburner/queue_config.rb
|
|
115
145
|
- lib/postburner/strategies/immediate_test_queue.rb
|
|
116
146
|
- lib/postburner/strategies/nice_queue.rb
|
|
117
147
|
- lib/postburner/strategies/null_queue.rb
|
|
118
148
|
- lib/postburner/strategies/queue.rb
|
|
119
149
|
- lib/postburner/strategies/test_queue.rb
|
|
120
150
|
- lib/postburner/time_helpers.rb
|
|
151
|
+
- lib/postburner/tracked.rb
|
|
121
152
|
- lib/postburner/version.rb
|
|
153
|
+
- lib/postburner/workers/base.rb
|
|
154
|
+
- lib/postburner/workers/worker.rb
|
|
122
155
|
- lib/tasks/postburner_tasks.rake
|
|
123
156
|
homepage: https://gitlab.nearapogee.com/opensource/postburner
|
|
124
157
|
licenses:
|
|
@@ -141,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
174
|
- !ruby/object:Gem::Version
|
|
142
175
|
version: '0'
|
|
143
176
|
requirements: []
|
|
144
|
-
rubygems_version: 3.6.
|
|
177
|
+
rubygems_version: 3.6.9
|
|
145
178
|
specification_version: 4
|
|
146
|
-
summary:
|
|
179
|
+
summary: PostgreSQL-backed job queue with optional audit trail for ActiveJob
|
|
147
180
|
test_files: []
|