database

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 12 Imported by: 2

README

db

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr         string
	User         string
	Database     string
	CertPath     string
	Type         DBType
	ReadTimeout  string
	WriteTimeout string
}

func (*Config) DSN added in v0.3.0

func (cfg *Config) DSN() (connStr string)

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func New

func New(cfg *Config, options ...Option) (db *DB, err error)

func (*DB) RunTxx

func (d *DB) RunTxx(ctx context.Context, fn TransactionFunc) error

type DBType

type DBType string
const (
	PostgresDatabase   DBType = "postgres"
	ClickhouseDatabase DBType = "clickhouse"
	SQLiteDatabase     DBType = "sqlite3"
)

func (DBType) String

func (d DBType) String() string

type Option

type Option func(b *builder, cfg *hooks.Config)

func WithCockroachRetryFunc

func WithCockroachRetryFunc() Option

func WithCustomHook

func WithCustomHook(hook dbhook.Hook) Option

func WithDefaultOptions

func WithDefaultOptions(tracer opentracing.Tracer) Option

func WithReconnectHook

func WithReconnectHook() Option

func WithRetryFunc

func WithRetryFunc(f RetryFunc) Option

func WithSimplerrHook

func WithSimplerrHook() Option

func WithTracingHook

func WithTracingHook(tracer opentracing.Tracer) Option

type RetryFunc

type RetryFunc func(retryCount int, err error) bool

type TransactionFunc

type TransactionFunc func(ctx context.Context, tx *sqlx.Tx) error

Directories

Path Synopsis
internal
tests

Jump to

Keyboard shortcuts

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