add noop broker and noop store (#30)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -1,13 +1,26 @@
|
||||
package store
|
||||
|
||||
type noopStore struct{}
|
||||
type noopStore struct {
|
||||
opts Options
|
||||
}
|
||||
|
||||
func newStore(opts ...Option) Store {
|
||||
options := NewOptions()
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
return &noopStore{opts: options}
|
||||
}
|
||||
|
||||
func (n *noopStore) Init(opts ...Option) error {
|
||||
for _, o := range opts {
|
||||
o(&n.opts)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *noopStore) Options() Options {
|
||||
return Options{}
|
||||
return n.opts
|
||||
}
|
||||
|
||||
func (n *noopStore) String() string {
|
||||
|
@@ -23,6 +23,13 @@ type Options struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
func NewOptions() Options {
|
||||
return Options{
|
||||
Logger: logger.DefaultLogger,
|
||||
Context: context.Background(),
|
||||
}
|
||||
}
|
||||
|
||||
// Option sets values in Options
|
||||
type Option func(o *Options)
|
||||
|
||||
|
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
var (
|
||||
// ErrNotFound is returned when a key doesn't exist
|
||||
ErrNotFound = errors.New("not found")
|
||||
DefaultStore Store
|
||||
ErrNotFound = errors.New("not found")
|
||||
DefaultStore Store = newStore()
|
||||
)
|
||||
|
||||
// Store is a data storage interface
|
||||
|
Reference in New Issue
Block a user