backend: refactor backend Connections and HasAtomicReplace into Properties

This commit is contained in:
Michael Eischer
2025-02-16 22:27:58 +01:00
parent 5ddda7f5e9
commit c970e58739
18 changed files with 89 additions and 97 deletions

View File

@@ -17,15 +17,12 @@ var ErrNoRepository = fmt.Errorf("repository does not exist")
// the context package need not be wrapped, as context cancellation is checked
// separately by the retrying logic.
type Backend interface {
// Connections returns the maximum number of concurrent backend operations.
Connections() uint
// Properties returns information about the backend
Properties() Properties
// Hasher may return a hash function for calculating a content hash for the backend
Hasher() hash.Hash
// HasAtomicReplace returns whether Save() can atomically replace files
HasAtomicReplace() bool
// Remove removes a File described by h.
Remove(ctx context.Context, h Handle) error
@@ -92,6 +89,14 @@ type Backend interface {
WarmupWait(ctx context.Context, h []Handle) error
}
type Properties struct {
// Connections states the maximum number of concurrent backend operations.
Connections uint
// HasAtomicReplace states whether Save() can atomically replace files
HasAtomicReplace bool
}
type Unwrapper interface {
// Unwrap returns the underlying backend or nil if there is none.
Unwrap() Backend