Documentation
¶
Index ¶
- Variables
- func Batch[S Storer, F Finder[R], R any](db S, finder F, batchNum int, handler func([]R) error) (err error)
- func BatchConcurrent[S Storer, F Finder[R], R any](db S, finder F, batchNum int, handler func([]R) error, concNum int) (err error)
- func BytesToString(b []byte) string
- func CodeIs200(code int) error
- func FindAll[S Storer, F Finder[R], R any](db S, finder F, initial R) (r []R, err error)
- func FindFirst[S Storer, F Finder[R], R any](db S, finder F, res *R) (err error)
- func FindList[S Storer, F Finder[R], R any](db S, finder F, res *[]R) (err error)
- func FindOne[S Storer, F Finder[R], R any](db S, finder F, initial R) (r R, err error)
- func FuncName(skip int, withFileInfo bool) string
- func HashJoin[K comparable, LE, RE, R any](left []LE, right []RE, lk func(item LE) K, rk func(item RE) K, ...) []R
- func JSONExtractor[R any](data []byte) (R, error)
- func KeyBy[K comparable, E any](collection []E, iteratee func(item E) K) map[K]E
- func KeyValueBy[K comparable, E, V any](collection []E, iteratee func(item E) (K, V)) map[K]V
- func MatchError(v any) bool
- func Must(args ...any)
- func Must1[T any](args ...any) (r T)
- func Must2[T1, T2 any](args ...any) (r1 T1, r2 T2)
- func Must3[T1, T2, T3 any](args ...any) (r1 T1, r2 T2, r3 T3)
- func Must4[T1, T2, T3, T4 any](args ...any) (r1 T1, r2 T2, r3 T3, r4 T4)
- func Must5[T1, T2, T3, T4, T5 any](args ...any) (r1 T1, r2 T2, r3 T3, r4 T4, r5 T5)
- func NestedJoin[J, K, R any](left []J, right []K, match func(J, K) bool, mapper func(J, K) R) []R
- func NewError[T any](inner T) error
- func PrintFields(fields []any)
- func RetryWithDeadline(ctx context.Context, d time.Time, f Doer) error
- func RetryWithTimes(ctx context.Context, tryTimes int, f Doer) error
- func SendHTTPRequest[R any](client *http.Client, method string, link string, body io.Reader, ...) (R, error)
- func StringToBytes(s string) []byte
- func WrapConnFindAll[F Finder[R], R any](ctx context.Context, db *sql.DB, finder F, initial R) (r []R, err error)
- func WrapDB(ctx context.Context, driverName string, dataSourceName string, ...) error
- func WrapSQLConn(ctx context.Context, db *sql.DB, ...) error
- func WrapSQLQueryRows(ctx context.Context, db *sql.DB, stmt string, args []interface{}, ...) error
- func WrapTx(ctx context.Context, db *sql.DB, f func(ctx context.Context, tx *sql.Tx) error) (err error)
- func WrapTxFindAll[F Finder[R], R any](ctx context.Context, db *sql.DB, finder F, initial R) (r []R, err error)
- func XMLExtractor[R any](data []byte) (R, error)
- type CodeChecker
- type DoWithCtx
- type Doer
- type Error
- type ErrorHandler
- type Finder
- type Job
- type ResultExtractor
- type Storer
- type Worker
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWorkerIsStop = errors.New("Worker is stop") ErrNilJobDo = errors.New("Job do field is nil") )
错误
View Source
var DefaultWorker = NewWorker(defaultCount)
DefaultWorker 默认Wroker
View Source
var (
ErrNilDoer = errors.New("f is nil")
)
Functions ¶
func Batch ¶ added in v0.2.0
func Batch[S Storer, F Finder[R], R any](db S, finder F, batchNum int, handler func([]R) error) (err error)
Batch 批量处理查询到的数据
func BatchConcurrent ¶ added in v0.2.0
func BatchConcurrent[S Storer, F Finder[R], R any](db S, finder F, batchNum int, handler func([]R) error, concNum int) (err error)
BatchConcurrent 并发批量处理查询到的数据
func BytesToString ¶ added in v0.5.0
BytesToString converts byte slice to string without a memory allocation.
func HashJoin ¶ added in v0.2.0
func HashJoin[K comparable, LE, RE, R any]( left []LE, right []RE, lk func(item LE) K, rk func(item RE) K, mapper func(LE, RE) R, ) []R
func JSONExtractor ¶ added in v0.2.0
func KeyBy ¶ added in v0.2.0
func KeyBy[K comparable, E any](collection []E, iteratee func(item E) K) map[K]E
KeyBy slice to map, key specified by iteratee, value is slice element
func KeyValueBy ¶ added in v0.2.0
func KeyValueBy[K comparable, E, V any](collection []E, iteratee func(item E) (K, V)) map[K]V
KeyValueBy slice to map, key value specified by iteratee
func MatchError ¶
func NestedJoin ¶ added in v0.2.0
func PrintFields ¶ added in v0.2.0
func PrintFields(fields []any)
func RetryWithDeadline ¶ added in v0.5.0
RetryWithDeadline 如果执行f失败了,在t时间之前重试
func RetryWithTimes ¶ added in v0.5.0
RetryWithTimes 如果执行f失败了,重试tryTimes次
func SendHTTPRequest ¶ added in v0.2.0
func StringToBytes ¶ added in v0.5.0
StringToBytes converts string to byte slice without a memory allocation.
func WrapConnFindAll ¶ added in v0.2.0
func WrapConnFindAll[F Finder[R], R any]( ctx context.Context, db *sql.DB, finder F, initial R, ) (r []R, err error)
WrapConnFindAll query by stmt and args, return values with dest support many rows
func WrapSQLConn ¶ added in v0.2.0
func WrapSQLQueryRows ¶ added in v0.2.0
func WrapSQLQueryRows( ctx context.Context, db *sql.DB, stmt string, args []interface{}, dest ...interface{}, ) error
WrapSQLQueryRows query by stmt and args, return values with dest only support one row
func WrapTxFindAll ¶ added in v0.2.0
func XMLExtractor ¶ added in v0.2.0
Types ¶
type CodeChecker ¶ added in v0.2.0
type Error ¶
type Error[T any] struct { // contains filtered or unexported fields }
func ConvertError ¶
type ResultExtractor ¶ added in v0.2.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.