Documentation
¶
Index ¶
- Variables
- func CustomFrom[V any](snap *Snapshot, name Name) (V, bool)
- func MustCustomFrom[V any](snap *Snapshot, name Name) V
- func MustObjectFrom[V any](snap *Snapshot, name Name) V
- func MustRegisterCustom[V any](r *Registry, def CustomDef[V])
- func MustRegisterObject[V any](r *Registry, def ObjectDef[V])
- func MustRegisterTable[K comparable, V any](r *Registry, def TableDef[K, V])
- func ObjectFrom[V any](snap *Snapshot, name Name) (V, bool)
- func RegisterCustom[V any](r *Registry, def CustomDef[V]) error
- func RegisterObject[V any](r *Registry, def ObjectDef[V]) error
- func RegisterTable[K comparable, V any](r *Registry, def TableDef[K, V]) error
- func SetDefaultStore(store *Store)
- type BuildContext
- type CustomDef
- type IndexDef
- type Name
- type ObjectDef
- type Registry
- type ReloadEvent
- type ReloadHook
- func (h ReloadHook) AfterApplyReload(ctx context.Context, event ReloadEvent) error
- func (h ReloadHook) BeforeApplyReload(ctx context.Context, event ReloadEvent) error
- func (h ReloadHook) Name() string
- func (h ReloadHook) RollbackReload(ctx context.Context, event ReloadEvent, cause error)
- func (h ReloadHook) ValidateReload(ctx context.Context, event ReloadEvent) error
- type ReloadListener
- type Snapshot
- type Store
- func (s *Store) AddReloadListener(listener ReloadListener) func()
- func (s *Store) Current() *Snapshot
- func (s *Store) Dir() string
- func (s *Store) DryRun(ctx context.Context, reason string) (*Snapshot, error)
- func (s *Store) Load(ctx context.Context) (*Snapshot, error)
- func (s *Store) Registry() *Registry
- func (s *Store) Reload(ctx context.Context) (*Snapshot, error)
- func (s *Store) ReloadWithReason(ctx context.Context, reason string) (*Snapshot, error)
- func (s *Store) Rollback(ctx context.Context, reason string) (*Snapshot, error)
- func (s *Store) SetDir(dir string)
- func (s *Store) SetLifecycleRegistry(reg *lifecycle.Registry)
- type Table
- type TableDef
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MustCustomFrom ¶
func MustObjectFrom ¶
func MustRegisterCustom ¶
func MustRegisterObject ¶
func MustRegisterTable ¶
func MustRegisterTable[K comparable, V any](r *Registry, def TableDef[K, V])
func RegisterTable ¶
func RegisterTable[K comparable, V any](r *Registry, def TableDef[K, V]) error
func SetDefaultStore ¶
func SetDefaultStore(store *Store)
Types ¶
type BuildContext ¶
BuildContext exposes already-loaded config while building and validating a new snapshot. It is never shared with live handlers.
type CustomDef ¶
type CustomDef[V any] struct { Name Name Build func(*BuildContext) (V, error) Validate func(*BuildContext, V) error }
CustomDef builds runtime-only config from already-loaded table/object data.
type IndexDef ¶
IndexDef describes a string-keyed secondary index. Generated config getters can wrap the string key with typed helpers.
type ObjectDef ¶
type ObjectDef[V any] struct { Name Name File string Validate func(*BuildContext, V) error }
ObjectDef describes a JSON object config.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores schema definitions. It is normally populated during game bootstrap, before Store.Load or Store.Reload is called.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) RegisterCustom ¶
func (*Registry) RegisterObject ¶
func (*Registry) RegisterTable ¶
type ReloadEvent ¶
type ReloadHook ¶
type ReloadHook struct {
HookName string
Validate func(context.Context, ReloadEvent) error
BeforeApply func(context.Context, ReloadEvent) error
AfterApply func(context.Context, ReloadEvent) error
Rollback func(context.Context, ReloadEvent, error)
}
func (ReloadHook) AfterApplyReload ¶
func (h ReloadHook) AfterApplyReload(ctx context.Context, event ReloadEvent) error
func (ReloadHook) BeforeApplyReload ¶
func (h ReloadHook) BeforeApplyReload(ctx context.Context, event ReloadEvent) error
func (ReloadHook) Name ¶
func (h ReloadHook) Name() string
func (ReloadHook) RollbackReload ¶
func (h ReloadHook) RollbackReload(ctx context.Context, event ReloadEvent, cause error)
func (ReloadHook) ValidateReload ¶
func (h ReloadHook) ValidateReload(ctx context.Context, event ReloadEvent) error
type ReloadListener ¶
type ReloadListener interface {
Name() string
ValidateReload(context.Context, ReloadEvent) error
BeforeApplyReload(context.Context, ReloadEvent) error
AfterApplyReload(context.Context, ReloadEvent) error
RollbackReload(context.Context, ReloadEvent, error)
}
type Snapshot ¶
type Snapshot struct {
Version uint64
LoadedAt time.Time
Hash string
// contains filtered or unexported fields
}
Snapshot is an immutable, point-in-time view of all business configuration. A running handler should keep reading the same snapshot through the bound request Context even if the global Store is hot-reloaded while the handler is executing.
func ActiveSnapshot ¶
func ActiveSnapshot() *Snapshot
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns the current immutable config snapshot and supports hot reload by atomically publishing a newly built snapshot.
func DefaultStore ¶
func DefaultStore() *Store
func (*Store) AddReloadListener ¶
func (s *Store) AddReloadListener(listener ReloadListener) func()
func (*Store) ReloadWithReason ¶
func (*Store) SetLifecycleRegistry ¶
type Table ¶
type Table[K comparable, V any] struct { // contains filtered or unexported fields }
Table is an immutable keyed business configuration table.
func MustTableFrom ¶
func MustTableFrom[K comparable, V any](snap *Snapshot, name Name) *Table[K, V]
func (*Table[K, V]) GetByIndex ¶
type TableDef ¶
type TableDef[K comparable, V any] struct { Name Name File string Key func(V) K Indexes []IndexDef[V] Validate func(*BuildContext, V) error }
TableDef describes a JSON-backed keyed table.