Documentation ¶
Index ¶
- func ExponentialBackOff(maxRetries uint64, maxElapsedTime time.Duration) backoff.BackOff
- func Tx(ctx context.Context, dbconn BeginnerExecutor, ...) error
- func TxWithBackOff(ctx context.Context, b backoff.BackOff, dbconn BeginnerExecutor, ...) error
- type Beginner
- type BeginnerExecutor
- type ContextExecutor
- type Executor
- type InstanceInfo
- type Transactor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExponentialBackOff ¶
ExponentialBackOff returns the exponential backoff configuration based on Azure best practices Reference: https://docs.microsoft.com/en-us/azure/postgresql/concepts-connectivity#handling-transient-errors
func Tx ¶
func Tx(ctx context.Context, dbconn BeginnerExecutor, callback func(ContextExecutor) error) error
Tx starts a transaction
func TxWithBackOff ¶
func TxWithBackOff(ctx context.Context, b backoff.BackOff, dbconn BeginnerExecutor, callback func(ContextExecutor) error) error
TxWithBackOff starts a transaction with the provided backoff policy
Types ¶
type BeginnerExecutor ¶
type BeginnerExecutor interface { Beginner ContextExecutor Close() error InstanceInfo() InstanceInfo }
BeginnerExecutor can context-aware perform SQL queries and create context-aware transactions with options
func NewPool ¶
func NewPool( url string, poolMaxOpenConns, poolMaxIdleConns int, ) (BeginnerExecutor, error)
NewPool opens a new DB connection pool, pings it and returns the pool connection pool definition: http://go-database-sql.org/connection-pool.html
type ContextExecutor ¶
type ContextExecutor interface { Executor ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
ContextExecutor can perform SQL queries with context
type Executor ¶
type Executor interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
Executor can perform SQL queries.
type InstanceInfo ¶
type InstanceInfo struct {
// contains filtered or unexported fields
}
InstanceInfo holds info about the DB
type Transactor ¶
type Transactor interface { Commit() error Rollback() error ContextExecutor }
Transactor is an interface for a sql.Tx