2020-03-12 16:41:30 +03:00
|
|
|
package store
|
|
|
|
|
2020-09-17 15:15:42 +03:00
|
|
|
import "context"
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
type noopStore struct {
|
2020-09-03 15:11:05 +03:00
|
|
|
opts Options
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
func NewStore(opts ...Option) Store {
|
|
|
|
return &noopStore{opts: NewOptions(opts...)}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init initialize store
|
|
|
|
func (n *noopStore) Init(opts ...Option) error {
|
2020-09-03 15:11:05 +03:00
|
|
|
for _, o := range opts {
|
|
|
|
o(&n.opts)
|
|
|
|
}
|
2020-03-12 16:41:30 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Options returns Options struct
|
|
|
|
func (n *noopStore) Options() Options {
|
2020-09-03 15:11:05 +03:00
|
|
|
return n.opts
|
2020-03-12 16:41:30 +03:00
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// String returns string representation
|
|
|
|
func (n *noopStore) String() string {
|
2020-03-12 16:41:30 +03:00
|
|
|
return "noop"
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Read reads store value by key
|
2020-12-10 22:08:56 +03:00
|
|
|
func (n *noopStore) Exists(ctx context.Context, key string) error {
|
|
|
|
return ErrNotFound
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read reads store value by key
|
|
|
|
func (n *noopStore) Read(ctx context.Context, key string, val interface{}, opts ...ReadOption) error {
|
|
|
|
return ErrNotFound
|
2020-03-12 16:41:30 +03:00
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Write writes store record
|
2020-12-10 22:08:56 +03:00
|
|
|
func (n *noopStore) Write(ctx context.Context, key string, val interface{}, opts ...WriteOption) error {
|
2020-03-12 16:41:30 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Delete removes store value by key
|
|
|
|
func (n *noopStore) Delete(ctx context.Context, key string, opts ...DeleteOption) error {
|
2020-03-12 16:41:30 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// List lists store
|
|
|
|
func (n *noopStore) List(ctx context.Context, opts ...ListOption) ([]string, error) {
|
2020-03-12 16:41:30 +03:00
|
|
|
return []string{}, nil
|
|
|
|
}
|
2020-04-08 11:51:10 +03:00
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Connect connects to store
|
|
|
|
func (n *noopStore) Connect(ctx context.Context) error {
|
2020-10-16 09:38:57 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-03 01:08:23 +03:00
|
|
|
// Disconnect disconnects from store
|
|
|
|
func (n *noopStore) Disconnect(ctx context.Context) error {
|
2020-04-08 11:51:10 +03:00
|
|
|
return nil
|
|
|
|
}
|