Documentation ¶
Index ¶
- Variables
- func Load(errChan chan error)
- func NewCardPersistenceAdapter() adapter.Adapter[model.Card, Card]
- func NewEventPersistenceAdapter() adapter.Adapter[model.Event, Event]
- func NewRuleSetAdapter() adapter.Adapter[model.RuleSet, RuleSet]
- func NewSkillPersistenceAdapter() adapter.Adapter[model.Skill, Skill]
- func Quit()
- func Serve(flushFeq time.Duration, errChan chan error)
- func SetStoragePath(path string) error
- type Cacheable
- type Card
- type CardDeck
- type CardPersistenceAdapter
- type Character
- type DatabasePersistence
- type Event
- type EventPersistenceAdapter
- type Factory
- type FactoryPersistence
- type FactoryPersistenceRecord
- type Increasable
- type MemoryCache
- type ModInfo
- type Player
- type RoomInfo
- type RuleSet
- type RuleSetPersistenceAdapter
- type Skill
- type SkillPersistenceAdapter
- type Summon
- type TimingMemoryCache
- type Token
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RuleSetPersistence = newFactoryPersistence[RuleSet]() CardPersistence = newFactoryPersistence[Card]() CharacterPersistence = newFactoryPersistence[Character]() SkillPersistence = newFactoryPersistence[Skill]() SummonPersistence = newFactoryPersistence[Summon]() EventPersistence = newFactoryPersistence[Event]() LocalizationPersistence = newMemoryCache[string, localization.LanguagePack]() ModInfoPersistence = newMemoryCache[string, ModInfo]() RoomInfoPersistence = newMemoryCache[uint64, RoomInfo]() TokenPersistence = newTimingMemoryCache[string, Token]() CardDeckPersistence DatabasePersistence[uint64, CardDeck] PlayerPersistence DatabasePersistence[uint64, Player] )
Functions ¶
Types ¶
type CardDeck ¶
type CardDeck struct { ID uint64 `xorm:"pk autoincr notnull unique index" json:"id"` // ID CardDeck的记录ID,主键 OwnerUID uint64 `xorm:"notnull index" json:"owner_uid"` // OwnerUID CardDeck的持有者 RequiredPackages []string `xorm:"notnull json" json:"required_packages"` // RequiredPackages CardDeck需要的包 Cards []uint64 `xorm:"notnull json" json:"cards"` // Cards CardDeck包含的卡组 Characters []uint64 `xorm:"notnull json" json:"characters"` // Characters CardDeck包含的角色 }
CardDeck 被持久化模块托管的CardDeck信息
type CardPersistenceAdapter ¶
type CardPersistenceAdapter struct{}
type Character ¶
type Character struct { Cacheable TypeID uint64 Affiliation enum.Affiliation Vision enum.ElementType Weapon enum.WeaponType MaxHP uint MaxMP uint Skills []uint64 }
Character 被持久化模块托管的CharacterInfo工厂的产品
type DatabasePersistence ¶
type DatabasePersistence[PK Increasable, T any] interface { QueryByID(id PK) (has bool, result T) UpdateByID(id PK, newEntity T) (success bool) InsertOne(entity *T) (success bool, result *T) DeleteOne(id PK) (success bool) FindOne(condition T) (has bool, result T) Find(condition T) (results []T) }
DatabasePersistence 数据库持久化
type EventPersistenceAdapter ¶
type EventPersistenceAdapter struct{}
type Factory ¶
type Factory[entity any] interface { Ctor() func() entity Enable() bool ID() uint64 UID() string // contains filtered or unexported methods }
Factory 可持久化的实体接口,本质是一个生产entity的工厂
type FactoryPersistence ¶
type FactoryPersistence[T any] interface { Serve(flushFrequency time.Duration, flushPath, flushFile string, errChan chan error) Exit() Load(filePath string) (err error) QueryByID(id uint64) (has bool, result Factory[T]) QueryByUID(uid string) (has bool, result Factory[T]) Register(ctor func() T) (success bool) Flush(flushPath string, flushFile string) (err error) }
FactoryPersistence 持久化接口,抽象工厂集合的持久化封装
type FactoryPersistenceRecord ¶
FactoryPersistenceRecord 抽象工厂的持久化结构记录
type Increasable ¶
type Increasable interface { int | uint | byte | rune | int8 | int16 | int64 | uint16 | uint32 | uint64 }
Increasable 可增长的,用于数据库主键
type MemoryCache ¶
type MemoryCache[PK comparable, T any] interface { QueryByID(id PK) (has bool, result T) UpdateByID(id PK, newEntity T) (success bool) InsertOne(id PK, entity T) (success bool) DeleteOne(id PK) (success bool) }
MemoryCache 内存缓存,不进行持久化
type ModInfo ¶
type ModInfo struct { PackageName string `json:"package_name"` Events []uint `json:"events"` Characters []uint `json:"characters"` Cards []uint `json:"cards"` Skills []uint `json:"skills"` Summons []uint `json:"summons"` }
ModInfo 被持久化模块托管的ModInfo缓存
type Player ¶
type Player struct { UID uint64 `xorm:"pk autoincr notnull unique index"` // UID Player的UID,主键 NickName string `xorm:"notnull varchar(64)"` // NickName Player的昵称 Password string `xorm:"notnull varchar(64)"` // Password Player的密码Hash }
Player 被持久化模块托管的Player信息
type RoomInfo ¶
type RoomInfo struct { RoomID uint64 `json:"room_id"` CreatedAt time.Time `json:"created_at"` CreatorID uint64 `json:"creator_id"` Token string `json:"token"` Players []uint64 `json:"players"` Viewers uint64 `json:"viewers"` RequiredPackages []string `json:"required_packages"` GameOptions message.GameOptions `json:"game_options"` }
RoomInfo 被持久化模块托管的RoomInfo缓存
type RuleSetPersistenceAdapter ¶
type RuleSetPersistenceAdapter struct{}
type SkillPersistenceAdapter ¶
type SkillPersistenceAdapter struct{}
type TimingMemoryCache ¶
type TimingMemoryCache[PK comparable, T any] interface { QueryByID(id PK) (has bool, result T, timeoutAt time.Time) UpdateByID(id PK, entity T) (success bool, timeoutAt time.Time) RefreshByID(id PK, timeout time.Duration) (success bool, timeoutAt time.Time) InsertOne(id PK, entity T, timeout time.Duration) (success bool, timeoutAt time.Time) DeleteByID(id PK) (success bool) Serve(proactivelyCleanTime time.Duration, proactivelyCleanIndex float64) Exit() }
TimingMemoryCache 带超时系统的内存缓存,不进行持久化,类redis
Click to show internal directories.
Click to hide internal directories.