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 +4 -4
- data/lib/tina4/queue_backends/rabbitmq_backend.rb +28 -14
- data/lib/tina4/session.rb +13 -4
- data/lib/tina4/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: cc06b125fb780e5f4703244636215011a65c6ee220081fcd02b4f73fa37db06c
|
|
4
|
+
data.tar.gz: a4ebef28a619dff925c104eb3e93c0632cf9cf47c9f84d15aff0c1658345eae0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3e081993e4da7a7ba4fd6fdd487ed06428bb5ccc7cd212dcee1e50ff309cfe30c342f14b4d17c4208067a558f089bc5300d4f6ee219967497dd43a17baa357a
|
|
7
|
+
data.tar.gz: 5a6123804aef171532d90d81230e6f45d6fd47a92c4820afe8416670372de57cd6afa1f66e05d493a57446ef4a0c4711ad3dd3281a2e369df99f551bc161df2f
|
|
@@ -210,18 +210,36 @@ module Tina4
|
|
|
210
210
|
true
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
224
|
-
|
|
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.
|
|
192
|
-
#
|
|
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