kura_driver_pgo (kura_postgres v0.4.3)

View Source

PostgreSQL driver impl using pgo.

Wraps pgo's query/3 and query/4 and pgo's transaction/2 behind the kura_driver behaviour so kura code does not need to know which client library is in use.

Transaction context

pgo stashes the in-flight transaction conn in the process dict (pgo_transaction_connection). query/5 checks for it: if present, the query routes to the transaction conn via pgo:query/3 (pool key); if absent, the query leases a fresh conn via kura_pool and runs it caller-driven via pgo:query/4. Same shape as the previous hardcoded path in kura_db:query/3 — extracted into a driver impl so non-pgo drivers can substitute their own transaction conventions.

Summary

Functions

ensure_database(Config)

-spec ensure_database(map()) -> ok | {error, term()}.

probe_pool(Pool)

-spec probe_pool(kura_pool:name()) -> ok | {error, term()}.

query(PoolMod, Pool, SQL, Params, Opts)

-spec query(module(), kura_pool:name(), iodata(), [term()], map()) -> dynamic().

query_on(Conn, SQL, Params, Opts)

-spec query_on(kura_pool:conn(), iodata(), [term()], map()) -> dynamic().

transaction(PoolMod, Pool, Fun, Opts)

-spec transaction(module(), kura_pool:name(), fun(() -> term()), map()) -> term().