Cameras on devices (openpanel C1): frames in memory, a binary uplink, demand
- Volatile frames are held in memory with a byte-bounded queue instead of the /dev/shm ring scanned on every put; workers keep writing to the directory, which is trimmed on a timer. A volatile upload no longer spools to disk. ARTIFACT_VOLATILE_BYTES=0 turns the ring off. - A device sends camera frames as binary messages on its socket, held and published in one step and credited to its device node; refused frames are logged and dropped. Its snapshot carries demand and the uplink (binary, or http through the portal). - One demand registry for every socket's wanted media, the tunnel's included, plus what running flows read, mapped onto on-demand ports and published as device_demand; at most 8 media names per socket. - Per-message deflate off in serve and dev; a device may fetch the last 8 digests of a message; published dashboards cached per store revision; a revoked device socket is closed with 1008. - Media tiles want bytes only while on screen; the Devices tab previews a wired camera; the device node warns when a flow reads an on-demand port.
This commit is contained in:
@@ -20,6 +20,7 @@ from fluksio.flow.artifacts import is_reference
|
||||
from fluksio.flow.controller import FlowController
|
||||
from fluksio.flow.dashboards import DashboardDef, DashboardStore
|
||||
from fluksio.flow.devices import DeviceDef, DeviceStore, DeviceUnavailable, presence
|
||||
from fluksio.flow.events import event_bus
|
||||
from fluksio.flow.workers import PythonWorkerPool
|
||||
from fluksio.models import OAuthClient, TokenPayload, User, WorkerToken
|
||||
|
||||
@@ -165,11 +166,13 @@ def _device_writable(device: DeviceDef, request: Request) -> set[str]:
|
||||
|
||||
|
||||
def _device_digests(device: DeviceDef, request: Request) -> set[str]:
|
||||
"""The artifacts this panel's messages are pointing at right now.
|
||||
"""The artifacts this panel's messages are pointing at, now or just before.
|
||||
|
||||
A media tile fetches the bytes its message names, so the messages already
|
||||
bounding the panel bound this too — one step further along, through
|
||||
whatever those messages currently hold.
|
||||
whatever those messages currently hold. And through the last few they
|
||||
held: a screen through the portal fetches a camera frame by frame, and by
|
||||
the time its fetch arrives the camera may have published the next one.
|
||||
"""
|
||||
controller: FlowController | None = getattr(
|
||||
request.app.state, "flow_controller", None
|
||||
@@ -183,6 +186,8 @@ def _device_digests(device: DeviceDef, request: Request) -> set[str]:
|
||||
for value in controller.state.get_present(sorted(names)).values():
|
||||
if is_reference(value):
|
||||
found.add(str(value["digest"]))
|
||||
for name in names:
|
||||
found.update(event_bus.digests.get(name, ()))
|
||||
return found
|
||||
|
||||
|
||||
@@ -215,9 +220,9 @@ def _device_may(payload: dict[str, Any], request: Request) -> None:
|
||||
The device is left on ``request.state`` for the route, which credits a
|
||||
value published on one of its ports to the node holding that port.
|
||||
|
||||
# ponytail: the device file and the published dashboards are re-read per
|
||||
# request (the nonces are cached by the file's stat). Cache them behind
|
||||
# the store's revision if this shows up in a profile.
|
||||
The device file is read per request, which is what makes deleting a
|
||||
device revoke it at once. The nonces are cached by the file's stat and
|
||||
the published dashboards until the flow store's next commit.
|
||||
"""
|
||||
device = _device_for(payload, request.app)
|
||||
request.state.device = device
|
||||
|
||||
Reference in New Issue
Block a user