mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:21:46 +00:00
Introduce type Server
This commit is contained in:
@@ -22,8 +22,8 @@ var (
|
||||
// Each lists all entries of type t in the backend and calls function f() with
|
||||
// the id and data.
|
||||
func Each(be interface {
|
||||
lister
|
||||
getter
|
||||
Lister
|
||||
Getter
|
||||
}, t Type, f func(id ID, data []byte, err error)) error {
|
||||
ids, err := be.List(t)
|
||||
if err != nil {
|
||||
@@ -45,7 +45,7 @@ func Each(be interface {
|
||||
|
||||
// Each lists all entries of type t in the backend and calls function f() with
|
||||
// the id.
|
||||
func EachID(be lister, t Type, f func(ID)) error {
|
||||
func EachID(be Lister, t Type, f func(ID)) error {
|
||||
ids, err := be.List(t)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -101,7 +101,7 @@ func Hash(data []byte) ID {
|
||||
// Find loads the list of all blobs of type t and searches for IDs which start
|
||||
// with prefix. If none is found, nil and ErrNoIDPrefixFound is returned. If
|
||||
// more than one is found, nil and ErrMultipleIDMatches is returned.
|
||||
func Find(be lister, t Type, prefix string) (ID, error) {
|
||||
func Find(be Lister, t Type, prefix string) (ID, error) {
|
||||
p, err := hex.DecodeString(prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -134,7 +134,7 @@ func Find(be lister, t Type, prefix string) (ID, error) {
|
||||
|
||||
// FindSnapshot takes a string and tries to find a snapshot whose ID matches
|
||||
// the string as closely as possible.
|
||||
func FindSnapshot(be lister, s string) (ID, error) {
|
||||
func FindSnapshot(be Lister, s string) (ID, error) {
|
||||
// parse ID directly
|
||||
if id, err := ParseID(s); err == nil {
|
||||
return id, nil
|
||||
@@ -151,7 +151,7 @@ func FindSnapshot(be lister, s string) (ID, error) {
|
||||
|
||||
// PrefixLength returns the number of bytes required so that all prefixes of
|
||||
// all IDs of type t are unique.
|
||||
func PrefixLength(be lister, t Type) (int, error) {
|
||||
func PrefixLength(be Lister, t Type) (int, error) {
|
||||
// load all IDs of the given type
|
||||
list, err := be.List(t)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,43 +21,43 @@ var (
|
||||
ErrAlreadyPresent = errors.New("blob is already present in backend")
|
||||
)
|
||||
|
||||
type lister interface {
|
||||
type Lister interface {
|
||||
List(Type) (IDs, error)
|
||||
}
|
||||
|
||||
type getter interface {
|
||||
type Getter interface {
|
||||
Get(Type, ID) ([]byte, error)
|
||||
}
|
||||
|
||||
type creater interface {
|
||||
type Creater interface {
|
||||
Create(Type, []byte) (ID, error)
|
||||
}
|
||||
|
||||
type tester interface {
|
||||
type Tester interface {
|
||||
Test(Type, ID) (bool, error)
|
||||
}
|
||||
|
||||
type remover interface {
|
||||
type Remover interface {
|
||||
Remove(Type, ID) error
|
||||
}
|
||||
|
||||
type closer interface {
|
||||
type Closer interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
type deleter interface {
|
||||
type Deleter interface {
|
||||
Delete() error
|
||||
}
|
||||
|
||||
type locationer interface {
|
||||
type Locationer interface {
|
||||
Location() string
|
||||
}
|
||||
|
||||
type backend interface {
|
||||
lister
|
||||
getter
|
||||
creater
|
||||
tester
|
||||
remover
|
||||
closer
|
||||
type Backend interface {
|
||||
Lister
|
||||
Getter
|
||||
Creater
|
||||
Tester
|
||||
Remover
|
||||
Closer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user