utils

package
v0.0.0-...-33f46c2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CronUtils = cronUtils{
	// contains filtered or unexported fields
}
View Source
var TaskExecChanMap = NewChanMap()

Functions

func BackoffErrorNotify

func BackoffErrorNotify(prefix string) backoff.Notify

func BsonMEqual

func BsonMEqual(v1, v2 bson.M) (ok bool)

func BytesToString

func BytesToString(b []byte) string

func CleanupDemo

func CleanupDemo() (err error)

func Close

func Close(c io.Closer)

func Compress

func Compress(files []*os.File, dest string) error

压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func ComputeHmacSha256

func ComputeHmacSha256(message string, secret string) string

func Contains

func Contains(array interface{}, val interface{}) (fla bool)

func CopyDir

func CopyDir(src string, dst string) error

Dir copies a whole directory recursively

func CopyFile

func CopyFile(src, dst string) error

File copies a single file from src to dst

func CreateDirPath

func CreateDirPath(filePath string)

创建文件夹

func DeCompress

func DeCompress(srcFile *os.File, dstPath string) error

func DeCompressByPath

func DeCompressByPath(tarFile, dest string) error

func DecryptAES

func DecryptAES(src string) (res string, err error)

func DefaultWait

func DefaultWait()

func DenormalizeBsonMObjectId

func DenormalizeBsonMObjectId(m bson.M) (res bson.M)

func EncryptAES

func EncryptAES(src string) (res string, err error)

func EncryptMd5

func EncryptMd5(str string) string

func EnvIsTrue

func EnvIsTrue(key string, defaultOk bool) bool

func Exists

func Exists(path string) bool

func FillEmptyFileData

func FillEmptyFileData(data []byte) (res []byte)

func FilterToQuery

func FilterToQuery(f interfaces.Filter) (q bson.M, err error)

FilterToQuery Translate entity.Filter to bson.M

func ForceInitModule

func ForceInitModule(fn func() error) (err error)

func GetAllFilesFromDir

func GetAllFilesFromDir(dirPath string) ([]*os.File, error)

func GetApiAddress

func GetApiAddress() (res string)

func GetArrayItems

func GetArrayItems(array interface{}) (res []interface{}, err error)

func GetCockroachdbSession

func GetCockroachdbSession(ds *models.DataSource) (s db.Session, err error)

func GetCockroachdbSessionWithTimeout

func GetCockroachdbSessionWithTimeout(ds *models.DataSource, timeout time.Duration) (s db.Session, err error)

func GetElasticsearchClient

func GetElasticsearchClient(ds *models.DataSource) (c *elasticsearch.Client, err error)

func GetElasticsearchClientWithTimeout

func GetElasticsearchClientWithTimeout(ds *models.DataSource, timeout time.Duration) (c *elasticsearch.Client, err error)

func GetElasticsearchQuery

func GetElasticsearchQuery(query generic.ListQuery) (buf *bytes.Buffer)

func GetElasticsearchQueryWithOptions

func GetElasticsearchQueryWithOptions(query generic.ListQuery, opts *generic.ListOptions) (buf *bytes.Buffer)

func GetFilesFromDir

func GetFilesFromDir(dirPath string) ([]*os.File, error)

func GetFromDbCache

func GetFromDbCache(key string, getFn func() (string, error)) (res string, err error)

func GetKafkaConnection

func GetKafkaConnection(ds *models.DataSource) (c *kafka.Conn, err error)

func GetKafkaConnectionWithTimeout

func GetKafkaConnectionWithTimeout(ds *models.DataSource, timeout time.Duration) (c *kafka.Conn, err error)

func GetLocalTime

func GetLocalTime(t time.Time) time.Time

func GetLocalTimeString

func GetLocalTimeString(t time.Time) string

func GetMongoClient

func GetMongoClient(ds *models.DataSource) (c *mongo2.Client, err error)

func GetMongoClientWithTimeout

func GetMongoClientWithTimeout(ds *models.DataSource, timeout time.Duration) (c *mongo2.Client, err error)

func GetMongoOpts

func GetMongoOpts(opts *generic.ListOptions) (res *mongo.FindOptions)

func GetMongoQuery

