db_holder

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DBConnRetryThreshold = 8
View Source
const MOLoggerUser = "mo_logger"
View Source
const MaxConnectionNumber = 1

Variables

View Source
var (
	DBConnErrCount atomic.Uint32
)

sqlWriterDBUser holds the db user for logger

Functions

func CloseDBConn added in v1.0.1

func CloseDBConn()

func GetOrInitDBConn added in v1.0.1

func GetOrInitDBConn(forceNewConn bool, randomCN bool) (*sql.DB, error)

func GetSQLWriterDBAddressFunc

func GetSQLWriterDBAddressFunc() func(context.Context, bool) (string, error)

func IsRecordExisted added in v1.0.0

func IsRecordExisted(ctx context.Context, record []string, tbl *table.Table, getDBConn DBConnProvider) (bool, error)

func SetDBConn

func SetDBConn(conn *sql.DB)

func SetSQLWriterDBAddressFunc

func SetSQLWriterDBAddressFunc(f func(context.Context, bool) (string, error))

func SetSQLWriterDBUser

func SetSQLWriterDBUser(userName string, password string)

func WriteRowRecords

func WriteRowRecords(records [][]string, tbl *table.Table, timeout time.Duration) (int, error)

Types

type CSVWriter added in v1.0.0

type CSVWriter struct {
	// contains filtered or unexported fields
}

func NewCSVWriter added in v1.0.0

func NewCSVWriter(ctx context.Context) *CSVWriter

func (*CSVWriter) GetContent added in v1.0.0

func (w *CSVWriter) GetContent() string

func (*CSVWriter) Release added in v1.0.0

func (w *CSVWriter) Release()

func (*CSVWriter) WriteStrings added in v1.0.0

func (w *CSVWriter) WriteStrings(record []string) error

type DBConnProvider added in v1.0.0

type DBConnProvider func(forceNewConn bool, randomCN bool) (*sql.DB, error)

type DBUser

type DBUser struct {
	UserName string
	Password string
}

func GetSQLWriterDBUser

func GetSQLWriterDBUser() (*DBUser, error)

Jump to

Keyboard shortcuts

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