Add file store

This commit is contained in:
Daniel Ponte 2022-10-02 14:39:55 -04:00
parent f3fd61643d
commit 17149f2c58
3 changed files with 34 additions and 2 deletions

View file

@ -12,6 +12,7 @@ import (
)
type Config struct {
DataDir *string `yaml:"data_dir,omitempty"`
Server *server.Config `yaml:"server"`
}

View file

@ -33,7 +33,10 @@ func (s *Server) installRoutes() {
}
func New(cfg *config.Config) (s *Server, err error) {
b := blas.New(cfg)
b, err := blas.New(cfg)
if err != nil {
return nil, err
}
s = &Server{
Blas: b,

28
pkg/storage/storage.go Normal file
View file

@ -0,0 +1,28 @@
package storage
import (
"io/fs"
)
type Data interface {
}
type Item struct {
Version int `json:"version"`
MinorVersion *int `json:"minor_version,omitempty"`
Key string `json:"key"`
Data Data `json:"data"`
}
type Store struct {
fs.FS
}
func Open(dir fs.FS) (*Store, error) {
stor, err := fs.Sub(dir, ".storage")
if err != nil {
return nil, err
}
return &Store{stor}, nil
}