solid_queue_autoscaler 1.0.3 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '047822a4b4205d1e4cf7da1e1f9210bb7ca84fe72f1309b0b32824cd7c6d44e5'
4
- data.tar.gz: 4282159caf6c8f4631ded2edee4545ea29e3af0b261fd98f61b61b07cb4930eb
3
+ metadata.gz: e3465a178ae32fa802b41eebff9cc3db372ce01a48c60b970d86e3b962a2c7e5
4
+ data.tar.gz: 29c4ab25bd35084109c5698ec432880932add84c49234d860ecb8ad6b652819c
5
5
  SHA512:
6
- metadata.gz: cc8f7375cd029e09b56aa8275c98e692a80f37bbe2f75aa4eb83d78b14e9d7d4b4a9d36a0e182e83e05b25ba9eb1c86c8f992e125bff7f5323206c9d34b9bed9
7
- data.tar.gz: 45e9928feb0afe9945902013e97b73122262cc927f89f9be687d2ac8ef94acc394b7262e93662a7082f3063f381d7b46775e7618f9e64b56490bbf579f70a521
6
+ metadata.gz: 7642cfc1b8a185eabbc61c716a118c94c47218c0b253e6ef670bb02caf279eda561b3c1a4d7c96ee0e2af93a1a09e8121c3fdf47995515ee0fd60c07b89c161a
7
+ data.tar.gz: cf02eea35fc5c03b0229d1a3c3cdbc32ead6e3e4dfe175f0fabcde7dd235ebb63cfad8a4d7ed6ca7ddb833bf1e6b3264090052a3d2591ab88802d4aafbc7ca78
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.5] - 2025-01-16
11
+
12
+ ### Added
13
+ - Auto-detect `SolidQueue::Record.connection` for multi-database setups
14
+ - No longer need to manually configure `database_connection` when using Solid Queue's separate database
15
+ - Connection priority: 1) explicit `database_connection`, 2) `SolidQueue::Record.connection`, 3) `ActiveRecord::Base.connection`
16
+
17
+ ## [1.0.4] - 2025-01-16
18
+
19
+ ### Fixed
20
+ - Fixed YAML syntax in README examples that caused parsing errors when users copied them
21
+ - Changed `args: [:all]` to block array syntax `args:\n - :all` to avoid YAML flow node parsing issues with symbols
22
+
10
23
  ## [1.0.3] - 2025-01-16
11
24
 
12
25
  ### Fixed
data/README.md CHANGED
@@ -193,6 +193,7 @@ The Kubernetes adapter uses the official `kubeclient` gem and supports:
193
193
  | `dry_run` | Boolean | `false` | Log decisions without making changes |
194
194
  | `queues` | Array | `nil` | Queue names to monitor (nil = all queues) |
195
195
  | `table_prefix` | String | `'solid_queue_'` | Solid Queue table name prefix |
196
+ | `database_connection` | Connection | auto | Database connection (auto-detects `SolidQueue::Record.connection`) |
196
197
 
197
198
  ### Worker Limits
198
199
 
@@ -273,20 +274,23 @@ autoscaler_all:
273
274
  class: SolidQueueAutoscaler::AutoscaleJob
274
275
  queue: autoscaler
275
276
  schedule: every 30 seconds
276
- args: [:all]
277
+ args:
278
+ - :all
277
279
 
278
280
  # Or scale specific worker types on different schedules
279
281
  autoscaler_critical:
280
282
  class: SolidQueueAutoscaler::AutoscaleJob
281
283
  queue: autoscaler
282
284
  schedule: every 15 seconds
283
- args: [:critical_worker]
285
+ args:
286
+ - :critical_worker
284
287
 
285
288
  autoscaler_default:
286
289
  class: SolidQueueAutoscaler::AutoscaleJob
287
290
  queue: autoscaler
288
291
  schedule: every 60 seconds
289
- args: [:default_worker]
292
+ args:
293
+ - :default_worker
290
294
  ```
291
295
 
292
296
  ### Running via Rake Tasks
@@ -110,7 +110,7 @@ module SolidQueueAutoscaler
110
110
  # Queue filtering (nil = all queues)
111
111
  @queues = nil
112
112
 
113
- # Database connection (defaults to ActiveRecord::Base.connection)
113
+ # Database connection (auto-detects SolidQueue::Record.connection if available)
114
114
  @database_connection = nil
115
115
 
116
116
  # Solid Queue table prefix (default: 'solid_queue_')
@@ -181,8 +181,20 @@ module SolidQueueAutoscaler
181
181
  scale_down_cooldown_seconds || cooldown_seconds
182
182
  end
183
183
 
184
+ # Returns the database connection for querying Solid Queue tables.
185
+ # Priority order:
186
+ # 1. Explicitly configured database_connection
187
+ # 2. SolidQueue::Record.connection (for multi-database setups)
188
+ # 3. ActiveRecord::Base.connection (fallback)
184
189
  def connection
185
- database_connection || ActiveRecord::Base.connection
190
+ return database_connection if database_connection
191
+
192
+ # Auto-detect Solid Queue's connection for multi-database setups
193
+ if defined?(SolidQueue::Record) && SolidQueue::Record.respond_to?(:connection)
194
+ return SolidQueue::Record.connection
195
+ end
196
+
197
+ ActiveRecord::Base.connection
186
198
  end
187
199
 
188
200
  def dry_run?
@@ -203,6 +215,12 @@ module SolidQueueAutoscaler
203
215
 
204
216
  def connection_available?
205
217
  return true if database_connection
218
+
219
+ # Check Solid Queue connection first (for multi-database setups)
220
+ if defined?(SolidQueue::Record) && SolidQueue::Record.respond_to?(:connected?)
221
+ return SolidQueue::Record.connected?
222
+ end
223
+
206
224
  return false unless defined?(ActiveRecord::Base)
207
225
 
208
226
  ActiveRecord::Base.connected?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidQueueAutoscaler
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_queue_autoscaler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - reillyse