tina4ruby 3.13.96 → 3.13.97

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: 03c4fdd796ea815b87db64ddfcdbfb640ab0c581b5b224b691994cacde2e6a0c
4
- data.tar.gz: 504966fa78530e347b4306b54ce3e353e950bf66af96ec13412a9100a371d108
3
+ metadata.gz: cc06b125fb780e5f4703244636215011a65c6ee220081fcd02b4f73fa37db06c
4
+ data.tar.gz: a4ebef28a619dff925c104eb3e93c0632cf9cf47c9f84d15aff0c1658345eae0
5
5
  SHA512:
6
- metadata.gz: ff853a253a55c4cb93649f0f6b23d15c707a5f6e207acc36cfbf31560cd5c01d1937f696c633b6f86cde279caf7f9fdc8498a2d0a0da6cb1b7144a4dcabaad7d
7
- data.tar.gz: 57f7c58bee9776ffc0cd28010380842064b987188f8b16bf291fb91fc820ffb23186c6bee73b363ffb4eaf20d67d9372330b7afbe979f4697543d991bf5a73c8
6
+ metadata.gz: e3e081993e4da7a7ba4fd6fdd487ed06428bb5ccc7cd212dcee1e50ff309cfe30c342f14b4d17c4208067a558f089bc5300d4f6ee219967497dd43a17baa357a
7
+ data.tar.gz: 5a6123804aef171532d90d81230e6f45d6fd47a92c4820afe8416670372de57cd6afa1f66e05d493a57446ef4a0c4711ad3dd3281a2e369df99f551bc161df2f
@@ -210,18 +210,36 @@ module Tina4
210
210
  true
211
211
  end
212
212
 
213
- # Remove messages by status. "dead" empties the dead-letter queue;
214
- # anything else empties the main queue. Returns the count removed.
215
- def purge(topic, status)
216
- name = dead_status?(status) ? "#{topic}.dead_letter" : topic
217
- queue = get_queue(name)
218
- count = queue.message_count
219
- queue.purge
220
- count
213
+ # Not performable on RabbitMQ - raises naming the backend and the operation.
214
+ #
215
+ # purge(status) removes jobs SELECTED BY STATUS. RabbitMQ cannot address
216
+ # messages by status: basic.get pops the head of the queue and the only
217
+ # bulk operation is queue.purge, which empties the WHOLE live queue
218
+ # regardless of status. This used to drain that queue on any non-dead
219
+ # status, destroying every pending job - the destructive no-op ADR-0022
220
+ # invariant 6 forbids. Refusing by name is the honest answer.
221
+ def purge(_topic, _status)
222
+ raise NotImplementedError,
223
+ "The rabbitmq queue backend cannot perform purge(): RabbitMQ " \
224
+ "cannot address messages by status (basic.get pops the head of " \
225
+ "the queue), so a status-addressed purge would have to drain the " \
226
+ "entire live queue and destroy pending work. Use the file or " \
227
+ "mongodb backend."
221
228
  end
222
229
 
223
- def clear(topic)
224
- purge(topic, "pending")
230
+ # Not performable on RabbitMQ - raises naming the backend and the operation.
231
+ #
232
+ # clear() empties the queue. RabbitMQ cannot address messages by status,
233
+ # so the only thing it could do is queue.purge the WHOLE live queue. This
234
+ # used to do exactly that and return 0, silently destroying every pending
235
+ # job. Draining a live broker on a status-addressed clear is data loss.
236
+ def clear(_topic)
237
+ raise NotImplementedError,
238
+ "The rabbitmq queue backend cannot perform clear(): RabbitMQ " \
239
+ "cannot address messages by status (basic.get pops the head of " \
240
+ "the queue), so a status-addressed clear would have to drain the " \
241
+ "entire live queue and destroy pending work. Use the file or " \
242
+ "mongodb backend."
225
243
  end
226
244
 
227
245
  def size(topic)
@@ -251,10 +269,6 @@ module Tina4
251
269
  @queues[topic] ||= @channel.queue(topic, durable: true)
252
270
  end
253
271
 
254
- def dead_status?(status)
255
- %w[dead dead_letter deadletter failed].include?(status.to_s.downcase)
256
- end
257
-
258
272
  # Pop every message off <topic>.dead_letter and put it straight back.
259
273
  # A READ must not consume: dead_letters() is called by dashboards and
260
274
  # health checks, and a read that emptied the queue would destroy the very
data/lib/tina4/session.rb CHANGED
@@ -178,8 +178,12 @@ module Tina4
178
178
  # Persist the session if dirty. On a backend write failure the error is
179
179
  # logged and false is returned — the @modified (dirty) flag is RETAINED so
180
180
  # a later save can retry. Returns true on a successful (or no-op) write.
181
+ #
182
+ # A cleared id (@id nil, e.g. after #destroy) is a no-op: there is nothing
183
+ # to persist, and a write would re-create the just-destroyed record. Mirrors
184
+ # the Python master's `if self._session_id and self._dirty`.
181
185
  def save
182
- return true unless @modified
186
+ return true unless @id && @modified
183
187
  if safe_write(@id, @data, @ttl)
184
188
  @modified = false
185
189
  true
@@ -188,11 +192,16 @@ module Tina4
188
192
  end
189
193
  end
190
194
 
191
- # Destroy the current session. Should be called right after login or any
192
- # privilege change to defend against session fixation (see #regenerate).
195
+ # Destroy the current session. ENDS the session: the stored record is
196
+ # removed and the id is CLEARED (@id = nil), so a later set()+save() with no
197
+ # new #start has no id to persist under and cannot RESURRECT the just-
198
+ # destroyed record. Mirrors the Python master (nulls _session_id) and Node
199
+ # (nulls sessionId). A fresh session needs a new #start, which mints a new id.
193
200
  def destroy
194
- safe_destroy(@id)
201
+ safe_destroy(@id) if @id
202
+ @id = nil
195
203
  @data = {}
204
+ @modified = false
196
205
  end
197
206
 
198
207
  # Get a session value with optional default.
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.13.96"
4
+ VERSION = "3.13.97"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.96
4
+ version: 3.13.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team