forked from TrueCloudLab/restic
Benchmark results for internal/repository: name old time/op new time/op delta LoadTree-8 479µs ± 2% 478µs ± 1% ~ (p=0.780 n=10+9) LoadBlob-8 11.6ms ± 2% 11.6ms ± 1% ~ (p=0.631 n=10+10) LoadAndDecrypt-8 13.2ms ± 2% 13.3ms ± 3% ~ (p=0.631 n=10+10) name old alloc/op new alloc/op delta LoadTree-8 41.2kB ± 0% 41.2kB ± 0% ~ (all equal) LoadBlob-8 2.28kB ± 0% 2.28kB ± 0% ~ (all equal) LoadAndDecrypt-8 2.10MB ± 0% 2.10MB ± 0% ~ (all equal) name old allocs/op new allocs/op delta LoadTree-8 652 ± 0% 652 ± 0% ~ (all equal) LoadBlob-8 24.0 ± 0% 24.0 ± 0% ~ (all equal) LoadAndDecrypt-8 30.0 ± 0% 30.0 ± 0% ~ (all equal) name old speed new speed delta LoadBlob-8 86.2MB/s ± 2% 86.4MB/s ± 1% ~ (p=0.594 n=10+10) LoadAndDecrypt-8 75.7MB/s ± 2% 75.4MB/s ± 3% ~ (p=0.617 n=10+10)
70 lines
2.2 KiB
Go
70 lines
2.2 KiB
Go
package restic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/restic/restic/internal/crypto"
|
|
)
|
|
|
|
// Repository stores data in a backend. It provides high-level functions and
|
|
// transparently encrypts/decrypts data.
|
|
type Repository interface {
|
|
|
|
// Backend returns the backend used by the repository
|
|
Backend() Backend
|
|
|
|
Key() *crypto.Key
|
|
|
|
SetIndex(Index) error
|
|
|
|
Index() Index
|
|
SaveFullIndex(context.Context) error
|
|
SaveIndex(context.Context) error
|
|
LoadIndex(context.Context) error
|
|
|
|
Config() Config
|
|
|
|
LookupBlobSize(ID, BlobType) (uint, bool)
|
|
|
|
// List calls the function fn for each file of type t in the repository.
|
|
// When an error is returned by fn, processing stops and List() returns the
|
|
// error.
|
|
//
|
|
// The function fn is called in the same Goroutine List() was called from.
|
|
List(ctx context.Context, t FileType, fn func(ID, int64) error) error
|
|
ListPack(context.Context, ID, int64) ([]Blob, int64, error)
|
|
|
|
Flush(context.Context) error
|
|
|
|
SaveUnpacked(context.Context, FileType, []byte) (ID, error)
|
|
SaveJSONUnpacked(context.Context, FileType, interface{}) (ID, error)
|
|
|
|
LoadJSONUnpacked(ctx context.Context, t FileType, id ID, dest interface{}) error
|
|
// LoadAndDecrypt loads and decrypts the file with the given type and ID,
|
|
// using the supplied buffer (which must be empty). If the buffer is nil, a
|
|
// new buffer will be allocated and returned.
|
|
LoadAndDecrypt(ctx context.Context, buf []byte, t FileType, id ID) (data []byte, err error)
|
|
|
|
LoadBlob(context.Context, BlobType, ID, []byte) ([]byte, error)
|
|
SaveBlob(context.Context, BlobType, []byte, ID) (ID, error)
|
|
|
|
LoadTree(context.Context, ID) (*Tree, error)
|
|
SaveTree(context.Context, *Tree) (ID, error)
|
|
}
|
|
|
|
// Lister allows listing files in a backend.
|
|
type Lister interface {
|
|
List(context.Context, FileType, func(FileInfo) error) error
|
|
}
|
|
|
|
// Index keeps track of the blobs are stored within files.
|
|
type Index interface {
|
|
Has(ID, BlobType) bool
|
|
Lookup(ID, BlobType) ([]PackedBlob, bool)
|
|
Count(BlobType) uint
|
|
|
|
// Each returns a channel that yields all blobs known to the index. When
|
|
// the context is cancelled, the background goroutine terminates. This
|
|
// blocks any modification of the index.
|
|
Each(ctx context.Context) <-chan PackedBlob
|
|
}
|