Documentation ¶
Index ¶
- Constants
- func BetweenNow(startTime, endTime string) bool
- func ByteConvertString(size float32) string
- func CheckTimeFormat(src, layout string) bool
- func CurrentTimeMillisecond() int64
- func CurrentTimeSecond() int64
- func DeepCopy(dst, src interface{}) error
- func FileExists(name string) bool
- func FirstLower(s string) string
- func FirstUpper(s string) string
- func GenerateSessionId() (string, error)
- func GetAppPath() string
- func GetJavaIntHash(s string) int32
- func IsPort(p string) bool
- func IsToday(ts int64) bool
- func IsWindows() bool
- func Now() time.Time
- func ParseInt(numberStr string) int
- func ParseInt32(numberStr string) int32
- func ParseInt64(numberStr string) int64
- func RandomBool(probability int32) bool
- func RandomInt32(start, end int32) int32
- func RandomInt64(start, end int64) int64
- func SameDay(a, b time.Time) bool
- func SameWeek(a, b int64) bool
- func SameWeekNow(a int64) bool
- func SetTime(timeStr string)
- func SliceContains(array interface{}, val interface{}) (index int)
- func ToString(what interface{}) string
- func ToStringIndent(what interface{}) string
- func WaitForTerminate()
- func WightRandomTwo[A any](drops []*Two[A, int32]) A
- func ZKAdd(conn *zk.Conn, path string, value string, flag int32)
- func ZKCreateConnect(hosts []string) *zk.Conn
- func ZKDelete(conn *zk.Conn, path string)
- func ZKGet(conn *zk.Conn, path string) string
- func ZKUpdate(conn *zk.Conn, path string, value string)
- func ZKWatchChildrenW(conn *zk.Conn, path string, errClose bool) (chan []string, chan error)
- func ZeroUnixTime(offsetDay int) int64
- type DefaultModule
- type DefaultModuleManager
- type Five
- type Four
- type Module
- type ServiceConfig
- type Snowflake
- type Three
- type Two
- type Uint32IdAllocator
Constants ¶
const ( KB = 1 << (10 * iota) MB GB TB PB )
字节大小常量
const ( FormatTime = "15:04:05" FormatDate = "2006-01-02" FormatDateTime = "2006-01-02 15:04:05" )
Variables ¶
This section is empty.
Functions ¶
func BetweenNow ¶ added in v0.0.15
BetweenNow 是否在当前时间内
func ByteConvertString ¶ added in v0.0.23
ByteConvertString 字节大小转换 B==>KB==>MB==>GB
func CurrentTimeMillisecond ¶ added in v0.0.8
func CurrentTimeMillisecond() int64
获取 服务器内部时间戳 ms,可能有偏移量
func FileExists ¶ added in v0.0.15
FileExists reports whether the named file or directory exists.
func GenerateSessionId ¶
func GetAppPath ¶ added in v0.0.15
func GetAppPath() string
Get the absolute path to the running directory
func GetJavaIntHash ¶ added in v0.0.9
计算字符串java hash值 int java byte为有符号(-128~127),go为无符号(0~256)
func IsWindows ¶ added in v0.0.15
func IsWindows() bool
Determine whether the current system is a Windows system?
func RandomBool ¶ added in v0.0.14
RandomBool 根据几率 计算是否生成,种子数为10000
func RandomInt32 ¶ added in v0.0.13
RandomInt32 随机 int32 ,包含开始和结束
func RandomInt64 ¶ added in v0.0.19
RandomInt64 随机 int64 ,包含开始和结束
func ToStringIndent ¶
func ToStringIndent(what interface{}) string
ToStringIndent 将任意结构转化为json缩进后的字符串 方便输出调试
func WightRandomTwo ¶ added in v0.0.20
WightRandomTwo 根据权重随机,第二参数为权重
func ZKAdd ¶
增 flags有4种取值: 0:永久,除非手动删除 zk.FlagEphemeral = 1:短暂,session断开则该节点也被删除 zk.FlagSequence = 2:会自动在节点后面添加序号 3:Ephemeral和Sequence,即,短暂且自动添加序号
func ZKWatchChildrenW ¶
ZKWatchChildrenW 事件监听 只能监听一层子目录?
Types ¶
type DefaultModule ¶
type DefaultModule struct { }
@
func (DefaultModule) Init ¶
func (this DefaultModule) Init() error
func (DefaultModule) Run ¶
func (this DefaultModule) Run()
func (DefaultModule) Stop ¶
func (this DefaultModule) Stop()
type DefaultModuleManager ¶
DefaultModuleManager default module manager
func NewDefaultModuleManager ¶
func NewDefaultModuleManager() *DefaultModuleManager
func (*DefaultModuleManager) AppendModule ¶
func (this *DefaultModuleManager) AppendModule(module Module) Module
添加模块
func (*DefaultModuleManager) Stop ¶
func (this *DefaultModuleManager) Stop()
type Five ¶ added in v0.0.18
Five 五个个参数结构体
func ParseFiveArgs ¶ added in v0.0.18
func ParseFiveArgs[A any, B any, C any, D any, E any](configString, splitSlice, splitArgs string, parseFun func(configStr []string) (A, B, C, D, E)) []*Five[A, B, C, D, E]
ParseFiveArgs 解析字符串道具 splitSlice数组分割 splitArgs 参数分割 例如2=10=1=3=1,5=25=1=3=1,10=20=1=3=1,15=10=1=3=1,20=5=1=3=1 splitSlice
type Four ¶ added in v0.0.18
Four 四个参数结构体
func ParseFourArgs ¶ added in v0.0.18
func ParseFourArgs[A any, B any, C any, D any](configString, splitSlice, splitArgs string, parseFun func(configStr []string) (A, B, C, D)) []*Four[A, B, C, D]
ParseFourArgs 解析字符串道具 splitSlice数组分割 splitArgs 参数分割 例如2=10=1=3,5=25=1=3,10=20=1=3,15=10=1=3,20=5=1=3 splitSlice
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"name"` Id string `json:"id"` Address string `json:"address"` Port int32 `json:"port"` RegistrationTimeUTC int64 `json:"registrationTimeUTC"` ServiceType string `json:"serviceType"` //默认值 DYNAMIC }
ServiceConfig 服务配置,参考java zookeeper服务发现定义
type Snowflake ¶
type Snowflake struct {
// contains filtered or unexported fields
}
var UUID *Snowflake
func NewSnowflake ¶
type Uint32IdAllocator ¶
type Uint32IdAllocator struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
* * 时间轮调度器 * 依赖模块 scheduled_task.go time_wheel.go
|
* * 时间轮调度器 * 依赖模块 scheduled_task.go time_wheel.go |