add store to defaults (#1086)

This commit is contained in:
Asim Aslam
2020-01-06 17:44:32 +00:00
committed by GitHub
parent df9055f69c
commit be6e8a7c78
5 changed files with 53 additions and 2 deletions

View File

@@ -173,7 +173,7 @@ func (s *sqlStore) initDB() {
}
// New returns a new micro Store backed by sql
func New(opts ...store.Option) store.Store {
func NewStore(opts ...store.Option) store.Store {
var options store.Options
for _, o := range opts {
o(&options)

View File

@@ -27,7 +27,7 @@ func TestSQL(t *testing.T) {
}
db.Close()
sqlStore := New(
sqlStore := NewStore(
store.Namespace("testsql"),
store.Nodes(connection),
)

View File

@@ -9,6 +9,8 @@ import (
var (
// ErrNotFound is returned when a Read key doesn't exist
ErrNotFound = errors.New("not found")
// Default store
DefaultStore Store = new(noop)
)
// Store is a data storage interface
@@ -29,3 +31,21 @@ type Record struct {
Value []byte
Expiry time.Duration
}
type noop struct{}
func (n *noop) List() ([]*Record, error) {
return nil, nil
}
func (n *noop) Read(key ...string) ([]*Record, error) {
return nil, nil
}
func (n *noop) Write(rec ...*Record) error {
return nil
}
func (n *noop) Delete(key ...string) error {
return nil
}