solid_objects 0.14.4 → 0.14.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: 32207ee5017c24fa87258061048c532532bcf599d46357ce8da4deef8cb0c93e
4
- data.tar.gz: d5594c50173f64f96303e91b0bc0b0659335d42b0d16b4df1e6f618ad98041fc
3
+ metadata.gz: 45c9deb9d06f62e056668c5d3b547786ba69f9d866c302d850650d4ddeac7f9d
4
+ data.tar.gz: be67022b7559e87fa48adc91bc09466c005a77345e1631405cd4be76a038e8b5
5
5
  SHA512:
6
- metadata.gz: 6578fe32fed59a2c8fc6f4209244de1d33793561af20b258d96c8bd7c5cd78e7203fa08ebaea4a2c8315c89980bf4033852d00c3f4cadad3a6986c766dea7dad
7
- data.tar.gz: ec2db7a0481f6075ef9e1565a47f972bc41f6d464b65a7700139b4209636e079a254454007857ce7988fb1d01b745277a71a737d8f3e49f340e768106b511c38
6
+ metadata.gz: 43ad462709bbb061bc9aef103ce4bed2b9f5432c2efd507a743ccbdd33c255c7c4c8540d8d203baef62ef1c552ffd8e6978403c83a400fa99329be9cafbc44ed
7
+ data.tar.gz: 909192b9a0ca8674439e4ade94c09b6d0cd03b6cddc1082d2f55d02e0de41b27b64688bd1cb8c8af77febb5dd3a78241b656fa8d77a12942b3e1678b61450e37
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.5 - 2026-09-03
4
+
5
+ - Split broadcast claiming into separate pending and stale-processing probes,
6
+ then choose the oldest locked candidate across both. The old `OR` query made
7
+ MySQL, PostgreSQL, and SQLite collect and sort eligible rows before applying
8
+ `LIMIT 1`; each probe now follows the existing
9
+ `(status, available_at, id)` index while preserving delivery order, recovery,
10
+ and concurrent claimant safety. No migration or new index is required.
11
+
3
12
  ## 0.14.4 - 2026-08-30
4
13
 
5
14
  - Reuse the encoding the after image already built. `State#to_h` copies the
@@ -112,11 +112,15 @@ module SolidObjects
112
112
  database_adapter.transaction do
113
113
  now = database_adapter.database_now
114
114
  stale_at = now - SolidObjects.configuration.process_alive_threshold
115
- relation = Broadcast
116
- .where(status: "pending", available_at: ..now)
117
- .or(Broadcast.where(status: "processing", claimed_at: ..stale_at))
118
- .order(:available_at, :id)
119
- broadcast = database_adapter.lock_candidates(relation).first
115
+ pending_broadcast = claim_candidate(
116
+ Broadcast.where(status: "pending", available_at: ..now)
117
+ )
118
+ stale_broadcast = claim_candidate(
119
+ Broadcast.where(status: "processing", claimed_at: ..stale_at)
120
+ )
121
+ broadcast = [ pending_broadcast, stale_broadcast ]
122
+ .compact
123
+ .min_by { |candidate| [ candidate.available_at, candidate.id ] }
120
124
  next unless broadcast
121
125
 
122
126
  broadcast.update!(
@@ -129,6 +133,11 @@ module SolidObjects
129
133
  end
130
134
  end
131
135
 
136
+ # @rbs (ActiveRecord::Relation[Broadcast]) -> Broadcast?
137
+ def claim_candidate(relation)
138
+ database_adapter.lock_candidates(relation.order(:available_at, :id)).first
139
+ end
140
+
132
141
  # @rbs () -> Proc | ActionCableBroadcastAdapter
133
142
  def broadcast_adapter
134
143
  SolidObjects.configuration.broadcast_adapter ||
@@ -1,5 +1,5 @@
1
1
  # rbs_inline: enabled
2
2
 
3
3
  module SolidObjects
4
- VERSION = "0.14.4"
4
+ VERSION = "0.14.5"
5
5
  end
@@ -47,6 +47,9 @@ module SolidObjects
47
47
  # @rbs () -> Broadcast?
48
48
  def claim_next: () -> Broadcast?
49
49
 
50
+ # @rbs (ActiveRecord::Relation[Broadcast]) -> Broadcast?
51
+ def claim_candidate: (ActiveRecord::Relation[Broadcast]) -> Broadcast?
52
+
50
53
  # @rbs () -> Proc | ActionCableBroadcastAdapter
51
54
  def broadcast_adapter: () -> Proc
52
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-30 00:00:00.000000000 Z
11
+ date: 2026-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable