Files
galaxy-game/pkg/repo/repo.go
T
2025-09-23 22:02:21 +03:00

33 lines
494 B
Go

package repo
import (
"encoding"
"github.com/iliadenisov/galaxy/pkg/repo/fs"
)
type Storage interface {
Lock() (func() error, error)
Write(string, encoding.BinaryMarshaler) error
Read(string, encoding.BinaryUnmarshaler) error
}
type repo struct {
s Storage
}
func NewRepo(s Storage) (*repo, error) {
r := &repo{
s: s,
}
return r, nil
}
func NewFileRepo(path string) (*repo, error) {
s, err := fs.NewFileStorage(path)
if err != nil {
return nil, err
}
return NewRepo(s)
}