Documentation ¶
Index ¶
- func SaveAll(errorHandle func(err error) bool, retryInterval time.Duration)
- type GlobalData
- func (slf *GlobalData[T]) GetData() T
- func (slf *GlobalData[T]) GetName() string
- func (slf *GlobalData[T]) Handle(handler func(name string, data T)) *GlobalData[T]
- func (slf *GlobalData[T]) HandleWithCallback(handler func(name string, data T) error, callback func(err error)) *GlobalData[T]
- func (slf *GlobalData[T]) LoadData()
- func (slf *GlobalData[T]) SaveData() error
- type GlobalDataStorage
- type IndexData
- func (slf *IndexData[I, T]) DeleteAllData() *IndexData[I, T]
- func (slf *IndexData[I, T]) DeleteData(index I) *IndexData[I, T]
- func (slf *IndexData[I, T]) GetAllData() map[I]T
- func (slf *IndexData[I, T]) GetData(index I) T
- func (slf *IndexData[I, T]) GetName() string
- func (slf *IndexData[I, T]) Handle(index I, handler func(name string, index I, data T)) *IndexData[I, T]
- func (slf *IndexData[I, T]) HandleWithCallback(index I, handler func(name string, index I, data T) error, ...) *IndexData[I, T]
- func (slf *IndexData[I, T]) LoadAllData()
- func (slf *IndexData[I, T]) LoadData(index I)
- func (slf *IndexData[I, T]) SaveAllData(errHandle func(err error) bool, retryInterval time.Duration)
- func (slf *IndexData[I, T]) SaveData(index I) error
- type IndexDataItem
- type IndexDataStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GlobalData ¶
type GlobalData[T any] struct { // contains filtered or unexported fields }
GlobalData 全局数据
func NewGlobalData ¶
func NewGlobalData[T any](name string, storage GlobalDataStorage[T]) *GlobalData[T]
NewGlobalData 创建全局数据
func (*GlobalData[T]) Handle ¶
func (slf *GlobalData[T]) Handle(handler func(name string, data T)) *GlobalData[T]
Handle 处理数据
func (*GlobalData[T]) HandleWithCallback ¶
func (slf *GlobalData[T]) HandleWithCallback(handler func(name string, data T) error, callback func(err error)) *GlobalData[T]
HandleWithCallback 处理数据
type GlobalDataStorage ¶
type GlobalDataStorage[T any] interface { // Load 加载全局数据 // - 当全局数据不存在时,应当返回新的全局数据实例 Load(name string) T // Save 保存全局数据 Save(name string, data T) error }
GlobalDataStorage 全局数据存储器接口
type IndexData ¶
type IndexData[I generic.Ordered, T IndexDataItem[I]] struct { // contains filtered or unexported fields }
IndexData 全局数据
func NewIndexData ¶
func NewIndexData[I generic.Ordered, T IndexDataItem[I]](name string, storage IndexDataStorage[I, T]) *IndexData[I, T]
NewIndexData 创建索引数据
func (*IndexData[I, T]) DeleteAllData ¶
DeleteAllData 删除所有数据
func (*IndexData[I, T]) DeleteData ¶
DeleteData 删除数据
func (*IndexData[I, T]) GetAllData ¶
func (slf *IndexData[I, T]) GetAllData() map[I]T
GetAllData 获取所有数据
func (*IndexData[I, T]) Handle ¶
func (slf *IndexData[I, T]) Handle(index I, handler func(name string, index I, data T)) *IndexData[I, T]
Handle 处理数据
func (*IndexData[I, T]) HandleWithCallback ¶
func (slf *IndexData[I, T]) HandleWithCallback(index I, handler func(name string, index I, data T) error, callback func(err error)) *IndexData[I, T]
HandleWithCallback 处理数据
type IndexDataItem ¶
type IndexDataStorage ¶
type IndexDataStorage[I generic.Ordered, T IndexDataItem[I]] interface { // Load 加载特定索引数据 // - 通常情况下当数据不存在时,应当返回空指针 Load(name string, index I) T // LoadAll 加载所有数据 LoadAll(name string) map[I]T // Save 保存特定索引数据 Save(name string, index I, data T) error // SaveAll 保存所有数据 SaveAll(name string, data map[I]T, errHandle func(err error) bool, retryInterval time.Duration) // Delete 删除特定索引数据 Delete(name string, index I) // DeleteAll 删除所有数据 DeleteAll(name string) }
IndexDataStorage 全局数据存储器接口
Source Files ¶
Click to show internal directories.
Click to hide internal directories.