Rename migrations for live state and the work queue: state keys move with RENAMENX in batches (type, TTL and history capacity kept), the queue rebuilds its streams with the same ids, group and pending entries, rewrites timers, parked and held items and done markers, and can hold new work in a list released in order; nothing calls them yet

This commit is contained in:
2026-11-02 19:50:54 +01:00
parent ebcc480a8c
commit 46b57de4ec
5 changed files with 981 additions and 83 deletions
+14 -5
View File
@@ -9,6 +9,7 @@ from types import SimpleNamespace
import pytest
from fluksio.flow import namespace, pipeline, state
from fluksio.flow import queue as queue_module
from fluksio.flow.alerts import dedup_key
from fluksio.flow.namespace import FAMILIES, ITEM_FIELDS, Rename, touches
from fluksio.flow.nodes import Node, base
@@ -144,10 +145,18 @@ FAMILY_LITERAL = re.compile(r"(__[a-z][a-z_]*__)(?::|$)")
PYTHON = set(dir(type)) | set(dir(lambda: None))
@pytest.mark.parametrize("module", [pipeline, base, state])
def test_every_family_in_the_key_builders_is_registered(module):
"""A key family written as a literal here, not registered in `namespace`,
would be left behind by a rename."""
@pytest.mark.parametrize(
("module", "registry"),
[
(pipeline, FAMILIES),
(base, FAMILIES),
(state, FAMILIES),
(queue_module, queue_module.STRUCTURES),
],
)
def test_every_family_in_the_key_builders_is_registered(module, registry):
"""A key family written as a literal here, not registered in `namespace`
(the queue's in `queue.STRUCTURES`), would be left behind by a rename."""
found = {
family
for node in ast.walk(ast.parse(inspect.getsource(module)))
@@ -155,7 +164,7 @@ def test_every_family_in_the_key_builders_is_registered(module):
for family in FAMILY_LITERAL.findall(node.value)
} - PYTHON
assert found <= set(FAMILIES), found - set(FAMILIES)
assert found <= set(registry), found - set(registry)
def test_every_work_item_field_is_classified():