2014-09-23 20:39:12 +00:00
|
|
|
package backend
|
|
|
|
|
2015-02-11 18:55:23 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"io"
|
|
|
|
)
|
2014-10-07 21:19:26 +00:00
|
|
|
|
2014-09-23 20:39:12 +00:00
|
|
|
type Type string
|
|
|
|
|
|
|
|
const (
|
2014-11-16 12:22:19 +00:00
|
|
|
Data Type = "data"
|
2014-09-23 20:39:12 +00:00
|
|
|
Key = "key"
|
|
|
|
Lock = "lock"
|
|
|
|
Snapshot = "snapshot"
|
|
|
|
Tree = "tree"
|
|
|
|
)
|
|
|
|
|
2014-10-04 14:49:39 +00:00
|
|
|
const (
|
|
|
|
BackendVersion = 1
|
|
|
|
)
|
|
|
|
|
2014-10-07 21:19:26 +00:00
|
|
|
var (
|
|
|
|
ErrAlreadyPresent = errors.New("blob is already present in backend")
|
|
|
|
)
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Lister interface {
|
2014-11-24 21:09:22 +00:00
|
|
|
List(Type) (IDs, error)
|
|
|
|
}
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Getter interface {
|
2014-09-23 20:39:12 +00:00
|
|
|
Get(Type, ID) ([]byte, error)
|
2015-02-11 18:55:23 +00:00
|
|
|
GetReader(Type, ID) (io.ReadCloser, error)
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Creater interface {
|
2014-12-21 14:57:41 +00:00
|
|
|
Create(Type, []byte) (ID, error)
|
2015-02-11 18:55:23 +00:00
|
|
|
CreateFrom(Type, rd io.Reader) (ID, error)
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Tester interface {
|
2014-09-23 20:39:12 +00:00
|
|
|
Test(Type, ID) (bool, error)
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Remover interface {
|
2014-09-23 20:39:12 +00:00
|
|
|
Remove(Type, ID) error
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|
2014-09-23 20:39:12 +00:00
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Closer interface {
|
2014-10-04 17:20:15 +00:00
|
|
|
Close() error
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|
2014-10-04 17:20:15 +00:00
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Deleter interface {
|
2014-12-21 14:57:41 +00:00
|
|
|
Delete() error
|
|
|
|
}
|
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Locationer interface {
|
2014-09-23 20:39:12 +00:00
|
|
|
Location() string
|
|
|
|
}
|
2014-12-21 14:57:41 +00:00
|
|
|
|
2014-12-21 16:02:49 +00:00
|
|
|
type Backend interface {
|
|
|
|
Lister
|
|
|
|
Getter
|
|
|
|
Creater
|
|
|
|
Tester
|
|
|
|
Remover
|
|
|
|
Closer
|
2014-12-21 14:57:41 +00:00
|
|
|
}
|