pkg/storage: change backend interface to return error (#1131)

Since when storage backend like redis can be fault in many cases, the
interface should return error for the caller to handle.
This commit is contained in:
Cuong Manh Le 2020-07-24 09:02:37 +07:00 committed by GitHub
parent 90d95b8c10
commit aedfbc4c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 69 deletions

View file

@ -16,13 +16,13 @@ type Backend interface {
Put(ctx context.Context, id string, data *anypb.Any) error
// Get is used to retrieve a record.
Get(ctx context.Context, id string) *databroker.Record
Get(ctx context.Context, id string) (*databroker.Record, error)
// GetAll is used to retrieve all the records.
GetAll(ctx context.Context) []*databroker.Record
GetAll(ctx context.Context) ([]*databroker.Record, error)
// List is used to retrieve all the records since a version.
List(ctx context.Context, sinceVersion string) []*databroker.Record
List(ctx context.Context, sinceVersion string) ([]*databroker.Record, error)
// Delete is used to mark a record as deleted.
Delete(ctx context.Context, id string) error