56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
|
// Package manager...
|
||
|
//
|
||
|
// Description : manager...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2021-08-09 6:34 下午
|
||
|
package manager
|
||
|
|
||
|
import (
|
||
|
"git.zhangdeman.cn/zhangdeman/gopkg/easylock"
|
||
|
"git.zhangdeman.cn/zhangdeman/gopkg/easymap"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
// Namespace 命名空间实例
|
||
|
Namespace *namespace
|
||
|
// Config 配置管理实例
|
||
|
Config *config
|
||
|
// Storage 内存存储实例
|
||
|
Storage *storage
|
||
|
)
|
||
|
|
||
|
// Init ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 6:36 下午 2021/8/9
|
||
|
func Init() {
|
||
|
Namespace = &namespace{}
|
||
|
Config = &config{}
|
||
|
// 初始化内存存储
|
||
|
Storage = &storage{
|
||
|
lock: nil,
|
||
|
namespaceTable: nil,
|
||
|
namespaceIDTable: nil,
|
||
|
namespaceIDToNameTable: nil,
|
||
|
namespaceConfigKeyTable: nil,
|
||
|
configTable: nil,
|
||
|
}
|
||
|
Storage.lock, _ = easylock.NewSegment(32)
|
||
|
Storage.namespaceTable, _ = easymap.NewSegment(32, true)
|
||
|
Storage.namespaceIDTable, _ = easymap.NewSegment(32, true)
|
||
|
Storage.namespaceIDToNameTable, _ = easymap.NewSegment(32, true)
|
||
|
Storage.namespaceConfigKeyTable, _ = easymap.NewSegment(32, true)
|
||
|
Storage.configTable, _ = easymap.NewSegment(128, true)
|
||
|
if err := Storage.InitNamespace(); nil != err {
|
||
|
panic("memory namespace init fail")
|
||
|
}
|
||
|
if err := Storage.InitConfig(); nil != err {
|
||
|
panic("memory config init fail")
|
||
|
}
|
||
|
|
||
|
go Storage.TimerUpdate(0)
|
||
|
}
|