Versions in this module Expand all Collapse all v0 v0.0.3 Sep 11, 2024 Changes in this version + const DefaultNumTxRetries + const DefaultRetryDelay + const PostgresTag — darwin/amd64, linux/amd64, windows/amd64 + const Subsystem + var DefaultPostgresFixtureLifetime = 10 * time.Minute + var DefaultStoreTimeout = time.Second * 10 + var ErrRetriesExceeded = errors.New("db tx retries exceeded") + func DisableLog() + func IsSerializationError(err error) bool + func MapSQLError(err error) error + func UseLogger(logger btclog.Logger) + type BaseDB struct + func (s *BaseDB) BeginTx(ctx context.Context, opts TxOptions) (*sql.Tx, error) + type BatchedInvoiceQueries interface + type BatchedQuerier interface + BeginTx func(ctx context.Context, options TxOptions) (*sql.Tx, error) + type BatchedTx interface + ExecTx func(ctx context.Context, txOptions TxOptions, txBody func(Q) error) error + type ErrSQLUniqueConstraintViolation struct + DBError error + func (e ErrSQLUniqueConstraintViolation) Error() string + type ErrSerializationError struct + DBError error + func (e ErrSerializationError) Error() string + func (e ErrSerializationError) Unwrap() error + type InvoiceQueries interface + DeleteCanceledInvoices func(ctx context.Context) (sql.Result, error) + DeleteInvoice func(ctx context.Context, arg sqlc.DeleteInvoiceParams) (sql.Result, error) + FetchAMPSubInvoiceHTLCs func(ctx context.Context, arg sqlc.FetchAMPSubInvoiceHTLCsParams) ([]sqlc.FetchAMPSubInvoiceHTLCsRow, error) + FetchAMPSubInvoices func(ctx context.Context, arg sqlc.FetchAMPSubInvoicesParams) ([]sqlc.AmpSubInvoice, error) + FetchSettledAMPSubInvoices func(ctx context.Context, arg sqlc.FetchSettledAMPSubInvoicesParams) ([]sqlc.FetchSettledAMPSubInvoicesRow, error) + FilterInvoices func(ctx context.Context, arg sqlc.FilterInvoicesParams) ([]sqlc.Invoice, error) + GetInvoice func(ctx context.Context, arg sqlc.GetInvoiceParams) ([]sqlc.Invoice, error) + GetInvoiceFeatures func(ctx context.Context, invoiceID int64) ([]sqlc.InvoiceFeature, error) + GetInvoiceHTLCCustomRecords func(ctx context.Context, invoiceID int64) ([]sqlc.GetInvoiceHTLCCustomRecordsRow, error) + GetInvoiceHTLCs func(ctx context.Context, invoiceID int64) ([]sqlc.InvoiceHtlc, error) + InsertAMPSubInvoiceHTLC func(ctx context.Context, arg sqlc.InsertAMPSubInvoiceHTLCParams) error + InsertInvoice func(ctx context.Context, arg sqlc.InsertInvoiceParams) (int64, error) + InsertInvoiceFeature func(ctx context.Context, arg sqlc.InsertInvoiceFeatureParams) error + InsertInvoiceHTLC func(ctx context.Context, arg sqlc.InsertInvoiceHTLCParams) (int64, error) + InsertInvoiceHTLCCustomRecord func(ctx context.Context, arg sqlc.InsertInvoiceHTLCCustomRecordParams) error + NextInvoiceSettleIndex func(ctx context.Context) (int64, error) + OnAMPSubInvoiceCanceled func(ctx context.Context, arg sqlc.OnAMPSubInvoiceCanceledParams) error + OnAMPSubInvoiceCreated func(ctx context.Context, arg sqlc.OnAMPSubInvoiceCreatedParams) error + OnAMPSubInvoiceSettled func(ctx context.Context, arg sqlc.OnAMPSubInvoiceSettledParams) error + OnInvoiceCanceled func(ctx context.Context, arg sqlc.OnInvoiceCanceledParams) error + OnInvoiceCreated func(ctx context.Context, arg sqlc.OnInvoiceCreatedParams) error + OnInvoiceSettled func(ctx context.Context, arg sqlc.OnInvoiceSettledParams) error + UpdateAMPSubInvoiceHTLCPreimage func(ctx context.Context, arg sqlc.UpdateAMPSubInvoiceHTLCPreimageParams) (sql.Result, error) + UpdateAMPSubInvoiceState func(ctx context.Context, arg sqlc.UpdateAMPSubInvoiceStateParams) error + UpdateInvoiceAmountPaid func(ctx context.Context, arg sqlc.UpdateInvoiceAmountPaidParams) (sql.Result, error) + UpdateInvoiceHTLC func(ctx context.Context, arg sqlc.UpdateInvoiceHTLCParams) error + UpdateInvoiceState func(ctx context.Context, arg sqlc.UpdateInvoiceStateParams) (sql.Result, error) + UpsertAMPSubInvoice func(ctx context.Context, arg sqlc.UpsertAMPSubInvoiceParams) (sql.Result, error) + type InvoiceQueriesTxOptions struct + func NewInvoiceQueryReadTx() InvoiceQueriesTxOptions + func (a *InvoiceQueriesTxOptions) ReadOnly() bool + type InvoiceStore struct + func NewInvoiceStore(db BatchedInvoiceQueries, clock clock.Clock) *InvoiceStore + func (i *InvoiceStore) AddInvoice(ctx context.Context, newInvoice *invpkg.Invoice, paymentHash lntypes.Hash) (uint64, error) + func (i *InvoiceStore) DeleteCanceledInvoices(ctx context.Context) error + func (i *InvoiceStore) DeleteInvoice(ctx context.Context, invoicesToDelete []invpkg.InvoiceDeleteRef) error + func (i *InvoiceStore) FetchPendingInvoices(ctx context.Context) (map[lntypes.Hash]invpkg.Invoice, error) + func (i *InvoiceStore) InvoicesAddedSince(ctx context.Context, idx uint64) ([]invpkg.Invoice, error) + func (i *InvoiceStore) InvoicesSettledSince(ctx context.Context, idx uint64) ([]invpkg.Invoice, error) + func (i *InvoiceStore) LookupInvoice(ctx context.Context, ref invpkg.InvoiceRef) (invpkg.Invoice, error) + func (i *InvoiceStore) QueryInvoices(ctx context.Context, q invpkg.InvoiceQuery) (invpkg.InvoiceSlice, error) + func (i *InvoiceStore) UpdateInvoice(ctx context.Context, ref invpkg.InvoiceRef, _ *invpkg.SetID, ...) (*invpkg.Invoice, error) + type PostgresConfig struct + Dsn string + MaxConnections int + SkipMigrations bool + Timeout time.Duration + func (p *PostgresConfig) Validate() error + type PostgresStore struct + func NewPostgresStore(cfg *PostgresConfig) (*PostgresStore, error) + func NewTestPostgresDB(t *testing.T, fixture *TestPgFixture) *PostgresStore + type QueryCreator func(*sql.Tx) Q + type SqliteConfig struct + BusyTimeout time.Duration + MaxConnections int + PragmaOptions []string + SkipMigrations bool + Timeout time.Duration + type SqliteStore struct + func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) + func NewTestSqliteDB(t *testing.T) *SqliteStore + type TestPgFixture struct — darwin/amd64, linux/amd64, windows/amd64 + func NewTestPgFixture(t *testing.T, expiry time.Duration) *TestPgFixture + func (f *TestPgFixture) GetConfig(dbName string) *PostgresConfig + func (f *TestPgFixture) TearDown(t *testing.T) + type TransactionExecutor struct + func NewTransactionExecutor[Querier any](db BatchedQuerier, createQuery QueryCreator[Querier], opts ...TxExecutorOption) *TransactionExecutor[Querier] + func (t *TransactionExecutor[Q]) ExecTx(ctx context.Context, txOptions TxOptions, txBody func(Q) error) error + type Tx interface + Commit func() error + Rollback func() error + type TxExecutorOption func(*txExecutorOptions) + func WithTxRetries(numRetries int) TxExecutorOption + func WithTxRetryDelay(delay time.Duration) TxExecutorOption + type TxOptions interface + ReadOnly func() bool