-
-
Notifications
You must be signed in to change notification settings - Fork 481
/
storage.go
41 lines (34 loc) · 965 Bytes
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package backend
import (
"context"
"fmt"
"github.com/blang/semver"
)
// StorageBackend is a type of storage backend
type StorageBackend int
const (
// FS is a filesystem-backend storage
FS StorageBackend = iota
// InMem is an in-memory mock store for tests
InMem
// Consul is a consul backend storage
Consul
)
func (s StorageBackend) String() string {
return storageNameFromBackend(s)
}
// Storage is an storage backend
type Storage interface {
fmt.Stringer
Get(ctx context.Context, name string) ([]byte, error)
Set(ctx context.Context, name string, value []byte) error
Delete(ctx context.Context, name string) error
Exists(ctx context.Context, name string) bool
List(ctx context.Context, prefix string) ([]string, error)
IsDir(ctx context.Context, name string) bool
Prune(ctx context.Context, prefix string) error
Available(ctx context.Context) error
Name() string
Version(context.Context) semver.Version
Fsck(context.Context) error
}