gozen

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 75 Imported by: 9

README

gozen

特性
快速创建项目
封装支持常用中间件:mysql、redis、mongodb、es
分层运行:http、grpc、script
链路跟踪使用skywalking

模块
config:配置
util:工具
dao:数据访问
model:数据模型
gin配置路由

生命周期说明

启动

0、扫描配置检测格式并配置写进内存
1、针对配置进行初始化操作:db连接池、grpc连接池、cache连接池或其他服务检测可用性
2、启动http或grpc服务

关闭
0、信号通知进程关闭,进入关闭流程http、grpc走shutdown流程
1、shutdown中针对配置之前初始化的服务进行主动close操作

redis

封装 github.com/go-redis/redis

redis 主从
配置多个主节点,

redis cluster

包含侵入非通用redis地址获取代码


Documentation

Index

Constants

View Source
const (
	MongoReadModePrimary            = "Primary"
	MongoReadModePrimaryPreferred   = "PrimaryPreferred"
	MongoReadModeSecondary          = "Secondary"
	MongoReadModeSecondaryPreferred = "SecondaryPreferred"
	MongoReadModeNearest            = "Nearest"
	MongoReadModeEventual           = "Eventual"
	MongoReadModeMonotonic          = "Monotonic"
	MongoReadModeStrong             = "Strong"
)
View Source
const (
	LogNameDefault = "default"
	LogNameRedis   = "redis"
	LogNameMysql   = "mysql"
	LogNameMongodb = "mongodb"
	LogNameApi     = "api"
	LogNameAo      = "ao"
	LogNameGRpc    = "grpc"
	LogNameEs      = "es"
	LogNameTmq     = "tmq"
	LogNameAmq     = "amq"
	LogNameLogic   = "logic"
	LogNameFile    = "file"
	LogNameNet     = "net"
)
View Source
const (
	LogKNameCommonErr       = "log-common-err"
	LogKNameCommonFields    = "log-common-fields"
	LogKNameCommonCondition = "log-common-condition"
	LogKNameCommonAddress   = "log-common-address"
	LogKNameCommonName      = "log-common-name"
	LogKNameCommonCmd       = "log-common-cmd"
	LogKNameCommonData      = "log-common-data"
	LogKNameCommonDataType  = "log-common-data-type"
	LogKNameCommonKey       = "log-common-key"
	LogKNameCommonValue     = "log-common-value"
	LogKNameCommonUrl       = "log-common-url"
	LogKNameCommonNum       = "log-common-num"
	LogKNameCommonId        = "log-common-id"
	LogKNameCommonUid       = "log-common-uid"
	LogKNameCommonCode      = "log-common-code"
	LogKNameCommonLevel     = "log-common-level"
	LogKNameCommonCookie    = "log-common-cookie"
	LogKNameCommonReq       = "log-common-req"
	LogKNameCommonRes       = "log-common-res"
	LogKNameCommonTime      = "log-common-time"
	LogKNameCommonTenantId  = "log-common-tenant-id"
	LogKNameCommonRecordId  = "log-common-record-id"
	LogKNameCommonUniqueId  = "log-common-unique-id"

	LogKNameRedisKey  = "log-redis-key"
	LogKNameRedisData = "log-redis-data"

	LogKNameMysqlParam = "log-mysql-param"
	LogKNameMysqlData  = "log-mysql-data"

	LogKNameMongodbParam = "log-mongodb-param"
	LogKNameMongodbData  = "log-mongodb-data"

	LogKNameApiParam = "log-api-param"
	LogKNameApiUrl   = "log-api-url"
	LogKNameApiRes   = "log-api-res"

	LogKNameAoParam = "log-ao-param"
	LogKNameAoReq   = "log-ao-req"
	LogKNameAoRes   = "log-ao-res"

	LogKNameGRpcReq = "log-grpc-req"
	LogKNameGRpcRes = "log-grpc-res"

	LogKNameEsReq = "log-es-req"
	LogKNameEsRes = "log-es-res"

	LogKNameTmqTopic = "log-tmq-topic"
	LogKNameTmqReq   = "log-tmq-req"
	LogKNameTmqRes   = "log-tmq-res"
)
View Source
const (
	PConstCodeOK               = 0    //成功
	PConstCodeCommonOK         = 1001 //成功
	PConstCodeAccessFail       = 1002 //无权访问
	PConstCodeServerBusy       = 1003 //服务器繁忙
	PConstCodeParamsIncomplete = 1004 //参数不全
	PConstCodeUserNoLogin      = 1005 //用户未登录
	PConstCodeUserNoLoginApp   = 1024 //APP用户未登录
	PConstCodeBusinessError    = 1010 //业务方错误

)

公共code 0 - 10000

View Source
const (

	//server 节点
	SpanGRpcServer   = "GRpcServer"
	SpanHttpServer   = "HttpServer"
	SpanScriptServer = "ScriptServer"

	//service 节点
	SpanServiceOpen = "ServiceOpen" //公开逻辑
	SpanServiceBase = "ServiceBase" //基础逻辑

	//middleware 节点
	SpanMiddlewareLogic = "MiddlewareLogic"

	//dao 节点
	SpanDaoMysql   = "DaoMySQL"
	SpanDaoRedis   = "DaoRedis"
	SpanDaoMongoDb = "DaoMongoDB"
	SpanDaoApi     = "DaoAPI"
	SpanDaoAo      = "DaoAO"
	SpanDaoEs      = "DaoES"
	SpanDaoGRpc    = "DaoGRpc"
	SpanDaoMQ      = "DaoMQ"
)
View Source
const (
	TracerSw8  = propagation.Header
	TracerSw8C = propagation.HeaderCorrelation
)
View Source
const (
	TracerSpanLayerUnknown      = v3.SpanLayer_Unknown
	TracerSpanLayerDatabase     = v3.SpanLayer_Database
	TracerSpanLayerRPCFramework = v3.SpanLayer_RPCFramework
	TracerSpanLayerHttp         = v3.SpanLayer_Http
	TracerSpanLayerMQ           = v3.SpanLayer_MQ
	TracerSpanLayerCache        = v3.SpanLayer_Cache
)

span layer

View Source
const (
	SignVersionOld = 1
	SignVersionNew = 2

	SignVersionNewPrefix = "1_"
)
View Source
const (
	Letters         = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#$%&*+=?@^_|-"
	LettersNoSymbol = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
)
View Source
const (
	ComponentIDX int32 = 5000 + iota
)

组件ID Golang程序使用范围是[5000, 6000)

View Source
const (
	CurlHeaderKeyContentType = "Content-Type"
)

Variables

View Source
var (
	GReporter go2sky.Reporter
	GTracer   *go2sky.Tracer
)
View Source
var (
	RollBus = NewEventBus(20)
)

Functions

func AesCbcDecrypt

func AesCbcDecrypt(key string, iv string, src []byte) (data []byte, err error)

解密数据

func AesCbcDecryptBase64

func AesCbcDecryptBase64(key string, iv string, str string) (data []byte, err error)

func AesCbcEncrypt

func AesCbcEncrypt(key string, iv string, data []byte) ([]byte, error)

加密数据

func BindParams

func BindParams(c *gin.Context, params interface{}) (code int, err error)

func BindParamsWithBody

func BindParamsWithBody(c *gin.Context, params interface{}) (code int, err error)

func CloseDaoMongo

func CloseDaoMongo() error

func CloseGRpcPool

func CloseGRpcPool()

func CloseSkyWalking

func CloseSkyWalking()

func ConfigAppFailOverGet

func ConfigAppFailOverGet(key string) (string, error)

func ConfigAppFailoverGet

func ConfigAppFailoverGet(key string) (string, error)

func ConfigAppGet

func ConfigAppGet(key string) interface{}

func ConfigAppGetSlice

func ConfigAppGetSlice(key string, data interface{}) error

ConfigAppGetSlice 获取slice配置,data必须是指针slice *[],目前支持string,int,int64,bool,float64,float32

func ConfigAppGetString

func ConfigAppGetString(key string, defaultConfig string) string

func ConfigAppGetValue

func ConfigAppGetValue[T []interface{} | int | int8 | int16 | int32 | int64 | string | float32 | float64 | bool](key string, defaultData T) T

func ConfigAppGetValueArr

func ConfigAppGetValueArr[T int | int8 | int16 | int32 | int64 | string | float32 | float64 | bool](key string, defaultData []T) (ret []T)

func ConfigCodeGetMessage

func ConfigCodeGetMessage(code int) string

func ConfigDocsInstanceNameGet

func ConfigDocsInstanceNameGet() string

func ConfigEnvGet

func ConfigEnvGet() string

func ConfigEnvIsBeta

func ConfigEnvIsBeta() bool

func ConfigEnvIsDebug

func ConfigEnvIsDebug() bool

func ConfigEnvIsDev

func ConfigEnvIsDev() bool

func ConfigMongodbClusterGetDbCount

func ConfigMongodbClusterGetDbCount() (n int)

func ConfigMysqlClusterGetDbCount

func ConfigMysqlClusterGetDbCount() (n int)

func Curl

func Curl(ctx context.Context, method string, url string, header map[string]string, body string, timeout time.Duration) (ret []byte, err error)

func CurlDelete

func CurlDelete(ctx context.Context, url string, header []string, timeout time.Duration) (ret []byte, err error)

func CurlGet

func CurlGet(ctx context.Context, url string, header []string, timeout time.Duration) (ret []byte, err error)

func CurlPost

func CurlPost(ctx context.Context, url string, header []string, data string, timeout time.Duration) (ret []byte, err error)

func CurlPostFile

func CurlPostFile(ctx context.Context, url string, reqParams map[string]string, files []UploadFile, timeout time.Duration) (ret []byte, err error)

func CurlPut

func CurlPut(ctx context.Context, url string, header []string, data string, timeout time.Duration) (ret []byte, err error)

func EntrySpan

func EntrySpan(peer string, operationName string, layer v3.SpanLayer) (span go2sky.Span, subCtx context.Context, err error)

func ExitSpan

func ExitSpan(ctx context.Context, peer string, operationName string, layer v3.SpanLayer) (span go2sky.Span, err error)

func ExitSpanGRpc

func ExitSpanGRpc(ctx context.Context, peer string, operationName string, layer v3.SpanLayer) (span go2sky.Span, ctxValue context.Context, err error)

放数据到header内

func GetConfigProjectConfigsPath

func GetConfigProjectConfigsPath() (path string)

func GoFunc

func GoFunc(f ...func() error) (err error)

func GoFuncOne

func GoFuncOne(f func() error)

func InitGRpcPool

func InitGRpcPool()

初始化连接池

func InitSkyWalking

func InitSkyWalking()

*

span component Golang程序使用范围是[5000, 6000)

func InjectorNull

func InjectorNull(headerKey, headerValue string) error

func JSONDecodeUseNumber

func JSONDecodeUseNumber(body []byte, obj any) (err error)

JSONDecodeUseNumber 解析json,舍弃科学计数法

func LimitHandlerByIP

func LimitHandlerByIP(lmt *limiter.Limiter) gin.HandlerFunc

按照请求ip限流

func LimitHandlerByKey

func LimitHandlerByKey(lmt *limiter.Limiter, key string) gin.HandlerFunc

按照key限流

func ListenGrpc

func ListenGrpc(grpcPort string, srv *grpc.Server)

func ListenHttp

func ListenHttp(httpPort string, r http.Handler, timeout int, f ...func())

func LocalSpan

func LocalSpan(ctx context.Context, peer string, operationName string, layer v3.SpanLayer) (span go2sky.Span, subCtx context.Context, err error)

func LogDPanic

func LogDPanic(logName string, args ...interface{})

LogDPanic dpanic debug模式下 当前协程panic

func LogDPanicf

func LogDPanicf(logName string, template string, args ...interface{})

func LogDPanicw

func LogDPanicw(logName string, msg string, keysAndValues ...interface{})

func LogDebug

func LogDebug(logName string, args ...interface{})

LogDebug debug debug模式下会记录

func LogDebugf

func LogDebugf(logName string, template string, args ...interface{})

func LogDebugw

func LogDebugw(logName string, msg string, keysAndValues ...interface{})

func LogError

func LogError(logName string, args ...interface{})

LogError error 有异常跟踪

func LogErrorf

func LogErrorf(logName string, template string, args ...interface{})

func LogErrorw

func LogErrorw(logName string, msg string, keysAndValues ...interface{})

func LogFatal

func LogFatal(logName string, args ...interface{})

LogFatal fatal 服务会终止

func LogFatalf

func LogFatalf(logName string, template string, args ...interface{})

func LogFatalw

func LogFatalw(logName string, msg string, keysAndValues ...interface{})

func LogInfo

func LogInfo(logName string, args ...interface{})

LogInfo info 记录信息

func LogInfof

func LogInfof(logName string, template string, args ...interface{})

func LogInfow

func LogInfow(logName string, msg string, keysAndValues ...interface{})

func LogPanic

func LogPanic(logName string, args ...interface{})

LogPanic panic 当前协程panic

func LogPanicf

func LogPanicf(logName string, template string, args ...interface{})

func LogPanicw

func LogPanicw(logName string, msg string, keysAndValues ...interface{})

func LogSync

func LogSync()

func LogWarn

func LogWarn(logName string, args ...interface{})

LogWarn warn 有异常跟踪

func LogWarnf

func LogWarnf(logName string, template string, args ...interface{})

func LogWarnw

func LogWarnw(logName string, msg string, keysAndValues ...interface{})

func MiddlewareGRpcUnaryInterceptorTracer

func MiddlewareGRpcUnaryInterceptorTracer() grpc.UnaryServerInterceptor

func MiddlewareHttp

func MiddlewareHttp() gin.HandlerFunc

func NewGin

func NewGin(param ...string) *gin.Engine

NewGin 新建gin

func NewLimiter

func NewLimiter(max float64, burst int, code int, msg ...string) (lmt *limiter.Limiter)

创建一个限制器 max 每秒产生令牌数 burst 令牌桶容量,用于处理突发请求 code 限制提示code msg 限制提示信息

func PKCS5Padding

func PKCS5Padding(cipherText []byte, blockSize int) []byte

* PKCS5包装

func PKCS5Trimming

func PKCS5Trimming(encrypt []byte) []byte

解包装

func PathExists

func PathExists(path string) (bool, error)

func Recovery

func Recovery() gin.HandlerFunc

func RedisGetAddress

func RedisGetAddress(conf *ConfigCacheRedis) (addr string, index int32, err error)

func RegisterOnShutdown

func RegisterOnShutdown(f func(cancel context.CancelFunc), timeout time.Duration)

func RunFuncName

func RunFuncName() string

skip 2 当前函数

func RunFuncNameSkip

func RunFuncNameSkip(skip int) string

func RunFuncNameUp

func RunFuncNameUp() string

skip 3 父级函数

func SetLogTimeSwitch

func SetLogTimeSwitch(b bool)

func SpanComponent

func SpanComponent(span go2sky.Span, component int32)

func SpanEnd

func SpanEnd(span go2sky.Span)

func SpanError

func SpanError(span go2sky.Span, data ...string)

func SpanErrorFast

func SpanErrorFast(span go2sky.Span, err error)

func SpanLog

func SpanLog(span go2sky.Span, data ...string)

func SpanTag

func SpanTag(span go2sky.Span, key go2sky.Tag, value string)

func SubStr

func SubStr(str string, start int, length int) (result string)

length:截取长度,负数表示截取到末尾

func TracerDisabled

func TracerDisabled() bool

func UtilCryptoGenerateRandomToken

func UtilCryptoGenerateRandomToken(n int) (string, error)

func UtilCryptoGenerateRandomToken16

func UtilCryptoGenerateRandomToken16() (string, error)

func UtilCryptoGenerateRandomToken32

func UtilCryptoGenerateRandomToken32() (string, error)

func UtilCryptoMD5

func UtilCryptoMD5(str string) string

func UtilCryptoMD5Lower

func UtilCryptoMD5Lower(str string) string

func UtilCryptoMd5

func UtilCryptoMd5(s string) string

func UtilCryptoMd5Lower

func UtilCryptoMd5Lower(s string) string

func UtilCryptoSha1

func UtilCryptoSha1(s string) string

func UtilFloat64ToInt

func UtilFloat64ToInt(value float64, multiplied float64) (intValue int, err error)

func UtilGetStringArrayFromInt64Array

func UtilGetStringArrayFromInt64Array(data []int64) []string

func UtilGetStringArrayFromIntArray

func UtilGetStringArrayFromIntArray(data []int) []string

func UtilGetStringFromInt64Array

func UtilGetStringFromInt64Array(data []int64, sep string) string

func UtilGetStringFromIntArray

func UtilGetStringFromIntArray(data []int, sep string) string

func UtilGetUrlHost

func UtilGetUrlHost(urlPath string) (host string)

func UtilIsEmpty

func UtilIsEmpty(data string) bool

func UtilLogDebug

func UtilLogDebug(msg string)

func UtilLogDebugf

func UtilLogDebugf(format string, a ...interface{})

func UtilLogError

func UtilLogError(msg string)

func UtilLogErrorf

func UtilLogErrorf(format string, a ...interface{})

func UtilLogInfo

func UtilLogInfo(msg string)

func UtilLogInfof

func UtilLogInfof(format string, a ...interface{})

func UtilMQSend

func UtilMQSend(key string, data interface{}) error

func UtilRequestGetAllParams

func UtilRequestGetAllParams(c *gin.Context) (ret url.Values)

func UtilRequestGetParam

func UtilRequestGetParam(c *gin.Context, key string) string

func UtilRequestQueryDataString

func UtilRequestQueryDataString(c *gin.Context) string

func UtilResponseRedirect

func UtilResponseRedirect(c *gin.Context, url string)

func UtilResponseReturnJson

