utils

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileIsExisted added in v1.0.30

func FileIsExisted(path string) bool

func GetCtxKeyDateTimeFormatFixFields

func GetCtxKeyDateTimeFormatFixFields(ctx context.Context) map[string]string

func GetCtxKeyIgnoreSystemIndex added in v1.0.10

func GetCtxKeyIgnoreSystemIndex(ctx context.Context) bool

func GetCtxKeySourceESVersion

func GetCtxKeySourceESVersion(ctx context.Context) string

func GetCtxKeySourceFieldMap

func GetCtxKeySourceFieldMap(ctx context.Context) map[string]interface{}

func GetCtxKeySourceIndexSetting

func GetCtxKeySourceIndexSetting(ctx context.Context) interface{}

func GetCtxKeySourceObject added in v1.0.30

func GetCtxKeySourceObject(ctx context.Context) string

func GetCtxKeyTargetESVersion

func GetCtxKeyTargetESVersion(ctx context.Context) string

func GetCtxKeyTargetFieldMap

func GetCtxKeyTargetFieldMap(ctx context.Context) map[string]interface{}

func GetCtxKeyTargetIndexSetting

func GetCtxKeyTargetIndexSetting(ctx context.Context) interface{}

func GetCtxKeyTargetObject added in v1.0.30

func GetCtxKeyTargetObject(ctx context.Context) string

func GetCtxKeyTaskAction

func GetCtxKeyTaskAction(ctx context.Context) string

func GetCtxKeyTaskID

func GetCtxKeyTaskID(ctx context.Context) string

func GetCtxKeyTaskName

func GetCtxKeyTaskName(ctx context.Context) string

func GetFirstKeyMapValue added in v1.1.0

func GetFirstKeyMapValue(m map[string]interface{}) (string, map[string]interface{})

func GetLogger

func GetLogger(ctx context.Context) *log.Entry

func GetSubDirectories added in v1.0.30

func GetSubDirectories(dir string) ([]string, error)

func GetTaskLogger added in v1.1.4

func GetTaskLogger(ctx context.Context) *log.Entry

func GetValueFromMapByPath added in v1.1.0

func GetValueFromMapByPath(data map[string]interface{}, path string) (interface{}, bool)

func GoRecovery

func GoRecovery(ctx context.Context, f func())

func InitLogger

func InitLogger(cfg *config.Config)

func InsertSlice added in v1.1.0

func InsertSlice[T any](slice []T, index int, value T) []T

func IsCustomError added in v1.0.35

func IsCustomError(err error, code ErrCode) bool

func MaxAtomicUint64 added in v1.0.35

func MaxAtomicUint64() *atomic.Uint64

func NewCustomError added in v1.0.35

func NewCustomError(code ErrCode, format string, args ...any) error

NewCustomError creates a new CustomError with the given code and message.

func Recovery

func Recovery(ctx context.Context)

func SetCtxKeyDateTimeFormatFixFields

func SetCtxKeyDateTimeFormatFixFields(ctx context.Context, fields map[string]string) context.Context

func SetCtxKeyIgnoreSystemIndex added in v1.0.10

func SetCtxKeyIgnoreSystemIndex(ctx context.Context, ignoreSystemIndex bool) context.Context

func SetCtxKeySourceESVersion

func SetCtxKeySourceESVersion(ctx context.Context, version string) context.Context

func SetCtxKeySourceFieldMap

func SetCtxKeySourceFieldMap(ctx context.Context, fieldMap map[string]interface{}) context.Context

func SetCtxKeySourceIndexSetting

func SetCtxKeySourceIndexSetting(ctx context.Context, setting interface{}) context.Context

func SetCtxKeySourceObject added in v1.0.30

func SetCtxKeySourceObject(ctx context.Context, obj string) context.Context

func SetCtxKeyTargetESVersion

func SetCtxKeyTargetESVersion(ctx context.Context, version string) context.Context

func SetCtxKeyTargetFieldMap

func SetCtxKeyTargetFieldMap(ctx context.Context, fieldMap map[string]interface{}) context.Context

func SetCtxKeyTargetIndexSetting

func SetCtxKeyTargetIndexSetting(ctx context.Context, setting interface{}) context.Context

func SetCtxKeyTargetObject added in v1.0.30

func SetCtxKeyTargetObject(ctx context.Context, index string) context.Context

func SetCtxKeyTaskAction

func SetCtxKeyTaskAction(ctx context.Context, action string) context.Context

func SetCtxKeyTaskID

func SetCtxKeyTaskID(ctx context.Context, id string) context.Context

func SetCtxKeyTaskName

func SetCtxKeyTaskName(ctx context.Context, name string) context.Context

func SetCtxKeyTaskProgress added in v1.1.4

func SetCtxKeyTaskProgress(ctx context.Context, taskProgress *TaskProgress) context.Context

func SetValueFromMapByPath added in v1.1.0

func SetValueFromMapByPath(data map[string]interface{}, path string, value interface{}) bool

func ZeroAtomicUint64 added in v1.0.35

func ZeroAtomicUint64() *atomic.Uint64

Types

type CtxKey

type CtxKey string
const (
	CtxKeySourceESVersion CtxKey = "sourceEsVersion"
	CtxKeyTargetESVersion CtxKey = "targetEsVersion"
	CtxKeySourceObject    CtxKey = "sourceObject"
	CtxKeyTargetObject    CtxKey = "targetObject"
	CtxKeyTaskName        CtxKey = "taskName"
	CtxKeyTaskID          CtxKey = "taskId"
	CtxKeyTaskAction      CtxKey = "taskAction"

	CtxKeySourceIndexSetting CtxKey = "sourceIndexSetting"
	CtxKeyTargetIndexSetting CtxKey = "targetIndexSetting"

	CtxKeySourceFieldMap CtxKey = "sourceFieldMap"
	CtxKeyTargetFieldMap CtxKey = "targetFieldMap"

	CtxKeyDateTimeFormatFixFields CtxKey = "dateTimeFormatFixFields"

	CtxKeyIgnoreSystemIndex CtxKey = "ignoreSystemIndex"

	CtxKeyTaskProgress CtxKey = "taskProgress"
)

type CustomError added in v1.0.35

type CustomError struct {
	Code    ErrCode
	Message string
}

func (*CustomError) Error added in v1.0.35

func (e *CustomError) Error() string

Error implements the error interface for CustomError.

type ErrCode added in v1.0.35

type ErrCode int
const (
	NonIndexExisted ErrCode = 1000
)

type Errs

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

Errs is an error that collects other errors, for when you want to do several things and then report all of them.

func (*Errs) Add

func (e *Errs) Add(err error)

func (*Errs) As

func (e *Errs) As(target interface{}) bool

func (*Errs) Error

func (e *Errs) Error() string

func (*Errs) Is

func (e *Errs) Is(target error) bool

func (*Errs) IsEmpty

func (e *Errs) IsEmpty() bool

func (*Errs) Len

func (e *Errs) Len() int

func (*Errs) Ret

func (e *Errs) Ret() error

type TaskProgress added in v1.1.4

type TaskProgress struct {
	TotalPairs    int
	FinishedPairs atomic.Int32
}

func GetCtxKeyTaskProgress added in v1.1.4

func GetCtxKeyTaskProgress(ctx context.Context) *TaskProgress

Jump to

Keyboard shortcuts

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