db

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB(globalDB *sql.DB)

func OpenDB

func OpenDB(dbName, host string, port int, user, password string) (*sql.DB, error)

Types

type BatchLoader

type BatchLoader interface {
	InsertValue(ctx context.Context, query []string) error
	Flush(ctx context.Context) error
}

type SQLBatchLoader

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

SQLBatchLoader helps us insert in batch

func NewSQLBatchLoader

func NewSQLBatchLoader(db *sql.DB, hint string, retryCount int, retryInterval time.Duration) *SQLBatchLoader

NewSQLBatchLoader creates a batch loader for database connection

func (*SQLBatchLoader) Flush

func (b *SQLBatchLoader) Flush(ctx context.Context) error

Flush inserts all pending values

func (*SQLBatchLoader) InsertValue

func (b *SQLBatchLoader) InsertValue(ctx context.Context, query []string) error

InsertValue inserts a value, the loader may flush all pending values.

Jump to

Keyboard shortcuts

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