Give connectors a store that survives restarts, and a way to clear it

`ConnectorNode.store` keeps short strings per connector package in the
engine's database (`connector_state`, migration f8c3e5a91d27), so the nodes of
one package share them and `fluksio serve` needs nothing new: get, set and
delete, at most 64 kB a value and 256 keys a package. A superuser lists the
keys (never the values) and clears them through `/connectors/{node_type}/state`,
or under Stored state in a connector node's panel. Documented in the connector
contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-06 17:19:48 +02:00
co-authored by Claude Opus 5.5
parent b086d5d22b
commit 847abd67d6
15 changed files with 710 additions and 4 deletions
@@ -0,0 +1,38 @@
"""connector_state
A place for a connector to keep what has to outlive a restart, such as the
certificate a Hue bridge presented on first contact. Keyed by the connector's
package, so the nodes of one package share it.
Revision ID: f8c3e5a91d27
Revises: d5a3c8e1f246
Create Date: 2026-10-06
"""
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
from alembic import op
# revision identifiers, used by Alembic.
revision = "f8c3e5a91d27"
down_revision = "d5a3c8e1f246"
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"connector_state",
sa.Column(
"connector", sqlmodel.sql.sqltypes.AutoString(length=100), nullable=False
),
sa.Column("key", sqlmodel.sql.sqltypes.AutoString(length=200), nullable=False),
sa.Column("value", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("connector", "key"),
)
def downgrade():
op.drop_table("connector_state")