add store to defaults (#1086)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestSQL(t *testing.T) {
|
||||
}
|
||||
db.Close()
|
||||
|
||||
sqlStore := New(
|
||||
sqlStore := NewStore(
|
||||
store.Namespace("testsql"),
|
||||
store.Nodes(connection),
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user