add context to store
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
d59db9df16
commit
8817c110d0
@ -1,5 +1,7 @@
|
||||
package store
|
||||
|
||||
import "context"
|
||||
|
||||
type noopStore struct {
|
||||
opts Options
|
||||
}
|
||||
@ -27,19 +29,19 @@ func (n *noopStore) String() string {
|
||||
return "noop"
|
||||
}
|
||||
|
||||
func (n *noopStore) Read(key string, opts ...ReadOption) ([]*Record, error) {
|
||||
func (n *noopStore) Read(ctx context.Context, key string, opts ...ReadOption) ([]*Record, error) {
|
||||
return []*Record{}, nil
|
||||
}
|
||||
|
||||
func (n *noopStore) Write(r *Record, opts ...WriteOption) error {
|
||||
func (n *noopStore) Write(ctx context.Context, r *Record, opts ...WriteOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *noopStore) Delete(key string, opts ...DeleteOption) error {
|
||||
func (n *noopStore) Delete(ctx context.Context, key string, opts ...DeleteOption) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *noopStore) List(opts ...ListOption) ([]string, error) {
|
||||
func (n *noopStore) List(ctx context.Context, opts ...ListOption) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
@ -20,13 +21,13 @@ type Store interface {
|
||||
// Options allows you to view the current options.
|
||||
Options() Options
|
||||
// Read takes a single key name and optional ReadOptions. It returns matching []*Record or an error.
|
||||
Read(key string, opts ...ReadOption) ([]*Record, error)
|
||||
Read(ctx context.Context, key string, opts ...ReadOption) ([]*Record, error)
|
||||
// Write() writes a record to the store, and returns an error if the record was not written.
|
||||
Write(r *Record, opts ...WriteOption) error
|
||||
Write(ctx context.Context, r *Record, opts ...WriteOption) error
|
||||
// Delete removes the record with the corresponding key from the store.
|
||||
Delete(key string, opts ...DeleteOption) error
|
||||
Delete(ctx context.Context, key string, opts ...DeleteOption) error
|
||||
// List returns any keys that match, or an empty list with no error if none matched.
|
||||
List(opts ...ListOption) ([]string, error)
|
||||
List(ctx context.Context, opts ...ListOption) ([]string, error)
|
||||
// Close the store
|
||||
Close() error
|
||||
// String returns the name of the implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user