pgbus 0.2.4 → 0.2.5
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/app/controllers/pgbus/application_controller.rb +5 -2
- data/app/models/pgbus/application_record.rb +4 -1
- data/app/models/pgbus/batch_entry.rb +1 -1
- data/app/models/pgbus/blocked_execution.rb +1 -1
- data/app/models/pgbus/job_lock.rb +1 -1
- data/app/models/pgbus/job_stat.rb +1 -1
- data/app/models/pgbus/outbox_entry.rb +1 -1
- data/app/models/pgbus/process_entry.rb +1 -1
- data/app/models/pgbus/processed_event.rb +1 -1
- data/app/models/pgbus/queue_state.rb +1 -1
- data/app/models/pgbus/recurring_execution.rb +1 -1
- data/app/models/pgbus/recurring_task.rb +1 -1
- data/app/models/pgbus/semaphore.rb +1 -1
- data/lib/pgbus/bus_record.rb +16 -0
- data/lib/pgbus/configuration.rb +1 -1
- data/lib/pgbus/engine.rb +1 -1
- data/lib/pgbus/process/consumer_priority.rb +1 -1
- data/lib/pgbus/process/dispatcher.rb +1 -1
- data/lib/pgbus/process/queue_lock.rb +1 -1
- data/lib/pgbus/process/worker.rb +1 -1
- data/lib/pgbus/version.rb +1 -1
- data/lib/pgbus/web/data_source.rb +1 -1
- data/lib/pgbus.rb +4 -0
- data/lib/tasks/pgbus_pgmq.rake +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cfd2ea5ccec3e3715dbcf2dd409a652527cf1d9e18c60fe4d5797fd5cf5be6ec
|
|
4
|
+
data.tar.gz: 6983d4977aeb792ba0857884752a8b662a15164cde8cd6ee3bb5406d95d7f225
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6f3e19f1e3fe2d5eae02fe52dcd2878f5bbcb13cd7387a41b3902ad91cb8c20ce2d1e3c606488bdce1c901126d1192f7a34747e8746c397d016d0c2541a8828
|
|
7
|
+
data.tar.gz: da5ed5a1a2012d757547e3e2f1f48586a84e7d096df91a793d9ba18f76da881e52dab650d4fb3c605c4da6de06b1e8b58b0d11c99bd90e30ef64b3c368c44093
|
|
@@ -57,8 +57,11 @@ module Pgbus
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def available_locales
|
|
60
|
-
@available_locales ||=
|
|
61
|
-
|
|
60
|
+
@available_locales ||= begin
|
|
61
|
+
pgbus_locales = Dir[Pgbus::Engine.root.join("config", "locales", "*.yml")]
|
|
62
|
+
.map { |f| File.basename(f, ".yml").to_sym }
|
|
63
|
+
pgbus_locales & I18n.available_locales
|
|
64
|
+
end
|
|
62
65
|
end
|
|
63
66
|
helper_method :available_locales
|
|
64
67
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Pgbus
|
|
4
|
-
|
|
4
|
+
# Backward-compatible alias — host apps that subclassed
|
|
5
|
+
# Pgbus::ApplicationRecord will continue to work.
|
|
6
|
+
# New code should inherit from Pgbus::BusRecord directly.
|
|
7
|
+
class ApplicationRecord < BusRecord
|
|
5
8
|
self.abstract_class = true
|
|
6
9
|
end
|
|
7
10
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_record"
|
|
4
|
+
|
|
5
|
+
module Pgbus
|
|
6
|
+
# Base class for all Pgbus ActiveRecord models.
|
|
7
|
+
#
|
|
8
|
+
# Lives in lib/pgbus/ so the main Zeitwerk gem loader picks it up
|
|
9
|
+
# regardless of Rails engine boot order. This avoids the NameError
|
|
10
|
+
# that occurs when a host app uses selective railtie requires
|
|
11
|
+
# (require "rails" + individual railties instead of require "rails/all")
|
|
12
|
+
# and the engine's app/models path isn't registered yet.
|
|
13
|
+
class BusRecord < ActiveRecord::Base
|
|
14
|
+
self.abstract_class = true
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/pgbus/configuration.rb
CHANGED
|
@@ -201,7 +201,7 @@ module Pgbus
|
|
|
201
201
|
connection_params
|
|
202
202
|
elsif defined?(ActiveRecord::Base)
|
|
203
203
|
if connects_to
|
|
204
|
-
-> { Pgbus::
|
|
204
|
+
-> { Pgbus::BusRecord.connection.raw_connection }
|
|
205
205
|
else
|
|
206
206
|
-> { ActiveRecord::Base.connection.raw_connection }
|
|
207
207
|
end
|
data/lib/pgbus/engine.rb
CHANGED
|
@@ -27,7 +27,7 @@ module Pgbus
|
|
|
27
27
|
|
|
28
28
|
initializer "pgbus.db" do
|
|
29
29
|
ActiveSupport.on_load(:active_record) do
|
|
30
|
-
Pgbus::
|
|
30
|
+
Pgbus::BusRecord.connects_to(**Pgbus.configuration.connects_to) if Pgbus.configuration.connects_to
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -27,7 +27,7 @@ module Pgbus
|
|
|
27
27
|
# that share at least one queue with the given queue list,
|
|
28
28
|
# excluding the current worker (by PID).
|
|
29
29
|
def self.max_active_priority(queues, my_pid)
|
|
30
|
-
conn = Pgbus.configuration.connects_to ? Pgbus::
|
|
30
|
+
conn = Pgbus.configuration.connects_to ? Pgbus::BusRecord.connection : ActiveRecord::Base.connection
|
|
31
31
|
rows = conn.select_all(
|
|
32
32
|
"SELECT metadata FROM pgbus_processes WHERE kind = 'worker' AND pid != $1 AND last_heartbeat_at > $2",
|
|
33
33
|
"Pgbus ConsumerPriority",
|
|
@@ -180,7 +180,7 @@ module Pgbus
|
|
|
180
180
|
batch_size = config.archive_compaction_batch_size || 1000
|
|
181
181
|
prefix = config.queue_prefix
|
|
182
182
|
|
|
183
|
-
conn = config.connects_to ? Pgbus::
|
|
183
|
+
conn = config.connects_to ? Pgbus::BusRecord.connection : ActiveRecord::Base.connection
|
|
184
184
|
queue_names = conn.select_values("SELECT queue_name FROM pgmq.meta ORDER BY queue_name")
|
|
185
185
|
|
|
186
186
|
queue_names.each do |full_name|
|
data/lib/pgbus/process/worker.rb
CHANGED
|
@@ -191,7 +191,7 @@ module Pgbus
|
|
|
191
191
|
dlq_suffix = config.dead_letter_queue_suffix
|
|
192
192
|
prefix = "#{config.queue_prefix}_"
|
|
193
193
|
|
|
194
|
-
conn = Pgbus.configuration.connects_to ? Pgbus::
|
|
194
|
+
conn = Pgbus.configuration.connects_to ? Pgbus::BusRecord.connection : ActiveRecord::Base.connection
|
|
195
195
|
all_queues = conn.select_values("SELECT queue_name FROM pgmq.meta ORDER BY queue_name")
|
|
196
196
|
resolved = all_queues
|
|
197
197
|
.reject { |q| q.end_with?(dlq_suffix) }
|
data/lib/pgbus/version.rb
CHANGED
data/lib/pgbus.rb
CHANGED
data/lib/tasks/pgbus_pgmq.rake
CHANGED
|
@@ -12,7 +12,7 @@ namespace :pgbus do
|
|
|
12
12
|
latest = Pgbus::PgmqSchema.latest_version
|
|
13
13
|
puts "Vendored version: #{latest}"
|
|
14
14
|
|
|
15
|
-
conn = Pgbus.configuration.connects_to ? Pgbus::
|
|
15
|
+
conn = Pgbus.configuration.connects_to ? Pgbus::BusRecord.connection : ActiveRecord::Base.connection
|
|
16
16
|
|
|
17
17
|
if conn.table_exists?("pgbus_pgmq_schema_versions")
|
|
18
18
|
row = conn.select_one(
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgbus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikael Henriksson
|
|
@@ -211,6 +211,7 @@ files:
|
|
|
211
211
|
- lib/pgbus/active_job/adapter.rb
|
|
212
212
|
- lib/pgbus/active_job/executor.rb
|
|
213
213
|
- lib/pgbus/batch.rb
|
|
214
|
+
- lib/pgbus/bus_record.rb
|
|
214
215
|
- lib/pgbus/circuit_breaker.rb
|
|
215
216
|
- lib/pgbus/cli.rb
|
|
216
217
|
- lib/pgbus/client.rb
|