Documentation
¶
Index ¶
- Variables
- func Decode(value string) ([]byte, error)
- func Encode(value []byte, encodeType ...EncodeType) string
- func ExecuteInTx(ctx context.Context, pool *pgxpool.Pool, fn func(tx pgx.Tx) error) (err error)
- func ExecuteTxWithinCtx(ctx context.Context, fn func(context.Context) error) error
- func NewWithUsernameAndPassword(username, password, hostname, port, dbname string) (*sql.DB, error)
- func SetupGlobalPgxPool(pool *pgxpool.Pool)
- type Config
- type EncodeType
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Decode ¶
Decode decodes the input string by automatically determining the encoding type from its short prefix.
func Encode ¶
func Encode(value []byte, encodeType ...EncodeType) string
Encode encodes the input byte slice into the specified format, prefixed with a short encoding type. If no encodeType is provided, it defaults to Base64.
func ExecuteInTx ¶
ExecuteInTx is meant for DB store implementations to execute an operation within the scope of a DB transaction. This method is aware of ExecuteTxWithinCtx, and will dynamically decide when to use a new or existing transaction, as well as where the responsibilty for commit/rollback calls lie.
func ExecuteTxWithinCtx ¶
ExecuteTxWithinCtx executes a DB transaction that's scoped to a call to fn. The transaction is passed along with the context. Once fn is complete, commit/rollback is called based on whether an error is returned.
func NewWithUsernameAndPassword ¶
Get a DB connection pool using username/password credentials
func SetupGlobalPgxPool ¶ added in v1.6.0
Types ¶
type EncodeType ¶
type EncodeType string
EncodeType is an enum-like type for encoding types.
const ( Base64 EncodeType = "b64" Base58 EncodeType = "b58" Hex EncodeType = "hex" DefaultEncodeType = Base64 )