Flows and dashboards get ids: the store is addressed by id with a key index, the first start gives every document its key as id, fluksio store migrate --dry-run and ls; the rename routes are gone

This commit is contained in:
2026-11-02 16:54:11 +01:00
parent de13c48c90
commit fae85f5ecb
20 changed files with 1287 additions and 420 deletions
+12 -1
View File
@@ -40,6 +40,7 @@ from fluksio.flow.demand import demand
from fluksio.flow.devices import DeviceStore, DeviceUnavailable
from fluksio.flow.events import event_bus
from fluksio.flow.executor import ExecutionService
from fluksio.flow.identity import assign_ids
from fluksio.flow.metrics import MetricsCollector
from fluksio.flow.nodes.http import close_shared_client
from fluksio.flow.pipeline import ValueSource
@@ -58,7 +59,7 @@ from fluksio.flow.resources import (
from fluksio.flow.runs import RUN_STATE_TTL, RunService, sweep_artifacts
from fluksio.flow.secrets import init_secrets
from fluksio.flow.state import MemoryState, RedisState, StateBackend
from fluksio.flow.store import FlowStore, InvalidName
from fluksio.flow.store import FlowStore, IdentityChange, InvalidName
from fluksio.flow.watchdog import LoopWatchdog
from fluksio.flow.workers import PythonWorkerPool
@@ -301,6 +302,10 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
events=event_bus,
max_cascades=settings.FLOW_MAX_CASCADES,
)
# Every flow and dashboard has an id before anything reads one: the
# store's own `_migrate`, the device migrations below and every cache
# after them write documents back with whatever id they read.
await run_in_threadpool(assign_ids, settings.FLOWS_DIR)
store = FlowStore(settings.FLOWS_DIR)
# The packages node code imports. In the background, because a first
# install of anything substantial takes minutes and `uv` is given five
@@ -577,6 +582,12 @@ async def invalid_name(request: Request, exc: InvalidName) -> JSONResponse: # n
return JSONResponse(status_code=400, content={"detail": str(exc)})
@app.exception_handler(IdentityChange)
async def identity_change(request: Request, exc: IdentityChange) -> JSONResponse: # noqa: ARG001
"""A save that would change an object's id or key, which no save may."""
return JSONResponse(status_code=409, content={"detail": str(exc)})
@app.exception_handler(DeviceUnavailable)
async def device_unavailable(request: Request, exc: DeviceUnavailable) -> JSONResponse: # noqa: ARG001
"""A device credential that cannot be checked now is not a refused one."""