Skip to content

API Reference parrot_formdesigner.services.sinks.factory

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.sinks.factory

View source

SinkFactory — builds and caches sinks, and enforces coordinate immutability.

The single owner of the sink dispatch table (services/sinks/__init__.py) and the single place that enforces the coordinate-immutability rule (spec section 8, resolved): a form's destination coordinates (schema/table/path/sheet id, and the connection alias itself) freeze once the factory has first resolved a sink for that form. Only the mapping (fields, delimiter, etc.) may evolve. This is what keeps a form's history in one place forever and is why promote() needs no changes.

Alias AbstractSubmissionSink

Re-exported from parrot_formdesigner.services.sinks.base.AbstractSubmissionSink.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias SinkAliasRegistry

Re-exported from parrot_formdesigner.services.sink_aliases.SinkAliasRegistry.

Class SinkFactory

Builds and caches sinks per (tenant, form_uid, version).

Not a global singleton — instantiated once by the app (TASK-2429) with a single :class:SinkAliasRegistry and passed in explicitly. Holds no module-level mutable state.

Parameter Type Default Description
alias_registry SinkAliasRegistry Shared alias registry passed to every sink built by this factory.

Method SinkFactory.get

Return the sink for form's declared persistence target.

get(form: FormSchema, *, tenant: str) -> AbstractSubmissionSink

Parameter Type Default Description
form FormSchema The form whose persistence.data target to resolve.
tenant str Tenant scope used both for caching and alias resolution.

Returns: AbstractSubmissionSink — The cached or newly built sink for (tenant, form.form_uid, form.version).

Raises:

  • ValueError — If form.persistence is not set.
  • SinkTargetMismatchError — If the target's coordinates differ from the fingerprint recorded for this (tenant, form_uid) on a previous call.

Method SinkFactory.close_all

Close every cached sink. Idempotent — safe to call twice.

Closes all sinks concurrently and tolerates individual failures (via return_exceptions=True): one sink raising during close() must not prevent the others from closing, and the cache is cleared only after every close attempt has completed — never before, so a failure never leaves an uncloseable sink stranded outside the cache.

close_all() -> None

Alias SinkTargetMismatchError

Re-exported from parrot_formdesigner.services.sinks.base.SinkTargetMismatchError.

Alias SubmissionTarget

Re-exported from parrot_formdesigner.core.persistence.SubmissionTarget.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally