Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertJson(data interface{}) string
- func ConvertResult(result *LResult) string
- func GetLock(ids ...string) bool
- func Lock(ids ...string)
- func ParseJson(str string, data interface{}) interface{}
- func RedisGetLock(res string, goId uint64) bool
- func RedisLock(res string, goId uint64)
- func RedisUnlock(res string, goId uint64)
- func SimpleCopyProperties(dst, src interface{}) (err error)
- func TestFail(lResult *LResult) bool
- func Unlock(ids ...string)
- func UnlockAll()
- type LResult
- func GenFailData(code string, errCode string, msg string, data interface{}) *LResult
- func GenOkData(data interface{}) *LResult
- func OfFail(code string, errCode string, msg string) *LResult
- func OfFailData(code string, errCode string, msg string, data interface{}) *LResult
- func OfOkData(data interface{}) *LResult
- func Ok() *LResult
- type ProtocolType
- type Runtimes
- type SnowFlake
- func (c *SnowFlake) GetMachineId() int64
- func (c *SnowFlake) GetSnowflakeId() (id, ts int64)
- func (c *SnowFlake) GetSnowflakeIdStr() string
- func (c *SnowFlake) MilliSecondToTime(milliSecond int64) (t time.Time)
- func (c *SnowFlake) MillisecondToTimeDb(ts int64) string
- func (c *SnowFlake) MillisecondToTimeTz(ts int64) string
- func (c *SnowFlake) ParseId(id int64) (milliSecond, mId, sn int64)
- func (c *SnowFlake) SetMachineId(mId int64)
Constants ¶
View Source
const CodeOk = "00000"
CodeOk 一切OK的CODE
View Source
const CodeRpcFail = "B0001"
CodeRpcFail rpc调用异常
View Source
const Day1Second = Hour1Second * 24
Day1Second one day second
View Source
const Day30Second = Day1Second * 30
Day30Second 30 day second
View Source
const Day3Second = Day1Second * 3
Day3Second three day second
View Source
const Day7Second = Day1Second * 7
Day7Second seven day second
View Source
const DbCacheModeAll = "data/cache"
DbCacheModeAll 数据库缓存模式-全部
View Source
const DbCacheModeCacheFirst = "cache"
DbCacheModeCacheFirst 数据库缓存模式-缓存
View Source
const DbDataUpdateQueue = "Cache:Update:"
DbDataUpdateQueue 数据更新队列名
View Source
const Hour1Second = Minute1Second * 60
Hour1Second one hour second
View Source
const Hour30Second = Hour1Second * 30
Hour30Second 30 hour second
View Source
const Minute15Second = Minute1Second * 15
Minute15Second 15 minute second
View Source
const Minute1Second = 60
Minute1Second one minute second
View Source
const MsgOk = "ok"
MsgOk 一切OK的消息
View Source
const RetOk = "0"
RetOk 一切OK的返回码
View Source
const RetSystemFail = "500"
RetSystemFail 系统错误的返回码
View Source
const TimeDayFormat = "2006-01-02"
View Source
const TimeFormat = "2006-01-02 15:04:05"
View Source
const TimeMonthFormat = "2006-01"
Variables ¶
View Source
var SelfRuntime = NewRuntimes()
View Source
var Snow = &SnowFlake{ lastTime: time.Now().UnixNano() / 1000000, }
Functions ¶
func ConvertJson ¶
func ConvertJson(data interface{}) string
func ConvertResult ¶
func RedisGetLock ¶
func RedisUnlock ¶
func SimpleCopyProperties ¶
func SimpleCopyProperties(dst, src interface{}) (err error)
Types ¶
type LResult ¶
type LResult struct { Api string `json:"api,omitempty"` Code string `json:"code,omitempty"` ErrCode string `json:"err_code,omitempty"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` }
func GenFailData ¶
func OfFailData ¶
type ProtocolType ¶
type ProtocolType string
const ( ProtocolProtobuf ProtocolType = "proto" ProtocolJson ProtocolType = "json" )
func (ProtocolType) String ¶
func (p ProtocolType) String() string
func (ProtocolType) ValueOf ¶
func (p ProtocolType) ValueOf(value string) ProtocolType
type Runtimes ¶
type Runtimes struct {
// contains filtered or unexported fields
}
func NewRuntimes ¶
func NewRuntimes() *Runtimes
type SnowFlake ¶
type SnowFlake struct {
// contains filtered or unexported fields
}
func (*SnowFlake) GetSnowflakeId ¶
GetSnowflakeId 获取雪花 返回值 id:自增id ts:生成该id的毫秒时间戳
func (*SnowFlake) GetSnowflakeIdStr ¶
func (*SnowFlake) MilliSecondToTime ¶
MilliSecondToTime 毫秒转换成time
func (*SnowFlake) MillisecondToTimeDb ¶
MillisecondToTimeDb 毫秒转换成"2006-01-02 15:04:05.999"
func (*SnowFlake) MillisecondToTimeTz ¶
MillisecondToTimeTz 毫秒转换成"20060102T150405.999Z"
func (*SnowFlake) SetMachineId ¶
SetMachineId 设置机器id,默认为0,范围[0,255]
Click to show internal directories.
Click to hide internal directories.