func GetMongoQuery(query generic.ListQuery) (res bson.M)

func GetMssqlSession

func GetMssqlSession(ds *models.DataSource) (s db.Session, err error)

func GetMssqlSessionWithTimeout

func GetMssqlSessionWithTimeout(ds *models.DataSource, timeout time.Duration) (s db.Session, err error)

func GetMysqlSession

func GetMysqlSession(ds *models.DataSource) (s db.Session, err error)

func GetMysqlSessionWithTimeout

func GetMysqlSessionWithTimeout(ds *models.DataSource, timeout time.Duration) (s db.Session, err error)

func GetNodeType

func GetNodeType() string

func GetPostgresqlSession

func GetPostgresqlSession(ds *models.DataSource) (s db.Session, err error)

func GetPostgresqlSessionWithTimeout

func GetPostgresqlSessionWithTimeout(ds *models.DataSource, timeout time.Duration) (s db.Session, err error)

func GetResultHash

func GetResultHash(value interface{}, keys []string) (res string, err error)

func GetRpcParam

func GetRpcParam(key string, params map[string]string) string

获取 RPC 参数

func GetSecretKey

func GetSecretKey() string

func GetSecretKeyBytes

func GetSecretKeyBytes() []byte

func GetSpiderCol

func GetSpiderCol(col string, name string) string

func GetSpiderMd5Str

func GetSpiderMd5Str(file string) string

func GetSqlQuery

func GetSqlQuery(query generic.ListQuery) (res db.Cond)

func GetSqliteSession

func GetSqliteSession(ds *models.DataSource) (s db.Session, err error)

func GetSqliteSessionWithTimeout

func GetSqliteSessionWithTimeout(ds *models.DataSource, timeout time.Duration) (s db.Session, err error)

func GetTimeString

func GetTimeString(t time.Time) string

func GetUserFromArgs

func GetUserFromArgs(args ...interface{}) (u interfaces.User)

func ImportDemo

func ImportDemo() (err error)

func InitGitClientAuth

func InitGitClientAuth(g *models.Git, gitClient *vcs.GitClient)

func InitModule

func InitModule(id interfaces.ModuleId, fn func() error) (err error)

func InitializedDemo

func InitializedDemo() (ok bool)

func IsCancellable

func IsCancellable(status string) bool

func IsDebug

func IsDebug() bool

func IsDemo

func IsDemo() (ok bool)

func IsDir

func IsDir(path string) bool

func IsDocker

func IsDocker() (ok bool)

func IsFile

func IsFile(path string) bool

func IsMaster

func IsMaster() bool

func JsonToBytes

func JsonToBytes(d interface{}) (bytes []byte, err error)

func ListDir

func ListDir(path string) []os.FileInfo

func LogDebug

func LogDebug(msg string)

func NewUUIDString

func NewUUIDString() (res string)

func NormalizeBsonMObjectId

func NormalizeBsonMObjectId(m bson.M) (res bson.M)

func NormalizeObjectId

func NormalizeObjectId(v interface{}) (res interface{})

func ObjectToString

func ObjectToString(params interface{}) string

Object 转化为 String

func OpenFile

func OpenFile(fileName string) *os.File

func ReadFileOneLine

func ReadFileOneLine(fileName string) string

func ReimportDemo

func ReimportDemo() (err error)

func RemoveFiles

func RemoveFiles(path string)

func SetFileVariable

func SetFileVariable(filePath string, key string, value string) error

设置文件变量值 可以理解为将文件中的变量占位符替换为想要设置的值

func ShuffleArray

func ShuffleArray(slice []interface{}) (err error)

func StringArrayContains

func StringArrayContains(arr []string, str string) bool

func TrimFileData

func TrimFileData(data []byte) (res []byte)

func VisualizeContainer

func VisualizeContainer(c *dig.Container) (err error)

Types

type ChanMap

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

func NewChanMap

func NewChanMap() *ChanMap

func (*ChanMap) Chan

func (cm *ChanMap) Chan(key string) chan string

func (*ChanMap) ChanBlocked

func (cm *ChanMap) ChanBlocked(key string) chan string

func (*ChanMap) HasChanKey

func (cm *ChanMap) HasChanKey(key string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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