dbutil

package
v0.0.0-...-94dd193 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dbutil provides utilities for managing connections to a SQL database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(driver, dsn string, opts ...Option) (*sql.DB, error)

OpenDB creates a sql.DB connection to the database driver. OpenDB uses a linear backoff timer when attempting to establish a connection, only returning after the connection is successful or the number of attempts exceeds the maxAttempts value(defaults to 15 attempts).

func OpenDBX

func OpenDBX(driver, dsn string, opts ...Option) (*sqlx.DB, error)

dbutil.OpenDBX is similar to dbutil.OpenDB, except it returns a *sqlx.DB from the popular github.com/jmoiron/sqlx package.

Types

type Option

type Option func(*dbConfig)

Option provides optional configuration for managing DB connections.

func WithCensusDriver

func WithCensusDriver() Option

func WithCensusTraceOptions

func WithCensusTraceOptions(opts ...ocsql.TraceOption) Option

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger configures a logger Option.

func WithMaxAttempts

func WithMaxAttempts(maxAttempts int) Option

WithMaxAttempts configures the number of maximum attempts to make

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL