Documentation ¶
Index ¶
- Constants
- Variables
- func AppendSYSField(data, sysField string) string
- func CheckRequiredField(body []byte, fields []string) bool
- func Clean()
- func GetGlobalDataTime(layout string) string
- func GetGlobalTime() time.Time
- func GetRedisTime() time.Time
- func GetUDPESIndex(body []byte, key string) string
- func InitES() error
- func InitLogger() error
- func InitRedisDB() error
- func IsValidJSON(data string) (string, bool)
- func LogConfig() error
- type TAPIData
- type TAnyMaps
- type TStringAnyMaps
Constants ¶
View Source
const ( // Redis 键名值分隔符, 默认为冒号 RedisKeySep = ":" // Redis 键名时间格式 RedisKeyTime = "060102150405" // Redis 全局锁键名前缀 RedisLockKey = "DR:REDISLOCK:" // 待办调度锁 RedisLockTodoKey = "DR:TODOLOCK" TodoListKey = "DR:TODO:LIST" SrcTagKey = ":SRC:list:" TodoTagKey = ":TODO:list:" PostTagKey = ":POST:list" PostTodoTagKey = ":GoPOST:list:" )
Variables ¶
View Source
var ( IPv4Zero = "0.0.0.0" // ES 系统字段 ESSYSField = [...]string{"_cip", "_ctime", "_gtime"} // 空白字符替换器 SpaceReplacer = strings.NewReplacer( "\n", "", "\r", "", "\f", "", "\v", "", "\t", "", "\u0085", "", "\u00a0", "", ) // 协程池 Pool = goroutine.Default() )
View Source
var ( Log zerolog.Logger LogSampled zerolog.Logger )
View Source
var CtxBG = context.Background()
View Source
var ES *elasticsearch.Client
View Source
var GTimeSub time.Duration
View Source
var RedisDB *redis.Client
View Source
var RenameScript = redis.NewScript(`
if redis.call("exists", KEYS[1]) == 1 then
redis.call("rename", KEYS[1], ARGV[1])
redis.call("expire", ARGV[1], ARGV[2])
return 1
else
return 0
end
`)
Functions ¶
func GetUDPESIndex ¶
获取 ES 索引名称, 不能包含冒号(Redis键分隔符)
func InitLogger ¶
func InitLogger() error
func InitRedisDB ¶
func InitRedisDB() error
Types ¶
type TAPIData ¶
type TAPIData struct { ID int `json:"id"` OK int `json:"ok"` Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` Count int `json:"count"` }
API 标准返回, 内部规范 id: 1, ok: 1, code: 0 成功; id: 0, ok: 0, code: 1 失败 成功时 msg 必定为空
type TStringAnyMaps ¶
type TStringAnyMaps map[string]interface{}
Click to show internal directories.
Click to hide internal directories.