func UtilResponseReturnJson(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJson400

func UtilResponseReturnJson400(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJson500

func UtilResponseReturnJson500(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJsonFailed

func UtilResponseReturnJsonFailed(c *gin.Context, code int)

func UtilResponseReturnJsonNoP

func UtilResponseReturnJsonNoP(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJsonNoPReal

func UtilResponseReturnJsonNoPReal(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJsonReal

func UtilResponseReturnJsonReal(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJsonStatus

func UtilResponseReturnJsonStatus(c *gin.Context, code int, model interface{}, msg ...string)

func UtilResponseReturnJsonSuccess

func UtilResponseReturnJsonSuccess(c *gin.Context, data interface{})

func UtilResponseReturnJsonWithMsg

func UtilResponseReturnJsonWithMsg(c *gin.Context, code int, msg string, model interface{},
	callbackFlag bool, unifyCode bool, status int)

func UtilSignCheckSign

func UtilSignCheckSign(c *gin.Context, token string) bool

func UtilSignCheckSignTimestamp

func UtilSignCheckSignTimestamp(c *gin.Context) (ts string, b bool)

检测请求时间是否有效

func UtilSignGetSortUpParamsString

func UtilSignGetSortUpParamsString(ps url.Values) string

升序排序的参数拼接的字符串

func UtilSplitToInt64Array

func UtilSplitToInt64Array(data string, sep string) []int64

func UtilSplitToIntArray

func UtilSplitToIntArray(data string, sep string) []int

func UtilStringCheckStringExisted

func UtilStringCheckStringExisted(strs []string, str string) bool

func UtilStringConcat

func UtilStringConcat(buffer *bytes.Buffer, str string)

func UtilStringConcatExist

func UtilStringConcatExist(strs []string, str string) []string

func UtilStringContains

func UtilStringContains(obj interface{}, target interface{}) bool

func UtilStringGenerateRandomString

func UtilStringGenerateRandomString(n int) string

func UtilStringGenerateRandomStringNoSymbol

func UtilStringGenerateRandomStringNoSymbol(n int) string

func UtilTimeConsumePrint

func UtilTimeConsumePrint(timeBefore time.Time, prefix string)

UtilTimeConsumePrint print time consume

func UtilTimeDiffDay

func UtilTimeDiffDay(t1 time.Time, t2 time.Time) int

func UtilTimeFewDaysLater

func UtilTimeFewDaysLater(day int) time.Time

func UtilTimeFewDurationLater

func UtilTimeFewDurationLater(duration time.Duration) time.Time

func UtilTimeGetDate

func UtilTimeGetDate(t time.Time) time.Time

func UtilTimeIsExpired

func UtilTimeIsExpired(expirationTime time.Time) bool

func UtilTimeIsLeapYear

func UtilTimeIsLeapYear(y int) bool

func UtilTimeIsToday

func UtilTimeIsToday(t time.Time) bool

func UtilTimeSameDay

func UtilTimeSameDay(t1 time.Time, t2 time.Time) bool

func UtilTimeSixHoursLater

func UtilTimeSixHoursLater() time.Time

func UtilTimeTwentyFourHoursLater

func UtilTimeTwentyFourHoursLater() time.Time

Types

type BaseMongo

type BaseMongo struct {
	CreatedAt time.Time `bson:"created_at,omitempty"`
	UpdatedAt time.Time `bson:"updated_at,omitempty"`
}

type BaseMongoEx

type BaseMongoEx struct {
	CreatedAt time.Time `bson:"created_at,omitempty" json:"created_at"`
	UpdatedAt time.Time `bson:"updated_at,omitempty" json:"updated_at"`
}

type CacheClient

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

type ConfigApp

type ConfigApp struct {
	Configs map[string]interface{} `yaml:"Configs"`
}

type ConfigCache

type ConfigCache struct {
	Redis   ConfigCacheRedis   `yaml:"Redis"`
	RedisP  ConfigCacheRedis   `yaml:"RedisP"` // 持久化Redis
	Dynamic ConfigCacheDynamic `yaml:"Dynamic"`
	NoProxy ConfigCacheNoProxy `yaml:"NoProxy"` // 平台去代理模式
}

type ConfigCacheDynamic

type ConfigCacheDynamic struct {
	IsDynamic      bool   `yaml:"IsDynamic"`      //是否开启代理
	DynamicAddress string `yaml:"DynamicAddress"` //代理地址
	CycleTime      int    `yaml:"CycleTime"`      //循环获取时间 秒
	CycleFlagTime  int    `yaml:"CycleFlagTime"`
}

func ConfigCacheGetRedisDynamic

func ConfigCacheGetRedisDynamic() *ConfigCacheDynamic

type ConfigCacheNoProxy

type ConfigCacheNoProxy struct {
	IsNoProxy      bool   `yaml:"IsNoProxy"`      //是否开启代理
	ServiceAddress string `yaml:"ServiceAddress"` //获取服务地址
	MonitorAddress string `yaml:"MonitorAddress"` //监控上报地址
	Lang           string `yaml:"Lang"`           //lang
	AppCode        string `yaml:"AppCode"`        //app code
	Iv             string `yaml:"Iv"`             //iv
	MonitorTime    int    `yaml:"MonitorTime"`    //心跳时间 秒
}

type ConfigCacheRedis

type ConfigCacheRedis struct {
	Address []string `yaml:"Address"` //多个ip节点,每个都是单独访问,循环建立连接

	Bid             string `yaml:"Bid"`             //bid
	Prefix          string `yaml:"Prefix"`          //前缀
	Cluster         bool   `yaml:"Cluster"`         //是否集群模式 集群模式走不一样的初始化和curd
	Expire          int    `yaml:"Expire"`          // 缓存默认时间
	ReadTimeout     int    `yaml:"ReadTimeout"`     //读超时时间
	WriteTimeout    int    `yaml:"WriteTimeout"`    //写超时时间
	ConnectTimeout  int    `yaml:"ConnectTimeout"`  //建立连接的超时时间
	PoolMaxActive   int    `yaml:"PoolMaxActive"`   //池子最大连接数
	PoolMinActive   int    `yaml:"PoolMinActive"`   //池子空闲连接数
	PoolIdleTimeout int    `yaml:"PoolIdleTimeout"` //连接存活时间 超出时间后 连接会重置 要小于服务端链接存活时间
	Password        string `yaml:"Password"`
	// contains filtered or unexported fields
}

func ConfigCacheGetRedis

func ConfigCacheGetRedis() *ConfigCacheRedis

func ConfigCacheGetRedisBaseWithConn

func ConfigCacheGetRedisBaseWithConn(persistent bool) *ConfigCacheRedis

func ConfigCacheGetRedisWithConn

func ConfigCacheGetRedisWithConn(persistent bool) *ConfigCacheRedis

type ConfigCodeList

type ConfigCodeList struct {
	Codes map[string]string `yaml:"Codes"`
}

type ConfigDb

type ConfigDb struct {
	Mysql ConfigMysql `yaml:"Mysql"`
	Mongo ConfigMongo `yaml:"Mongo"`
}

func NewConfigDb

func NewConfigDb() *ConfigDb

type ConfigDbBase

type ConfigDbBase struct {
	Address  string `yaml:"Address"`
	Port     int    `yaml:"Port"`
	User     string `yaml:"User"`
	Password string `yaml:"Password"`
	DbName   string `yaml:"-" json:"-"`
}

type ConfigDbPool

type ConfigDbPool struct {
	PoolMinCap      int `yaml:"PoolMinCap"`
	PoolMaxCap      int `yaml:"PoolMaxCap"`
	PoolIdleTimeout int `yaml:"PoolIdleTimeout"` //最大空闲时间
	PoolLifeTimeout int `yaml:"PoolLifeTimeout"` //最大生命时间
}

type ConfigES

type ConfigES struct {
	Address             []string `yaml:"Address"`
	Timeout             int      `yaml:"Timeout"`
	TransportMaxIdel    int      `yaml:"TransportMaxIdel"`
	HealthcheckEnabled  bool     `yaml:"HealthcheckEnabled"`
	HealthcheckTimeout  int      `yaml:"HealthcheckTimeout"`
	HealthcheckInterval int      `yaml:"HealthcheckInterval"`
	SnifferEnabled      bool     `yaml:"SnifferEnabled"`
	Account             string   `yaml:"Account"`
	Password            string   `yaml:"Password"`
}

type ConfigMongo

type ConfigMongo struct {
	DbNum                  uint32 `yaml:"DbNum"`                  //库号
	DbName                 string `yaml:"DbName"`                 //库名
	Options                string `yaml:"Options"`                //options
	User                   string `yaml:"User"`                   //用户名
	Password               string `yaml:"Password"`               //密码
	Servers                string `yaml:"Servers"`                //服务ip端口
	ReadOption             string `yaml:"ReadOption"`             //读取模式
	Timeout                int    `yaml:"Timeout"`                //具体操作超时时间 秒
	MaxPoolSize            uint64 `yaml:"MaxPoolSize"`            //最大连接数
	MinPoolSize            uint64 `yaml:"MinPoolSize"`            //最小连接数
	SocketTimeout          int    `yaml:"SocketTimeout"`          //读取写入超时
	ConnectTimeout         int    `yaml:"ConnectTimeout"`         //链接超时时间 默认30s
	MaxConnIdleTime        int    `yaml:"MaxConnIdleTime"`        //最大空闲时间
	ServerSelectionTimeout int    `yaml:"ServerSelectionTimeout"` //节点选择超时时间 默认30s
}

func ConfigMongodbClusterGetOne

func ConfigMongodbClusterGetOne(dbNum uint32) (data *ConfigMongo, ok bool)

func (*ConfigMongo) Get

func (m *ConfigMongo) Get() *ConfigMongo

type ConfigMysql

type ConfigMysql struct {
	DbNum  uint32         `yaml:"DbNum"`  //库号
	DbName string         `yaml:"DbName"` //库名
	Pool   ConfigDbPool   `yaml:"Pool"`   //连接池配置
	Write  ConfigDbBase   `yaml:"Write"`  //写库配置
	Reads  []ConfigDbBase `yaml:"Reads"`  //读库配置
}

func ConfigMysqlClusterGetOne

func ConfigMysqlClusterGetOne(dbNum uint32) (data *ConfigMysql, ok bool)

func NewConfigMysql

func NewConfigMysql() *ConfigMysql

func (*ConfigMysql) GetClusterPool

func (m *ConfigMysql) GetClusterPool() *ConfigDbPool

func (*ConfigMysql) GetClusterRead

func (m *ConfigMysql) GetClusterRead() (config *ConfigDbBase)

func (*ConfigMysql) GetClusterWrite

func (m *ConfigMysql) GetClusterWrite() (config *ConfigDbBase)

func (*ConfigMysql) GetPool

func (m *ConfigMysql) GetPool() *ConfigDbPool

func (*ConfigMysql) GetRead

func (m *ConfigMysql) GetRead() (config *ConfigDbBase)

func (*ConfigMysql) GetWrite

func (m *ConfigMysql) GetWrite() *ConfigDbBase

type ConfigPool

type ConfigPool struct {
	Address              []string `yaml:"Address"`
	MaxIdle              int      `yaml:"MaxIdle"`              //最大空闲
	MaxActive            int      `yaml:"MaxActive"`            //最多链接限制数 0 不限制
	MaxConcurrentStreams int      `yaml:"MaxConcurrentStreams"` //每一个http链接 并发stream数
	Reuse                bool     `yaml:"Reuse"`                //是否重用链接
}

func (*ConfigPool) GetAddressRandom

func (c *ConfigPool) GetAddressRandom() (server string, err error)

func GetAddressRandom get one address random

type ConfigPoolMap

type ConfigPoolMap struct {
	Configs map[string]ConfigPool `yaml:"Configs"`
}

type ConfigProject

type ConfigProject struct {
	Base struct {
		Mode        string `yaml:"mode"`
		Format      string `yaml:"format"`
		ConfigsPath string `yaml:"configs_path"`
	} `yaml:"base"`
	Nacos struct {
		Addr        string   `yaml:"addr"`
		Port        uint64   `yaml:"port"`
		NamespaceId string   `yaml:"namespace_id"`
		Group       string   `yaml:"group"`
		DataId      []string `yaml:"data_id"`
		TimeoutMs   uint64   `yaml:"timeout_ms"`
		LogLevel    string   `yaml:"log_level"`
		Username    string   `yaml:"username"`
		Password    string   `yaml:"password"`
		Interval    int      `yaml:"interval"`
	} `yaml:"nacos"`
	Log struct {
		Name       string `yaml:"name"`
		Path       string `yaml:"path"`
		Debug      bool   `yaml:"debug"`
		MaxSize    int    `yaml:"max_size"`
		MaxAge     int    `yaml:"max_age"`
		MaxBackups int    `yaml:"max_backups"`
		Compress   bool   `yaml:"compress"`
	} `yaml:"log"`
}

type ConfigTracer

type ConfigTracer struct {
	Tracer ConfigTracerData `yaml:"Tracer"`
}
var (
	TracerConfig *ConfigTracer
)

type ConfigTracerData

type ConfigTracerData struct {
	ServiceName string                   `yaml:"ServiceName"`
	Disabled    bool                     `yaml:"Disabled"`
	Sampler     ConfigTracerSamplerData  `yaml:"Sampler"`
	Reporter    ConfigTracerReporterData `yaml:"Reporter"`
}

type ConfigTracerReporterData

type ConfigTracerReporterData struct {
	LogSpans            bool   `yaml:"LogSpans"`
	BufferFlushInterval int    `yaml:"BufferFlushInterval"`
	LocalAgentHostPort  string `yaml:"LocalAgentHostPort"`
}

type ConfigTracerSamplerData

type ConfigTracerSamplerData struct {
	SamplingRate float64 `yaml:"SamplingRate"`
}

type DaoES

type DaoES struct {
	IndexName string
	TypeName  string
	Ctx       context.Context
}

func (*DaoES) CloseConnect

func (p *DaoES) CloseConnect(client *elastic.Client)

func (*DaoES) GetConnect

func (p *DaoES) GetConnect() (*elastic.Client, error)

func (*DaoES) Insert

func (p *DaoES) Insert(id string, data interface{}) error

func (*DaoES) Update

func (p *DaoES) Update(id string, doc interface{}) error

func (*DaoES) UpdateAppend

func (p *DaoES) UpdateAppend(id string, name string, value interface{}) error

type DaoESFactory

type DaoESFactory struct {
}

func (*DaoESFactory) ActivateObject

func (f *DaoESFactory) ActivateObject(object *pool.PooledObject) error

func (*DaoESFactory) DestroyObject

func (f *DaoESFactory) DestroyObject(object *pool.PooledObject) error

func (*DaoESFactory) MakeClient

func (f *DaoESFactory) MakeClient() (*elastic.Client, error)

func (*DaoESFactory) MakeObject

func (f *DaoESFactory) MakeObject() (*pool.PooledObject, error)

func (*DaoESFactory) PassivateObject

func (f *DaoESFactory) PassivateObject(object *pool.PooledObject) error

func (*DaoESFactory) ValidateObject

func (f *DaoESFactory) ValidateObject(object *pool.PooledObject) bool

type DaoESV5

type DaoESV5 struct {
	IndexName string
	TypeName  string
	Ctx       context.Context
}

func (*DaoESV5) CloseConnect

func (p *DaoESV5) CloseConnect(client *elastic.Client)

func (*DaoESV5) GetConnect

func (p *DaoESV5) GetConnect() (*elastic.Client, error)

func (*DaoESV5) Insert

func (p *DaoESV5) Insert(id string, data interface{}) error

func (*DaoESV5) Update

func (p *DaoESV5) Update(id string, doc interface{}) error

func (*DaoESV5) UpdateAppend

func (p *DaoESV5) UpdateAppend(id string, name string, value interface{}) error

type DaoESV5Factory

type DaoESV5Factory struct {
}

func (*DaoESV5Factory) ActivateObject

func (f *DaoESV5Factory) ActivateObject(object *pool.PooledObject) error

func (*DaoESV5Factory) DestroyObject

func (f *DaoESV5Factory) DestroyObject(object *pool.PooledObject) error

func (*DaoESV5Factory) MakeClient

func (f *DaoESV5Factory) MakeClient() (*elastic.Client, error)

func (*DaoESV5Factory) MakeObject

func (f *DaoESV5Factory) MakeObject() (*pool.PooledObject, error)

func (*DaoESV5Factory) PassivateObject

func (f *DaoESV5Factory) PassivateObject(object *pool.PooledObject) error

func (*DaoESV5Factory) ValidateObject

func (f *DaoESV5Factory) ValidateObject(object *pool.PooledObject) bool

type DaoESV6

type DaoESV6 struct {
	IndexName string
	TypeName  string
	Ctx       context.Context
}

func (*DaoESV6) CloseConnect

func (p *DaoESV6) CloseConnect(client *elastic.Client)

func (*DaoESV6) GetConnect

func (p *DaoESV6) GetConnect() (*elastic.Client, error)

func (*DaoESV6) Insert

func (p *DaoESV6) Insert(id string, data interface{}) error

func (*DaoESV6) Update

func (p *DaoESV6) Update(id string, doc interface{}) error

func (*DaoESV6) UpdateAppend

func (p *DaoESV6) UpdateAppend(id string, name string, value interface{}) error

type DaoESV6Factory

type DaoESV6Factory struct {
}

func (*DaoESV6Factory) ActivateObject

func (f *DaoESV6Factory) ActivateObject(object *pool.PooledObject) error

func (*DaoESV6Factory) DestroyObject

func (f *DaoESV6Factory) DestroyObject(object *pool.PooledObject) error

func (*DaoESV6Factory) MakeClient

func (f *DaoESV6Factory) MakeClient() (*elastic.Client, error)

func (*DaoESV6Factory) MakeObject

func (f *DaoESV6Factory) MakeObject() (*pool.PooledObject, error)

func (*DaoESV6Factory) PassivateObject

func (f *DaoESV6Factory) PassivateObject(object *pool.PooledObject) error

func (*DaoESV6Factory) ValidateObject

func (f *DaoESV6Factory) ValidateObject(object *pool.PooledObject) bool

type DaoESV7

type DaoESV7 struct {
	IndexName string
	Ctx       context.Context
}

func (*DaoESV7) AddIndexField

func (p *DaoESV7) AddIndexField(indexName string, data map[string]interface{}) error

func (*DaoESV7) Bulk

func (p *DaoESV7) Bulk(upsertData map[string]interface{}, deleteData []string) error

func (*DaoESV7) BulkDelete

func (p *DaoESV7) BulkDelete(idS []string) error

func (*DaoESV7) BulkUpsert

func (p *DaoESV7) BulkUpsert(idS []string, dataS []interface{}) error

func (*DaoESV7) CloseConnect

func (p *DaoESV7) CloseConnect(client *elastic.Client)

func (*DaoESV7) CreateIndex

func (p *DaoESV7) CreateIndex(indexName string, data interface{}) error

func (*DaoESV7) DelIndex

func (p *DaoESV7) DelIndex(indexName string) error

func (*DaoESV7) GetConnect

func (p *DaoESV7) GetConnect() (*elastic.Client, error)

func (*DaoESV7) IndexPutSettings

func (p *DaoESV7) IndexPutSettings(indexName string, data interface{}) error

func (*DaoESV7) Insert

func (p *DaoESV7) Insert(id string, data interface{}) error

func (*DaoESV7) NewIdsQuery

func (p *DaoESV7) NewIdsQuery() *elastic.IdsQuery

func (*DaoESV7) NewMatchAllQuery

func (p *DaoESV7) NewMatchAllQuery() elastic.Query

func (*DaoESV7) NewQueryStringQuery

func (p *DaoESV7) NewQueryStringQuery(str string) *elastic.QueryStringQuery

func (*DaoESV7) SetIndexName

func (p *DaoESV7) SetIndexName(indexName string)

func (*DaoESV7) Update

func (p *DaoESV7) Update(id string, doc interface{}) error

func (*DaoESV7) UpdateAppend

func (p *DaoESV7) UpdateAppend(id string, value interface{}) error

func (*DaoESV7) Upsert

func (p *DaoESV7) Upsert(id string, doc interface{}) error

func (*DaoESV7) UpsertUseScript

func (p *DaoESV7) UpsertUseScript(id string, doc interface{}, script *elastic.Script) error

type DaoGRPC

type DaoGRPC struct {
	ServerName string
	Ctx        context.Context
}

连接GRPC服务并自建负载均衡

func (*DaoGRPC) CloseConn

func (p *DaoGRPC) CloseConn(conn pool.Conn) (err error)

func (*DaoGRPC) GetConn

func (p *DaoGRPC) GetConn() (conn pool.Conn, err error)

获取连接

type DaoMongo

type DaoMongo struct {
	CollectionName  string
	AutoIncrementId bool
	PrimaryKey      string
	Mode            string
	Ctx             context.Context
}

func NewDaoMongo

func NewDaoMongo() *DaoMongo

func (*DaoMongo) Count

func (p *DaoMongo) Count(condition interface{}) (int, error)

func (*DaoMongo) Distinct

func (p *DaoMongo) Distinct(condition interface{}, field string) (data []interface{}, err error)

func (*DaoMongo) DistinctCount

func (p *DaoMongo) DistinctCount(condition interface{}, field string) (data []DaoMongoCountStruct, err error)

func (*DaoMongo) Find

func (p *DaoMongo) Find(condition interface{}, limit int, skip int, data interface{}, sortFields bson.D) error

func (*DaoMongo) FindOne

func (p *DaoMongo) FindOne(condition interface{}, data interface{}, sortFields bson.D) error

func (*DaoMongo) GetById

func (p *DaoMongo) GetById(id interface{}, data interface{}) error

func (*DaoMongo) GetId

func (p *DaoMongo) GetId() (int64, error)

func (*DaoMongo) GetNextSequence

func (p *DaoMongo) GetNextSequence() (int64, error)

func (*DaoMongo) GetSession

func (p *DaoMongo) GetSession() (session mongo.Session, dbName string, timeout int, err error)

func (*DaoMongo) Insert

func (p *DaoMongo) Insert(data IModelMongo) error

func (*DaoMongo) InsertM

func (p *DaoMongo) InsertM(data []IModelMongo) error

func (*DaoMongo) InsertMReturn

func (p *DaoMongo) InsertMReturn(data []IModelMongo) (insertedIDs []interface{}, err error)

func (*DaoMongo) InsertReturn

func (p *DaoMongo) InsertReturn(data IModelMongo) (insertedID interface{}, err error)

func (*DaoMongo) RemoveAll

func (p *DaoMongo) RemoveAll(selector interface{}) error

func (*DaoMongo) RemoveId

func (p *DaoMongo) RemoveId(id interface{}) error

func (*DaoMongo) SetEventualMode

func (p *DaoMongo) SetEventualMode()

func (*DaoMongo) SetMonotonicMode

func (p *DaoMongo) SetMonotonicMode()

func (*DaoMongo) SetNearestMode

func (p *DaoMongo) SetNearestMode()

func (*DaoMongo) SetPrimaryMode

func (p *DaoMongo) SetPrimaryMode()

func (*DaoMongo) SetPrimaryPreferredMode

func (p *DaoMongo) SetPrimaryPreferredMode()

func (*DaoMongo) SetSecondaryMode

func (p *DaoMongo) SetSecondaryMode()

func (*DaoMongo) SetSecondaryPreferredMode

func (p *DaoMongo) SetSecondaryPreferredMode()

func (*DaoMongo) SetStrongMode

func (p *DaoMongo) SetStrongMode()

func (*DaoMongo) Sum

func (p *DaoMongo) Sum(condition interface{}, sumField string) (int, error)

func (*DaoMongo) Update

func (p *DaoMongo) Update(condition interface{}, data map[string]interface{}) error

func (*DaoMongo) UpdateAllSupported

func (p *DaoMongo) UpdateAllSupported(condition interface{}, updateData interface{}, opts ...*options.UpdateOptions) error

func (*DaoMongo) UpdateOne

func (p *DaoMongo) UpdateOne(condition interface{}, data map[string]interface{}) error

func (*DaoMongo) Upsert

func (p *DaoMongo) Upsert(condition interface{}, data map[string]interface{}) error

func (*DaoMongo) UpsertNum

func (p *DaoMongo) UpsertNum(condition interface{}, data map[string]interface{}) error

type DaoMongoCountStruct

type DaoMongoCountStruct struct {
	Field interface{} `bson:"_id"`   //分组字段 - 可以是各种类型
	Count int         `bson:"count"` //计数
}

type DaoMongodbCluster

type DaoMongodbCluster struct {
	DbExtName    string //库扩展
	TableExtName string //表扩展
	DbSelector   uint32 //库号
	DaoMongo
}

func NewDaoMongodbCluster

func NewDaoMongodbCluster() *DaoMongodbCluster

func (*DaoMongodbCluster) Count

func (p *DaoMongodbCluster) Count(condition interface{}) (int, error)

func (*DaoMongodbCluster) Distinct

func (p *DaoMongodbCluster) Distinct(condition interface{}, field string) (data []interface{}, err error)

Distinct 只返回field的字段

func (*DaoMongodbCluster) DistinctCount

func (p *DaoMongodbCluster) DistinctCount(condition interface{}, field string) (data []DaoMongoCountStruct, err error)

func (*DaoMongodbCluster) Find

func (p *DaoMongodbCluster) Find(condition interface{}, limit int, skip int, data interface{}, sortFields bson.D) error

func (*DaoMongodbCluster) FindOne

func (p *DaoMongodbCluster) FindOne(condition interface{}, data interface{}, sortFields bson.D) error

func (*DaoMongodbCluster) GetById

func (p *DaoMongodbCluster) GetById(id interface{}, data interface{}) error

func (*DaoMongodbCluster) GetId

func (p *DaoMongodbCluster) GetId() (int64, error)

func (*DaoMongodbCluster) GetNextSequence

func (p *DaoMongodbCluster) GetNextSequence() (int64, error)

func (*DaoMongodbCluster) GetSession

func (p *DaoMongodbCluster) GetSession() (session mongo.Session, dbName string, timeout int, err error)

func (*DaoMongodbCluster) Insert

func (p *DaoMongodbCluster) Insert(data IModelMongo) error

func (*DaoMongodbCluster) InsertM

func (p *DaoMongodbCluster) InsertM(data []IModelMongo) error

func (*DaoMongodbCluster) InsertMReturn

func (p *DaoMongodbCluster) InsertMReturn(data []IModelMongo) (insertedIDs []interface{}, err error)

func (*DaoMongodbCluster) InsertReturn

func (p *DaoMongodbCluster) InsertReturn(data IModelMongo) (insertedID interface{}, err error)

func (*DaoMongodbCluster) RemoveAll

func (p *DaoMongodbCluster) RemoveAll(selector interface{}) error

func (*DaoMongodbCluster) RemoveId

func (p *DaoMongodbCluster) RemoveId(id interface{}) error

func (*DaoMongodbCluster) Sum

func (p *DaoMongodbCluster) Sum(condition interface{}, sumField string) (int, error)

func (*DaoMongodbCluster) Update

func (p *DaoMongodbCluster) Update(condition interface{}, data map[string]interface{}) error

func (*DaoMongodbCluster) UpdateOne

func (p *DaoMongodbCluster) UpdateOne(condition interface{}, data map[string]interface{}) error

func (*DaoMongodbCluster) Upsert

func (p *DaoMongodbCluster) Upsert(condition interface{}, data map[string]interface{}) error

func (*DaoMongodbCluster) UpsertNum

func (p *DaoMongodbCluster) UpsertNum(condition interface{}, data map[string]interface{}) error

type DaoMysql

type DaoMysql struct {
	TableName string
	Ctx       context.Context
}

func NewDaoMysql

func NewDaoMysql() *DaoMysql

func (*DaoMysql) Find

func (p *DaoMysql) Find(condition string, data interface{}, skip int, limit int, fields []string, sort string) error

func (*DaoMysql) First

func (p *DaoMysql) First(condition string, data interface{}, sort string) error

func (*DaoMysql) GetReadOrm

func (p *DaoMysql) GetReadOrm() (MysqlConnection, error)

func (*DaoMysql) GetWriteOrm

func (p *DaoMysql) GetWriteOrm() (MysqlConnection, error)

func (*DaoMysql) Insert

func (p *DaoMysql) Insert(model interface{}) error

func (*DaoMysql) Remove

func (p *DaoMysql) Remove(condition string) error

func (*DaoMysql) Select

func (p *DaoMysql) Select(condition string, data interface{}, field ...[]string) error

func (*DaoMysql) SelectWithConn

func (p *DaoMysql) SelectWithConn(orm *MysqlConnection, condition string, data interface{}, field ...[]string) error

SelectWithConn SelectWithConn 事务的时候使用

func (*DaoMysql) Update

func (p *DaoMysql) Update(condition string, sets map[string]interface{}) error

type DaoMysqlCluster

type DaoMysqlCluster struct {
	DbExtName    string //库扩展
	TableExtName string //表扩展
	TableName    string //表名
	DbSelector   uint32 //库号
	Ctx          context.Context
}

func NewDaoMysqlCluster

func NewDaoMysqlCluster() *DaoMysqlCluster

func (*DaoMysqlCluster) Count

func (p *DaoMysqlCluster) Count(condition string, data int64) error

func (*DaoMysqlCluster) First

func (p *DaoMysqlCluster) First(condition string, data interface{}) error

func (*DaoMysqlCluster) GetReadOrm

func (p *DaoMysqlCluster) GetReadOrm() (MysqlConnection, error)

func (*DaoMysqlCluster) GetWriteOrm

func (p *DaoMysqlCluster) GetWriteOrm() (MysqlConnection, error)

func (*DaoMysqlCluster) GetWriteOrmNoDb

func (p *DaoMysqlCluster) GetWriteOrmNoDb() (conn MysqlConnection, err error)

func (*DaoMysqlCluster) Insert

func (p *DaoMysqlCluster) Insert(model interface{}) error

func (*DaoMysqlCluster) Remove

func (p *DaoMysqlCluster) Remove(condition string) error

func (*DaoMysqlCluster) Select

func (p *DaoMysqlCluster) Select(condition string, data interface{}, skip int, limit int, fields []string, sort string) error

func (*DaoMysqlCluster) Update

func (p *DaoMysqlCluster) Update(condition string, sets map[string]interface{}) error

type DaoRedis

type DaoRedis struct {
	KeyName    string
	Persistent bool            // 持久化key
	Ctx        context.Context // 必须定义 否则报错
}

func (*DaoRedis) Del

func (p *DaoRedis) Del(key string) bool

func (*DaoRedis) Exists

func (p *DaoRedis) Exists(key string) (bool, error)

func (*DaoRedis) Expire

func (p *DaoRedis) Expire(key string, expire int) bool

Expire expire

func (*DaoRedis) Get

func (p *DaoRedis) Get(key string, data interface{}) bool

func (*DaoRedis) GetE

func (p *DaoRedis) GetE(key string, data interface{}) error

func (*DaoRedis) GetPTtl

func (p *DaoRedis) GetPTtl(key string) (ttl int64, err error)

GetPTtl:获取key的过期时间,单位为毫秒 如果key不存在返回-2 如果key存在,但是没有设置过期时间,返回-1

func (*DaoRedis) GetRaw

func (p *DaoRedis) GetRaw(key string, data interface{}) (b bool, err error)

返回 1. key是否存在 2. error

func (*DaoRedis) GetRedisConn

func (p *DaoRedis) GetRedisConn() (c redis.UniversalClient, err error)

GetRedisConn 获取redis连接

func (*DaoRedis) GetTtl

func (p *DaoRedis) GetTtl(key string) (ttl int64, err error)

GetTtl 获取key的过期时间,单位为秒

func (*DaoRedis) HDel

func (p *DaoRedis) HDel(key string, data ...interface{}) bool

func (*DaoRedis) HExists

func (p *DaoRedis) HExists(key string, field string) (bool, error)

func (*DaoRedis) HGet

func (p *DaoRedis) HGet(key string, field string, value interface{}) bool

func (*DaoRedis) HGetAll

func (p *DaoRedis) HGetAll(key string, data interface{}) error

func (*DaoRedis) HGetAllIntMap

func (p *DaoRedis) HGetAllIntMap(key string) (err error, data map[string]int64)

func (*DaoRedis) HGetAllStringMap

func (p *DaoRedis) HGetAllStringMap(key string) (err error, data map[string]string)

func (*DaoRedis) HGetE

func (p *DaoRedis) HGetE(key string, field string, value interface{}) error

HGetE 返回error

func (*DaoRedis) HGetRaw

func (p *DaoRedis) HGetRaw(key string, field string, value interface{}) (b bool, err error)

HGetRaw 返回 1. key是否存在 2. error

func (*DaoRedis) HIncrby

func (p *DaoRedis) HIncrby(key string, field string, value int) (int, bool)

hash start

func (*DaoRedis) HLen

func (p *DaoRedis) HLen(key string, data *int) bool

func (*DaoRedis) HMGet

func (p *DaoRedis) HMGet(key string, fields []interface{}, data interface{}) error

func (*DaoRedis) HMSet

func (p *DaoRedis) HMSet(key string, value map[string]interface{}) bool

HMSet value是filed:data

func (*DaoRedis) HMSetE

func (p *DaoRedis) HMSetE(key string, value map[string]interface{}) error

HMSetE value是filed:data

func (*DaoRedis) HSet

func (p *DaoRedis) HSet(key string, field string, value interface{}) bool

func (*DaoRedis) HSetNX

func (p *DaoRedis) HSetNX(key string, field string, value interface{}) (int64, bool)

func (*DaoRedis) Incr

func (p *DaoRedis) Incr(key string) (int, bool)

func (*DaoRedis) IncrBy

func (p *DaoRedis) IncrBy(key string, value int) (int, bool)

func (*DaoRedis) LLen

func (p *DaoRedis) LLen() (int64, error)

func (*DaoRedis) LPop

func (p *DaoRedis) LPop(value interface{}) bool

func (*DaoRedis) LPush

func (p *DaoRedis) LPush(value interface{}) bool

func (*DaoRedis) LREM

func (p *DaoRedis) LREM(count int, data interface{}) int

func (*DaoRedis) LRange

func (p *DaoRedis) LRange(start int, end int, value interface{}) (err error)

func (*DaoRedis) LTRIM

func (p *DaoRedis) LTRIM(start int, end int) (err error)

func (*DaoRedis) MDel

func (p *DaoRedis) MDel(key ...string) bool

func (*DaoRedis) MGet

func (p *DaoRedis) MGet(keys []string, data interface{}) error

func (*DaoRedis) MGetGo

func (p *DaoRedis) MGetGo(keys []string, data interface{}) error

封装mget通过go并发get

func (*DaoRedis) MSet

func (p *DaoRedis) MSet(datas map[string]interface{}) bool

MSet mset

func (*DaoRedis) PipelineHGet

func (p *DaoRedis) PipelineHGet(key []string, fields []interface{}, data []interface{}) error

func (*DaoRedis) Pop

func (p *DaoRedis) Pop(value interface{}, isLeft bool) bool

func (*DaoRedis) Push

func (p *DaoRedis) Push(value interface{}, isLeft bool) bool

func (*DaoRedis) RPop

func (p *DaoRedis) RPop(value interface{}) bool

func (*DaoRedis) RPush

func (p *DaoRedis) RPush(value interface{}) bool

func (*DaoRedis) SAdd

func (p *DaoRedis) SAdd(key string, argPs []interface{}) bool

Set集合Start

func (*DaoRedis) SCard

func (p *DaoRedis) SCard(key string) int64

func (*DaoRedis) SIsMember

func (p *DaoRedis) SIsMember(key string, arg interface{}) bool

func (*DaoRedis) SMembers

func (p *DaoRedis) SMembers(key string, value interface{}) (err error)

func (*DaoRedis) SPop

func (p *DaoRedis) SPop(key string, value interface{}) bool

func (*DaoRedis) SRem

func (p *DaoRedis) SRem(key string, argPs []interface{}) bool

func (*DaoRedis) Set

func (p *DaoRedis) Set(key string, value interface{}) bool

func (*DaoRedis) SetE

func (p *DaoRedis) SetE(key string, value interface{}) error

func (*DaoRedis) SetEx

func (p *DaoRedis) SetEx(key string, value interface{}, expire int) bool

SetEx setex

func (*DaoRedis) SetExE

func (p *DaoRedis) SetExE(key string, value interface{}, expire int) error

SetEx setex

func (*DaoRedis) SetNX

func (p *DaoRedis) SetNX(key string, value interface{}) (int64, bool)

func (*DaoRedis) SetNXNoExpire

func (p *DaoRedis) SetNXNoExpire(key string, value interface{}) (int64, bool)

func (*DaoRedis) ZAdd

func (p *DaoRedis) ZAdd(key string, score interface{}, data interface{}) bool

sorted set start

func (*DaoRedis) ZAddM

func (p *DaoRedis) ZAddM(key string, value map[string]interface{}) bool

sorted set start

func (*DaoRedis) ZCard

func (p *DaoRedis) ZCard(key string) (data int, err error)

func (*DaoRedis) ZCount

func (p *DaoRedis) ZCount(key string, min, max int) (data int, err error)

func (*DaoRedis) ZGet

func (p *DaoRedis) ZGet(key string, sort bool, start int, end int, value interface{}) error

func (*DaoRedis) ZGetByScore

func (p *DaoRedis) ZGetByScore(key string, sort bool, start int, end int, value interface{}) error

func (*DaoRedis) ZGetWithScores

func (p *DaoRedis) ZGetWithScores(key string, sort bool, start int, end int) (err error, data map[string]string)

func (*DaoRedis) ZIncrBy

func (p *DaoRedis) ZIncrBy(key string, increment int, member interface{}) bool

func (*DaoRedis) ZRank

func (p *DaoRedis) ZRank(key string, member string, sort bool) (bool, int)

func (*DaoRedis) ZRem

func (p *DaoRedis) ZRem(key string, data ...interface{}) bool

func (*DaoRedis) ZRevRange

func (p *DaoRedis) ZRevRange(key string, start int, end int, value interface{}) error

func (*DaoRedis) ZScore

func (p *DaoRedis) ZScore(key string, member string, value interface{}) bool

type DaoRedisEx

type DaoRedisEx struct {
	KeyName      string
	Persistent   bool // 持久化key
	ExpireSecond int  // 默认过期时间,单实例有效

	Ctx context.Context // 必须定义 否则报错
	// contains filtered or unexported fields
}

func (*DaoRedisEx) CompareWithAdd

func (p *DaoRedisEx) CompareWithAdd(key string, value int, cvalue int, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) CompareWithReduce

func (p *DaoRedisEx) CompareWithReduce(key string, value int, cvalue int, ops ...OpOptionEx) (int64, error)

存在key, 减值,不能小于0(专用于扣减原子性)

func (*DaoRedisEx) Del

func (p *DaoRedisEx) Del(key string, ops ...OpOptionEx) error

func (*DaoRedisEx) DelWithReply

func (p *DaoRedisEx) DelWithReply(key string, ops ...OpOptionEx) (ret interface{}, err error)

func (*DaoRedisEx) Exists

func (p *DaoRedisEx) Exists(key string, ops ...OpOptionEx) (bool, error)

func (*DaoRedisEx) Expire

func (p *DaoRedisEx) Expire(key string, expire int, ops ...OpOptionEx) error

Expire expire

func (*DaoRedisEx) Get

func (p *DaoRedisEx) Get(key string, data interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) GetExpire

func (p *DaoRedisEx) GetExpire(expire int) int

func (*DaoRedisEx) GetKey

func (p *DaoRedisEx) GetKey(key string) string

func (*DaoRedisEx) GetPTtl

func (p *DaoRedisEx) GetPTtl(key string) (ttl int64, err error)

GetPTtl:获取key的过期时间,单位为毫秒 如果key不存在返回-2 如果key存在,但是没有设置过期时间,返回-1

func (*DaoRedisEx) GetRaw

func (p *DaoRedisEx) GetRaw(key string, data interface{}, ops ...OpOptionEx) (bool, error)

返回 1. key是否存在 2. error

func (*DaoRedisEx) GetRedisConn

func (p *DaoRedisEx) GetRedisConn() (c redis.UniversalClient, err error)

GetRedisConn 获取redis连接

func (*DaoRedisEx) GetTtl

func (p *DaoRedisEx) GetTtl(key string) (ttl int64, err error)

GetTtl:获取key的过期时间,单位为秒 如果key不存在返回-2 如果key存在,但是没有设置过期时间,返回-1

func (*DaoRedisEx) HDel

func (p *DaoRedisEx) HDel(key string, data ...interface{}) error

func (*DaoRedisEx) HExists

func (p *DaoRedisEx) HExists(key string, field string) (bool, error)

func (*DaoRedisEx) HGet

func (p *DaoRedisEx) HGet(key string, field string, value interface{}) error

func (*DaoRedisEx) HGetAll

func (p *DaoRedisEx) HGetAll(key string, data interface{}) error

func (*DaoRedisEx) HGetAllIntMap

func (p *DaoRedisEx) HGetAllIntMap(key string) (err error, data map[string]int64)

func (*DaoRedisEx) HGetAllStringMap

func (p *DaoRedisEx) HGetAllStringMap(key string) (err error, data map[string]string)

func (*DaoRedisEx) HGetRaw

func (p *DaoRedisEx) HGetRaw(key string, field string, value interface{}) (bool, error)

HGetRaw 返回 1. key是否存在 2. error

func (*DaoRedisEx) HIncrby

func (p *DaoRedisEx) HIncrby(key string, field string, value int, ops ...OpOptionEx) (int64, error)

hash start

func (*DaoRedisEx) HLen

func (p *DaoRedisEx) HLen(key string, data *int) error

func (*DaoRedisEx) HMGet

func (p *DaoRedisEx) HMGet(key string, fields []interface{}, data interface{}) error

func (*DaoRedisEx) HMSet

func (p *DaoRedisEx) HMSet(key string, value map[string]interface{}, ops ...OpOptionEx) error

HMSet value是filed:data

func (*DaoRedisEx) HSet

func (p *DaoRedisEx) HSet(key string, field string, value interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) HSetNX

func (p *DaoRedisEx) HSetNX(key string, field string, value interface{}, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) Incr

func (p *DaoRedisEx) Incr(key string, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) IncrBy

func (p *DaoRedisEx) IncrBy(key string, value int, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) IncrByNX

func (p *DaoRedisEx) IncrByNX(key string, value int, ops ...OpOptionEx) (int64, error)

存在key 才会更新数值

func (*DaoRedisEx) IncrByNoExpire

func (p *DaoRedisEx) IncrByNoExpire(key string, value int) (int64, error)

不操作过期时间 deprecated

func (*DaoRedisEx) IncrNX

func (p *DaoRedisEx) IncrNX(key string, ops ...OpOptionEx) (int64, error)

存在key 才会自增

func (*DaoRedisEx) LLen

func (p *DaoRedisEx) LLen() (int64, error)

func (*DaoRedisEx) LLenEx

func (p *DaoRedisEx) LLenEx(key string) (int64, error)

func (*DaoRedisEx) LPop

func (p *DaoRedisEx) LPop(value interface{}) error

func (*DaoRedisEx) LPopEx

func (p *DaoRedisEx) LPopEx(key string, value interface{}) error

func (*DaoRedisEx) LPush

func (p *DaoRedisEx) LPush(value interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) LPushEx

func (p *DaoRedisEx) LPushEx(key string, value interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) LREM

func (p *DaoRedisEx) LREM(count int, data interface{}) (error, int)

func (*DaoRedisEx) LREMEx

func (p *DaoRedisEx) LREMEx(key string, count int, data interface{}) (error, int)

func (*DaoRedisEx) LRange

func (p *DaoRedisEx) LRange(start int, end int, value interface{}) (err error)

func (*DaoRedisEx) LRangeEx

func (p *DaoRedisEx) LRangeEx(key string, start int, end int, value interface{}) (err error)

func (*DaoRedisEx) LTRIM

func (p *DaoRedisEx) LTRIM(start int, end int) (err error)

func (*DaoRedisEx) LTRIMEx

func (p *DaoRedisEx) LTRIMEx(key string, start int, end int) (err error)

func (*DaoRedisEx) Limiter

func (p *DaoRedisEx) Limiter(key string, expire int, max int) (allow bool, err error)

针对key进行一定时间内访问次数的限流

func (*DaoRedisEx) MDel

func (p *DaoRedisEx) MDel(key []string, ops ...OpOptionEx) error

func (*DaoRedisEx) MGet

func (p *DaoRedisEx) MGet(keys []string, data interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) MGetGo

func (p *DaoRedisEx) MGetGo(keys []string, data interface{}) error

封装mget通过go并发get

func (*DaoRedisEx) MSet

func (p *DaoRedisEx) MSet(datas map[string]interface{}, ops ...OpOptionEx) error

MSet mset

func (*DaoRedisEx) Persist

func (p *DaoRedisEx) Persist(key string, ops ...OpOptionEx) error

Persist 永久生效

func (*DaoRedisEx) PipelineHGet

func (p *DaoRedisEx) PipelineHGet(key []string, fields []interface{}, data []interface{}) error

func (*DaoRedisEx) RPop

func (p *DaoRedisEx) RPop(value interface{}) error

func (*DaoRedisEx) RPopEx

func (p *DaoRedisEx) RPopEx(key string, value interface{}) error

func (*DaoRedisEx) RPush

func (p *DaoRedisEx) RPush(value interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) RPushEx

func (p *DaoRedisEx) RPushEx(key string, value interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) SAdd

func (p *DaoRedisEx) SAdd(key string, argPs []interface{}, ops ...OpOptionEx) error

Set集合Start

func (*DaoRedisEx) SCard

func (p *DaoRedisEx) SCard(key string) int64

func (*DaoRedisEx) SIsMember

func (p *DaoRedisEx) SIsMember(key string, arg interface{}) (b bool, err error)

func (*DaoRedisEx) SMembers

func (p *DaoRedisEx) SMembers(key string) (data []interface{}, err error)

func (*DaoRedisEx) SPop

func (p *DaoRedisEx) SPop(key string, value interface{}) error

func (*DaoRedisEx) SRem

func (p *DaoRedisEx) SRem(key string, argPs []interface{}) error

func (*DaoRedisEx) Set

func (p *DaoRedisEx) Set(key string, value interface{}, ops ...OpOptionEx) (err error)

基础结束

func (*DaoRedisEx) SetEx

func (p *DaoRedisEx) SetEx(key string, value interface{}, expire int, ops ...OpOptionEx) error

SetEx setex

func (*DaoRedisEx) SetNX

func (p *DaoRedisEx) SetNX(key string, value interface{}, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) SetNXNoExpire

func (p *DaoRedisEx) SetNXNoExpire(key string, value interface{}, ops ...OpOptionEx) (int64, error)

func (*DaoRedisEx) ZAdd

func (p *DaoRedisEx) ZAdd(key string, score interface{}, value interface{}, ops ...OpOptionEx) error

sorted set start

func (*DaoRedisEx) ZAddM

func (p *DaoRedisEx) ZAddM(key string, value map[float64]interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) ZCard

func (p *DaoRedisEx) ZCard(key string) (data int, err error)

func (*DaoRedisEx) ZCount

func (p *DaoRedisEx) ZCount(key string, min, max int) (data int, err error)

func (*DaoRedisEx) ZGet

func (p *DaoRedisEx) ZGet(key string, sort bool, start int, end int, value interface{}) error

func (*DaoRedisEx) ZGetByScore

func (p *DaoRedisEx) ZGetByScore(key string, sort bool, start int, end int, value interface{}) error

func (*DaoRedisEx) ZGetByScoreLimit

func (p *DaoRedisEx) ZGetByScoreLimit(key string, sort bool, offset uint32, limit uint32, value interface{}) error

ZRANGEBYSCORE <KEY> -inf +inf limit <offset> <limit>

func (*DaoRedisEx) ZGetByScoreWithSize

func (p *DaoRedisEx) ZGetByScoreWithSize(key string, sort bool, start int, end int, offset uint32, limit uint32, value interface{}) error

ZRANGEBYSCORE <KEY> min max limit offset limit

func (*DaoRedisEx) ZGetWithScores

func (p *DaoRedisEx) ZGetWithScores(key string, sort bool, start int, end int) (err error, data map[string]string)

func (*DaoRedisEx) ZGetWithScoresLimit

func (p *DaoRedisEx) ZGetWithScoresLimit(key string, sort bool, offset uint32, limit uint32) (err error, data []ModelRedisZSetListWithScore)

ZRANGEBYSCORE <KEY> -inf +inf WITHSCORES limit <offset> <limit>

func (*DaoRedisEx) ZGetWithScoresSlice

func (p *DaoRedisEx) ZGetWithScoresSlice(key string, sort bool, start int, end int) (err error, data []ModelRedisZSetListWithScore)

func (*DaoRedisEx) ZIncrBy

func (p *DaoRedisEx) ZIncrBy(key string, increment int, member interface{}, ops ...OpOptionEx) error

func (*DaoRedisEx) ZRank

func (p *DaoRedisEx) ZRank(key string, member string, sort bool) (error, int)

func (*DaoRedisEx) ZRem

func (p *DaoRedisEx) ZRem(key string, data ...interface{}) error

func (*DaoRedisEx) ZRevRange

func (p *DaoRedisEx) ZRevRange(key string, start int, end int, value interface{}) error

func (*DaoRedisEx) ZScore

func (p *DaoRedisEx) ZScore(key string, member string, value interface{}) error

type EventBus

type EventBus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewEventBus

func NewEventBus(max int) *EventBus

func (*EventBus) Publish

func (e *EventBus) Publish(topic string, args ...interface{})

发布

func (*EventBus) Stop

func (e *EventBus) Stop()

关闭事件中心

func (*EventBus) Subscribe

func (e *EventBus) Subscribe(topic string, fn interface{})

订阅

func (*EventBus) Unsubscribe

func (e *EventBus) Unsubscribe(topic string, fn interface{})

取消订阅

func (*EventBus) Work

func (e *EventBus) Work()

事件调度中心

type IModelES

type IModelES interface {
	GetCreatedTime() time.Time
	InitTime(t time.Time)
	SetUpdatedTime(t time.Time)
	SetId(id int64)
	GetId() int64
}

type IModelMongo

type IModelMongo interface {
	GetCreatedTime() time.Time
	InitTime(t time.Time)
	SetUpdatedTime(t time.Time)
	SetId(id int64)
	GetId() int64
	SetObjectId()
	ExistId() (b bool)
}

type IModelMysql

type IModelMysql interface {
	InitTime(t time.Time)
	SetUpdatedTime(t time.Time)
	SetId(id int)
	GetId() int
}

type Log

type Log struct {
}

func NewUtilLog

func NewUtilLog() *Log

func (*Log) Error

func (l *Log) Error(format string, a ...interface{})

func (*Log) Info

func (l *Log) Info(format string, a ...interface{})

type LogTime

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

func NewLogTime

func NewLogTime(name string) (p *LogTime)

func (*LogTime) LogEnd

func (p *LogTime) LogEnd()

type ModelMongo

type ModelMongo struct {
	Id        int64 `bson:"_id,omitempty"`
	BaseMongo `bson:",inline"`
}

自增id使用

func (*ModelMongo) ExistId

func (m *ModelMongo) ExistId() (b bool)

func (*ModelMongo) GetCreatedTime

func (m *ModelMongo) GetCreatedTime() time.Time

func (*ModelMongo) GetId

func (m *ModelMongo) GetId() int64

func (*ModelMongo) InitTime

func (m *ModelMongo) InitTime(t time.Time)

func (*ModelMongo) SetId

func (m *ModelMongo) SetId(id int64)

func (*ModelMongo) SetObjectId

func (m *ModelMongo) SetObjectId()

func (*ModelMongo) SetUpdatedTime

func (m *ModelMongo) SetUpdatedTime(t time.Time)

type ModelMongoBase

type ModelMongoBase struct {
	Id        primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	BaseMongo `bson:",inline"`
}

db生成id使用

func (*ModelMongoBase) ExistId

func (m *ModelMongoBase) ExistId() (b bool)

func (*ModelMongoBase) GetCreatedTime

func (m *ModelMongoBase) GetCreatedTime() time.Time

func (*ModelMongoBase) GetId

func (m *ModelMongoBase) GetId() (id int64)

func (*ModelMongoBase) InitTime

func (m *ModelMongoBase) InitTime(t time.Time)

func (*ModelMongoBase) SetId

func (m *ModelMongoBase) SetId(id int64)

func (*ModelMongoBase) SetObjectId

func (m *ModelMongoBase) SetObjectId()

func (*ModelMongoBase) SetUpdatedTime

func (m *ModelMongoBase) SetUpdatedTime(t time.Time)

type ModelMongoBaseEx

type ModelMongoBaseEx struct {
	Id          primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	BaseMongoEx `bson:",inline"`
}

db生成id使用

func (*ModelMongoBaseEx) ExistId

func (m *ModelMongoBaseEx) ExistId() (b bool)

func (*ModelMongoBaseEx) GetCreatedTime

func (m *ModelMongoBaseEx) GetCreatedTime() time.Time

func (*ModelMongoBaseEx) GetId

func (m *ModelMongoBaseEx) GetId() (id int64)

func (*ModelMongoBaseEx) InitTime

func (m *ModelMongoBaseEx) InitTime(t time.Time)

func (*ModelMongoBaseEx) SetId

func (m *ModelMongoBaseEx) SetId(id int64)

func (*ModelMongoBaseEx) SetObjectId

func (m *ModelMongoBaseEx) SetObjectId()

func (*ModelMongoBaseEx) SetUpdatedTime

func (m *ModelMongoBaseEx) SetUpdatedTime(t time.Time)

type ModelMongoEx

type ModelMongoEx struct {
	Id          int64 `bson:"_id,omitempty" json:"id"`
	BaseMongoEx `bson:",inline"`
}

自增id使用

func (*ModelMongoEx) ExistId

func (m *ModelMongoEx) ExistId() (b bool)

func (*ModelMongoEx) GetCreatedTime

func (m *ModelMongoEx) GetCreatedTime() time.Time

func (*ModelMongoEx) GetId

func (m *ModelMongoEx) GetId() int64

func (*ModelMongoEx) InitTime

func (m *ModelMongoEx) InitTime(t time.Time)

func (*ModelMongoEx) SetId

func (m *ModelMongoEx) SetId(id int64)

func (*ModelMongoEx) SetObjectId

func (m *ModelMongoEx) SetObjectId()

func (*ModelMongoEx) SetUpdatedTime

func (m *ModelMongoEx) SetUpdatedTime(t time.Time)

type ModelMysql

type ModelMysql struct {
	Id        int       `sql:"AUTO_INCREMENT" json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*ModelMysql) GetId

func (m *ModelMysql) GetId() int

func (*ModelMysql) InitTime

func (m *ModelMysql) InitTime(t time.Time)

func (*ModelMysql) SetId

func (m *ModelMysql) SetId(id int)

func (*ModelMysql) SetUpdatedTime

func (m *ModelMysql) SetUpdatedTime(t time.Time)

type ModelRedisZSetListWithScore

type ModelRedisZSetListWithScore struct {
	Key   string `json:"key"`
	Score string `json:"score"`
}

type MysqlConnection

type MysqlConnection struct {
	*gorm.DB
	IsRead bool
}

func (MysqlConnection) Close

func (p MysqlConnection) Close()

func (MysqlConnection) Put

func (p MysqlConnection) Put()

func (MysqlConnection) PutCluster

func (p MysqlConnection) PutCluster(d *DaoMysqlCluster)

type Nacos

type Nacos struct {
	Client config_client.IConfigClient
}

type OnShutdownF

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

type OpOptionEx

type OpOptionEx func(*DaoRedisEx)

func WithClusterKey

func WithClusterKey() OpOptionEx

func WithExpire

func WithExpire(expire int) OpOptionEx

WithExpire 设置超时时间 - 为了兼容之前的命令写法 无expire时 加expire

type RedisDynamicAddress

type RedisDynamicAddress struct {
	Address      []string      // 地址列表
	AddressLen   int32         // 地址总数
	AddressIndex atomic.Int32  // 地址获取索引 从0到AddressLen-1
	ErrorConnM   sync.Map      // 地址连接错误 k 是索引 v 是空
	ErrorConnNum atomic.Int32  // 地址连接错误数
	FlagCount    atomic.Int32  // 更新标记统计
	Flag         chan struct{} // 是否主动重置
	L            sync.RWMutex
}

func (*RedisDynamicAddress) GetAddress

func (p *RedisDynamicAddress) GetAddress() (addr string, index int32)

type UploadFile

type UploadFile struct {
	// 名称
	Name string
	// 文件全路径
	Filepath string
}

Directories

Path Synopsis
ttool module
wait
Package wait provides tools for polling or listening for changes to a condition.
Package wait provides tools for polling or listening for changes to a condition.

Jump to

Keyboard shortcuts

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