write op working, sort of. encodes b64
This commit is contained in:
@@ -2,15 +2,24 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
mstore "github.com/micro/go-micro/v2/store"
|
||||
)
|
||||
|
||||
// Store interacts with the filesystem to manage account information
|
||||
type Store struct{}
|
||||
type Store struct {
|
||||
mountPath string
|
||||
}
|
||||
|
||||
// New returns a new file system store manager
|
||||
// TODO add mountPath as an option argument
|
||||
func New() Store {
|
||||
return Store{}
|
||||
return Store{
|
||||
mountPath: "/var/tmp/ocis-store",
|
||||
}
|
||||
}
|
||||
|
||||
// Init implements the store interface
|
||||
@@ -27,7 +36,14 @@ func (s *Store) Read(key string, opts ...mstore.ReadOption) ([]*mstore.Record, e
|
||||
}
|
||||
|
||||
// Write implements the store interface
|
||||
func (s *Store) Write(*mstore.Record) error {
|
||||
func (s *Store) Write(rec *mstore.Record) error {
|
||||
if rec.Key == "" {
|
||||
return fmt.Errorf("%v", "key is empty")
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(s.mountPath+"/"+rec.Key, rec.Value, 0644); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user