options

package
v0.0.0-...-d72f891 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsoleBuildLogFunc

func ConsoleBuildLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)

ConsoleBuildLogFunc 控制台日志输出

func ConsoleExecLogFunc

func ConsoleExecLogFunc(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)

ConsoleExecLogFunc print the message to console

func NewTraceId

func NewTraceId() string

NewTraceId 生成新的UUID

func Time2StringEncodeHook

func Time2StringEncodeHook(typ reflect.Type, data interface{}) (interface{}, error)

Time2StringEncodeHook converts time.Time to string which the layout

Types

type BuildLogFunc

type BuildLogFunc func(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)

BuildLogFunc is called each time when we build a sql statement and args. The "ts" parameter gives the time that the build takes, while sql,args and err refer to the result of the execution.

type EncodeHookFunc

type EncodeHookFunc func(typ reflect.Type, data interface{}) (interface{}, error)

EncodeHookFunc this defined a func which will be called on each value when we use a INSERT clause

func GroupEncodeHook

func GroupEncodeHook(fns ...EncodeHookFunc) EncodeHookFunc

GroupEncodeHook support multi EncodeHookFunc The composed funcs are called in order, with the result of the previous transformation.

type ExecLogFunc

type ExecLogFunc func(ctx context.Context, ts time.Duration, sql string, args []interface{}, err error)

ExecLogFunc is called each time when a SQL statement is executed. The "ts" parameter gives the time that the SQL statement takes to execute, sql and args refer the exec params err refer to the result of the execution.

type SealOptions

type SealOptions struct {
	EncodeHook EncodeHookFunc
	ExecLog    ExecLogFunc
	BuildLog   BuildLogFunc
}

SealOptions the global options

func DefaultSealOptions

func DefaultSealOptions() *SealOptions

DefaultSealOptions only contains the EncodeHook

type SealOptionsFunc

type SealOptionsFunc func(opt *SealOptions)

SealOptionsFunc SealOptions

func WithBuildLogger

func WithBuildLogger(blog BuildLogFunc) SealOptionsFunc

WithBuildLogger set the sql build log

func WithEncodeHook

func WithEncodeHook(ehook EncodeHookFunc) SealOptionsFunc

WithEncodeHook set encode hook. we can set nil to encode hook func if we want drop the default encode hook

func WithExecLogger

func WithExecLogger(elog ExecLogFunc) SealOptionsFunc

WithExecLogger set execlog func

type TraceKey

type TraceKey struct{}

链路追踪KEY

var DefaultTraceKey TraceKey = TraceKey{}

默认的TraceKey

Jump to

Keyboard shortcuts

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