Documentation
¶
Overview ¶
Package postgres is a PostgreSQL ledgo.Store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps accounts and transactions in PostgreSQL.
Commits lock only the accounts that have a balance limit, always in ID order, so concurrent commits cannot deadlock on READ COMMITTED and need no retry loop.
func InTx ¶
InTx returns a Store that writes into tx, so postings commit or roll back together with the caller's own changes. The caller commits tx, and must roll it back if a Commit fails.
func New ¶
New returns a Store on db, opened with sql.Open("pgx", dsn). Each Commit runs in its own database transaction.
func (*Store) Balance ¶
Balance is the account's debits minus credits: cached for accounts with a limit, summed from entries otherwise.
func (*Store) CreateAccount ¶
CreateAccount registers account. Creating the same account again is a no-op; with different settings it returns ledgo.ErrAccountConflict.