pgbus 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/pgbus/client.rb +26 -0
- data/lib/pgbus/process/supervisor.rb +11 -0
- data/lib/pgbus/version.rb +1 -1
- 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: fea599f69fd2b216ca1f805da2e72ec594080b02f3ae4c17cb2fe6e7fd0e3359
|
|
4
|
+
data.tar.gz: b03a0bfa5448819822ced10c02de6e14cdacff982f29e7d69234a64dc4b50310
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97b31599de64e76a125f06f1aae701f23fd7177213f3fc90622aefbe4eb484740b52cde1fae04c85428386fd637d6bd32cd16032ecb130455212fb1bd7408c18
|
|
7
|
+
data.tar.gz: 5032cf8a4d1781d162761674496724311589b1897785c2dc90473d7f7264f3d05784c4a6ecbd6de01daa630432b9ba46dbc0f839dd86850ccd2caf10993a3540
|
data/lib/pgbus/client.rb
CHANGED
|
@@ -42,6 +42,12 @@ module Pgbus
|
|
|
42
42
|
"PGMQ schema is not available (#{e.message}). Run `rails db:migrate` for the pgbus database."
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def ensure_all_queues
|
|
46
|
+
queue_names = collect_configured_queues
|
|
47
|
+
Pgbus.logger.info { "[Pgbus] Bootstrapping #{queue_names.size} queue(s): #{queue_names.join(", ")}" }
|
|
48
|
+
queue_names.each { |name| ensure_queue(name) }
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
def ensure_dead_letter_queue(name)
|
|
46
52
|
dlq_name = config.dead_letter_queue_name(name)
|
|
47
53
|
return if @queues_created[dlq_name]
|
|
@@ -228,6 +234,26 @@ module Pgbus
|
|
|
228
234
|
|
|
229
235
|
private
|
|
230
236
|
|
|
237
|
+
def collect_configured_queues
|
|
238
|
+
queues = Set.new
|
|
239
|
+
queues << config.default_queue
|
|
240
|
+
|
|
241
|
+
# Queues from worker configs
|
|
242
|
+
(config.workers || []).each do |w|
|
|
243
|
+
worker_queues = w[:queues] || w["queues"] || [config.default_queue]
|
|
244
|
+
worker_queues.each { |q| queues << q unless q == "*" }
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Queues from recurring tasks
|
|
248
|
+
(config.recurring_tasks || {}).each_value do |opts|
|
|
249
|
+
opts = opts.transform_keys(&:to_s) if opts.is_a?(Hash)
|
|
250
|
+
queue = opts["queue"] || opts[:queue]
|
|
251
|
+
queues << queue if queue
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
queues.to_a
|
|
255
|
+
end
|
|
256
|
+
|
|
231
257
|
def ensure_single_queue(full_name)
|
|
232
258
|
return if @queues_created[full_name]
|
|
233
259
|
|
|
@@ -42,6 +42,11 @@ module Pgbus
|
|
|
42
42
|
private
|
|
43
43
|
|
|
44
44
|
def boot_processes
|
|
45
|
+
# Bootstrap all configured queues before forking workers.
|
|
46
|
+
# Without this, workers start reading from non-existent queues
|
|
47
|
+
# and recurring task enqueues fail.
|
|
48
|
+
bootstrap_queues
|
|
49
|
+
|
|
45
50
|
# Boot workers
|
|
46
51
|
config.workers.each do |worker_config|
|
|
47
52
|
fork_worker(worker_config)
|
|
@@ -280,6 +285,12 @@ module Pgbus
|
|
|
280
285
|
end
|
|
281
286
|
end
|
|
282
287
|
|
|
288
|
+
def bootstrap_queues
|
|
289
|
+
Pgbus.client.ensure_all_queues
|
|
290
|
+
rescue StandardError => e
|
|
291
|
+
Pgbus.logger.error { "[Pgbus] Failed to bootstrap queues: #{e.message}" }
|
|
292
|
+
end
|
|
293
|
+
|
|
283
294
|
def load_rails_app
|
|
284
295
|
return unless defined?(Rails)
|
|
285
296
|
|
data/lib/pgbus/version.rb
CHANGED