Skip to content

symfonic.memory.backends.pool_pgvector

pool_pgvector

Registering pgvector's binary codec once per physical connection.

Split from :mod:.pool at the 300-line budget. It is a self-contained concern -- whether this connection can speak vector natively -- consulted by the two Postgres backends and by nothing else, and it has its own test module.

pool re-exports every name here, so from symfonic.memory.backends.pool import connection_has_pgvector_codec and the tests' pool_mod._register_pgvector_on_connection are unchanged.

connection_has_pgvector_codec

connection_has_pgvector_codec(conn: Any) -> bool

Return True if conn had pgvector's codec successfully registered.

Set by :func:_register_pgvector_on_connection per physical connection. Defaults to False when the connection has not been seen by the init hook — e.g. on mock connections in unit tests, or on a connection that was not created by a pool we control.

Source code in src/symfonic/memory/backends/pool_pgvector.py
def connection_has_pgvector_codec(conn: Any) -> bool:
    """Return True if ``conn`` had pgvector's codec successfully registered.

    Set by :func:`_register_pgvector_on_connection` per physical
    connection. Defaults to ``False`` when the connection has not been
    seen by the init hook — e.g. on mock connections in unit tests, or
    on a connection that was not created by a pool we control.
    """
    raw = _raw_connection(conn)
    try:
        return bool(_CODEC_REGISTRY.get(raw, False))
    except TypeError:  # raw is not hashable (mocks, etc.) — degrade safely
        return False