Documentation
¶
Index ¶
- Constants
- Variables
- func After(ms int) <-chan time.Time
- func Atof(str string) float32
- func Atof64(str string) float64
- func Atoi(str string) int
- func Atoi64(str string) int64
- func FromByteJSON(data []byte, obj interface{}) error
- func FromJSON(data string, obj interface{}) error
- func GetDate() string
- func GetHour(timestamp int64) int
- func GetHour24(timestamp int64) int
- func GetMaxMsgChanLen() uint32
- func GetMsgSessionId() uint64
- func GetNextHourIntervalS(timestamp int64) int
- func GetNextTime(intervalType int) time.Time
- func GetNowTime() time.Time
- func GetTimestamp() int64
- func GetUnixMs() int64
- func GetUnixNano() int64
- func GetUnixTime(sec, nsec int64) time.Time
- func GetYearMonthDay(timestamp int64) (int32, int32, int32)
- func Go(fn func())
- func InitJsonConfigFile(configFilePath string, out interface{}) error
- func IsDiffDay(now, old int64) int
- func Itoa(num interface{}) string
- func LogDebug(v ...interface{})
- func LogError(v ...interface{})
- func LogFatal(v ...interface{})
- func LogInfo(v ...interface{})
- func LogSimpleStack() string
- func LogStack()
- func LogWarn(v ...interface{})
- func MD5Bytes(s []byte) string
- func MD5Str(s string) string
- func MD5WithSalt(s string) string
- func NewTicker(ms int) *time.Ticker
- func NewTimer(ms int) *time.Timer
- func ParseBool(s string) bool
- func ParseInt32(s string) int32
- func ParseInt64(s string) int64
- func ParseTime(str string) (time.Time, error)
- func ParseUint32(s string) uint32
- func ParseUint64(s string) uint64
- func Print(a ...interface{}) (int, error)
- func Printf(format string, a ...interface{}) (int, error)
- func Println(a ...interface{}) (int, error)
- func SetFileLog(filepath string, maxsize int)
- func Sleep(ms int)
- func Sprintf(format string, a ...interface{}) string
- func Tick(ms int) <-chan time.Time
- func ToJson(obj interface{}) string
- func Try(fun func(), handler func(interface{}))
- type ConsoleLogger
- type DelayFunc
- type FileLogger
- type GlobalObj
- type ILogger
- type ISnowflake
- type Log
- func (r *Log) Debug(v ...interface{})
- func (r *Log) Error(v ...interface{})
- func (r *Log) Fatal(v ...interface{})
- func (r *Log) GetLevel() LogLevel
- func (r *Log) Info(v ...interface{})
- func (r *Log) IsStop() bool
- func (r *Log) SetLevel(level LogLevel)
- func (r *Log) SetLevelByName(name string) bool
- func (r *Log) SetLogger(logger ILogger) bool
- func (r *Log) StartLoop()
- func (r *Log) Stop()
- func (r *Log) Warn(v ...interface{})
- func (r *Log) Write(v ...interface{})
- type LogLevel
- type Snowflake
- type TimeWheel
- type Timer
- type TimerScheduler
- func (this *TimerScheduler) CancelTimer(tid uint32)
- func (this *TimerScheduler) CreateTimerAt(unixNano int64, f func(v ...interface{}), args []interface{}) (uint32, error)
- func (this *TimerScheduler) GetTriggerChan() chan *DelayFunc
- func (this *TimerScheduler) NewTimerAfter(duration time.Duration, f func(v ...interface{}), args []interface{}) (uint32, error)
- func (this *TimerScheduler) NewTimerInterval(duration time.Duration, times int, f func(v ...interface{}), ...) (uint32, error)
- func (this *TimerScheduler) Start()
Constants ¶
View Source
const ( INTERVAL_DAY = iota //当前时间的第二天 INTERVAL_WEEK = iota //当前时间的下周一 INTERVAL_MONTH = iota //当前时间的下一月第一天) INTERVAL_YEAR = iota //当前时间的下一年第一天) TIME_SET_MAX_VAL = iota //类型最大值 )
View Source
const ( HOUR_NAME = "HOUR" HOUR_INTERVAL = 60 * 60 * 1e3 HOUR_SCALES = 12 MINUTE_NAME = "MINUTE" MINUTE_INTERVAL = 60 * 1e3 MINUTE_SCALES = 60 SECOND_NAME = "SECOND" SECOND_INTERVAL = 1e3 SECOND_SCALES = 60 TIMERS_MAX_CAP = 2048 )
View Source
const ( MAX_CHAN_BUFF = 2048 MAX_TIME_DELAY = 100 )
View Source
const (
WorkeridMax = workeridMax //集群自增量
)
Snowflake 算法
Variables ¶
View Source
var LogLevelNameMap = map[string]LogLevel{ "debug": LogLevelDebug, "info": LogLevelInfo, "warn": LogLevelWarn, "error": LogLevelError, "fatal": LogLevelFatal, "off": LogLevelAllOff, }
View Source
var NowTick int64
View Source
var StartTick int64
View Source
var Timestamp int64
Functions ¶
func GetMaxMsgChanLen ¶
func GetMaxMsgChanLen() uint32
func GetMsgSessionId ¶
func GetMsgSessionId() uint64
func GetNextHourIntervalS ¶
func GetNextTime ¶
func GetNowTime ¶
func GetTimestamp ¶
func GetTimestamp() int64
func GetUnixNano ¶
func GetUnixNano() int64
func GetUnixTime ¶
func InitJsonConfigFile ¶
InitConfigFile 初始化配置文件信息
func LogSimpleStack ¶
func LogSimpleStack() string
func MD5WithSalt ¶
func ParseInt32 ¶
func ParseInt64 ¶
func ParseUint32 ¶
func ParseUint64 ¶
func SetFileLog ¶
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct {
Pln bool
}
func (*ConsoleLogger) Write ¶
func (l *ConsoleLogger) Write(msg string)
type DelayFunc ¶
type DelayFunc struct {
// contains filtered or unexported fields
}
func NewDelayFunc ¶
func NewDelayFunc(f func(v ...interface{}), args []interface{}) *DelayFunc
type FileLogger ¶
type FileLogger struct { FilePath string Pln bool MaxSize int // contains filtered or unexported fields }
func (*FileLogger) Write ¶
func (l *FileLogger) Write(msg string)
type GlobalObj ¶
type GlobalObj struct { MaxMsgDataSize uint32 //都需数据包的最大值 MaxConn int //当前服务器主机允许的最大链接个数 MaxMsgChanLen uint32 //SendBuffMsg发送消息的缓冲最大长度 MsgSessionId uint64 //消息队列id }
var GlobalObject *GlobalObj
type ISnowflake ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
var DefLog *Log //日志
func (*Log) SetLevelByName ¶
type TimeWheel ¶
func NewTimeWheel ¶
func (*TimeWheel) AddTimeWheel ¶
func (*TimeWheel) GetTimerWithIn ¶
func (*TimeWheel) RemoveTimer ¶
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
func NewTimerAfter ¶
func NewTimerAt ¶
func NewTimerInterval ¶
type TimerScheduler ¶
func NewAutoExecTimerScheduler ¶
func NewAutoExecTimerScheduler() *TimerScheduler
func NewTimerScheduler ¶
func NewTimerScheduler() *TimerScheduler
func (*TimerScheduler) CancelTimer ¶
func (this *TimerScheduler) CancelTimer(tid uint32)
func (*TimerScheduler) CreateTimerAt ¶
func (this *TimerScheduler) CreateTimerAt(unixNano int64, f func(v ...interface{}), args []interface{}) (uint32, error)
func (*TimerScheduler) GetTriggerChan ¶
func (this *TimerScheduler) GetTriggerChan() chan *DelayFunc
func (*TimerScheduler) NewTimerAfter ¶
func (this *TimerScheduler) NewTimerAfter(duration time.Duration, f func(v ...interface{}), args []interface{}) (uint32, error)
func (*TimerScheduler) NewTimerInterval ¶
func (*TimerScheduler) Start ¶
func (this *TimerScheduler) Start()
Click to show internal directories.
Click to hide internal directories.