lib

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RandomLogID = func() string {
	return fmt.Sprintf("%d_%03d", time.Now().UnixNano(), ran.Int63()%1000)
}

Functions

func AccepLanguages

func AccepLanguages(req *http.Request) []string

func DuplicateEntryError

func DuplicateEntryError(err error) bool

func GainLogID

func GainLogID(ctx context.Context) string

func Int64BoolMap2Slice

func Int64BoolMap2Slice(m map[int64]bool) (s []int64)

func Int64Map2Slice

func Int64Map2Slice(m map[int64]bool) []int64

func LoadConf

func LoadConf(fileName string, data interface{}, fileSuffix string) error

LoadConf load config from file

func LoadConfAuto

func LoadConfAuto(fileName string, data interface{}) error

LoadConfAuto load config from file. auto calculate file type by suffix

func NewLogContext

func NewLogContext(ctx context.Context) context.Context

func PBool

func PBool(v bool) *bool

func PInt

func PInt(v int) *int

func PInt32

func PInt32(v int32) *int32

func PInt64

func PInt64(v int64) *int64

func PInt8

func PInt8(v int8) *int8

func PString

func PString(v string) *string

func PTime

func PTime(v time.Time) *time.Time

func PTimeNow

func PTimeNow() *time.Time

func PUint32

func PUint32(v uint32) *uint32

func RDBTxnExecute

func RDBTxnExecute(dc *DBContext, handler func(context.Context) error) error

func ReqFactory

func ReqFactory(url string, reqHeader, rspHeader map[string]string, method string) (*bfe_basic.Request, error)

func SortMapInt642String

func SortMapInt642String(m map[int64]string) []int64

func StringBoolMap2Slice

func StringBoolMap2Slice(m map[string]bool) (s []string)

func StringMap2Slice

func StringMap2Slice(m map[string]bool) []string

func StringSlice2Map

func StringSlice2Map(ss []string) map[string]bool

func StringSliceHasElement

func StringSliceHasElement(s []string, e string) bool

func StringSliceSub

func StringSliceSub(a, b []string) (diff []string)

func StringSliceSubtract

func StringSliceSubtract(a, b []string) (r []string)

StringSliceSubtract a - b

func Transaction

func Transaction(conn *sql.DB, do func(*sql.Tx) error) error

func WantBlockWrite

func WantBlockWrite(ops ...*Op) bool

func WantOpenTxn

func WantOpenTxn(ops ...*Op) bool

Types

type DBContext

type DBContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewDBContext

func NewDBContext(ctx context.Context, conn *sql.DB) *DBContext

func (*DBContext) BeginTrans

func (ctx *DBContext) BeginTrans() error

func (*DBContext) Conn

func (ctx *DBContext) Conn() *sql.DB

type DBContextFactory

type DBContextFactory func(ctx context.Context, ops ...*Op) (*DBContext, error)

type DBContexter

type DBContexter interface {
	context.Context
	Conn() *sql.DB
}

type Op

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

func BlockWrite

func BlockWrite() *Op

func OpenTxn

func OpenTxn() *Op

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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