connector: wanted(port) says whether anyone watches or reads a port
Docs / docs (push) Successful in 31s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m5s
Playwright Tests / test-playwright (2, 2) (push) Failing after 20s
pre-commit / pre-commit (push) Failing after 2m30s
Test Backend / test-backend (3.12) (push) Failing after 4m52s
Test Backend / test-backend (3.14) (push) Failing after 4m36s
Compose Smoke Test / test-compose (push) Failing after 24s
Playwright Tests / merge-reports (push) Failing after 2m25s
Docs / docs (push) Successful in 31s
Playwright Tests / test-playwright (1, 2) (push) Failing after 1m5s
Playwright Tests / test-playwright (2, 2) (push) Failing after 20s
pre-commit / pre-commit (push) Failing after 2m30s
Test Backend / test-backend (3.12) (push) Failing after 4m52s
Test Backend / test-backend (3.14) (push) Failing after 4m36s
Compose Smoke Test / test-compose (push) Failing after 24s
Playwright Tests / merge-reports (push) Failing after 2m25s
This commit is contained in:
@@ -21,6 +21,8 @@ What a connector gets from the base class:
|
||||
* :meth:`ConnectorNode.save_artifact`, for a device whose readings are bytes —
|
||||
a camera frame, a recorded clip — which travel as a reference on a media
|
||||
port rather than as the message itself;
|
||||
* :meth:`ConnectorNode.wanted`, so a camera fetches frames only while someone
|
||||
watches them or a running flow reads them;
|
||||
* :attr:`ConnectorNode.store`, for the few short strings that have to outlive
|
||||
a restart — a certificate pinned on first contact, a pairing token — shared
|
||||
by every node of the connector's package; :mod:`fluksio.flow.connector_tls`
|
||||
@@ -40,6 +42,7 @@ from typing import TYPE_CHECKING, Any, ClassVar
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from fluksio.flow.connector_store import ConnectorStore, namespace_of
|
||||
from fluksio.flow.demand import demand
|
||||
from fluksio.flow.nodes import Node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -173,6 +176,17 @@ class ConnectorNode(Node):
|
||||
[data], name=name, media_type=media_type, volatile=volatile
|
||||
)
|
||||
|
||||
def wanted(self, port: str) -> bool:
|
||||
"""Whether anyone wants what ``port`` publishes right now.
|
||||
|
||||
A dashboard tile on screen, a screen through the portal, or a node of a
|
||||
running flow reading the port's message. A camera asks before each
|
||||
frame, so it sends nothing while nobody watches. Always true on a
|
||||
remote worker, which cannot see who watches.
|
||||
"""
|
||||
names = {s.name for s in self.output_ports if s.port == port and s.name}
|
||||
return demand.wants(names)
|
||||
|
||||
@property
|
||||
def store(self) -> ConnectorStore:
|
||||
"""Short strings this connector keeps across restarts.
|
||||
|
||||
Reference in New Issue
Block a user