package repo import ( e "galaxy/error" "galaxy/game/internal/repo/fs" ) func NewStorageError(err error) error { return e.NewRepoError(err) } func NewGameNotInitializedError() error { return e.NewGameNotInitializedError() } func NewReportNotFoundError() error { return e.NewReportNotFoundError() } func NewStateError(msg string) error { return e.NewGameStateError(msg) } // Repo persists game state through a file-backed FS. Reads and writes are // atomic and lock-free: Write swaps a fully written file into place with // rename, so Read never observes a partial file. Serialising concurrent // writers to the same state file is the caller's concern (the engine does it // at the router, see LimitMiddleware). type Repo struct { s *fs.FS } func NewRepo(s *fs.FS) (*Repo, error) { return &Repo{s: s}, nil } func NewFileRepo(path string) (*Repo, error) { s, err := fs.NewFileStorage(path) if err != nil { return nil, err } return NewRepo(s) }