kura_pool_pgo (kura_postgres v0.4.3)

View Source

Default kura_pool implementation. Wraps pgo's pool, which uses an ETS-holder transfer pattern that keeps the per-query hot path off the pool agent.

The connection handle returned from checkout/2 is pgo's own conn() record and can be passed straight to pgo_handler:extended_query/4 etc.

The give_away/3 callback transfers ownership of pgo's per-conn holder ETS table to another process via ets:give_away/3. The new owner can then call kura_pool_pgo:checkin/2 legitimately. Used by kura_sandbox-style test fixtures.

Pool options are passed through to pgo verbatim. Common keys:

#{
    host => "localhost",
    port => 5432,
    database => "my_app",
    user => "postgres",
    password => "secret",
    pool_size => 10,
    socket_options => [],
    decode_opts => [return_rows_as_maps, column_name_as_atom]
}

See the pgo pool options for the full list.

Summary

Functions

capabilities()

-spec capabilities() -> kura_capabilities:capability_set().

checkin/2

-spec checkin(kura_pool:name(), kura_pool:token()) -> ok.

checkout(Name, Opts)

-spec checkout(kura_pool:name(), kura_pool:checkout_opts()) ->
                  {ok, kura_pool:conn(), kura_pool:token()} | {error, term()}.

give_away/3

-spec give_away(kura_pool:token(), pid(), term()) -> ok | {error, term()}.

start_pool(Name, Opts)

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

stop_pool(Name)

-spec stop_pool(kura_pool:name()) -> ok.