Backend is used to store and access data. Backend operations that return an error will be retried when a Backend is wrapped in a RetryBackend. To prevent that from happening, the operations should return a github.com/cenkalti/backoff/v4.PermanentError. Errors from the context package need not be wr
| 17 | // the context package need not be wrapped, as context cancellation is checked |
| 18 | // separately by the retrying logic. |
| 19 | type Backend interface { |
| 20 | // Properties returns information about the backend |
| 21 | Properties() Properties |
| 22 | |
| 23 | // Hasher may return a hash function for calculating a content hash for the backend |
| 24 | Hasher() hash.Hash |
| 25 | |
| 26 | // Remove removes a File described by h. |
| 27 | Remove(ctx context.Context, h Handle) error |
| 28 | |
| 29 | // Close the backend |
| 30 | Close() error |
| 31 | |
| 32 | // Save stores the data from rd under the given handle. |
| 33 | Save(ctx context.Context, h Handle, rd RewindReader) error |
| 34 | |
| 35 | // Load runs fn with a reader that yields the contents of the file at h at the |
| 36 | // given offset. If length is larger than zero, only a portion of the file |
| 37 | // is read. If the length is larger than zero and the file is too short to return |
| 38 | // the requested length bytes, then an error MUST be returned that is recognized |
| 39 | // by IsPermanentError(). |
| 40 | // |
| 41 | // The function fn may be called multiple times during the same Load invocation |
| 42 | // and therefore must be idempotent. |
| 43 | // |
| 44 | // Implementations are encouraged to use util.DefaultLoad |
| 45 | Load(ctx context.Context, h Handle, length int, offset int64, fn func(rd io.Reader) error) error |
| 46 | |
| 47 | // Stat returns information about the File identified by h. |
| 48 | Stat(ctx context.Context, h Handle) (FileInfo, error) |
| 49 | |
| 50 | // List runs fn for each file in the backend which has the type t. When an |
| 51 | // error occurs (or fn returns an error), List stops and returns it. |
| 52 | // |
| 53 | // The function fn is called exactly once for each file during successful |
| 54 | // execution and at most once in case of an error. |
| 55 | // |
| 56 | // The function fn is called in the same Goroutine that List() is called |
| 57 | // from. |
| 58 | List(ctx context.Context, t FileType, fn func(FileInfo) error) error |
| 59 | |
| 60 | // IsNotExist returns true if the error was caused by a non-existing file |
| 61 | // in the backend. |
| 62 | // |
| 63 | // The argument may be a wrapped error. The implementation is responsible |
| 64 | // for unwrapping it. |
| 65 | IsNotExist(err error) bool |
| 66 | |
| 67 | // IsPermanentError returns true if the error can very likely not be resolved |
| 68 | // by retrying the operation. Backends should return true if the file is missing, |
| 69 | // the requested range does not (completely) exist in the file or the user is |
| 70 | // not authorized to perform the requested operation. |
| 71 | IsPermanentError(err error) bool |
| 72 | |
| 73 | // Delete removes all data in the backend. |
| 74 | Delete(ctx context.Context) error |
| 75 | |
| 76 | // Warmup ensures that the specified handles are ready for upcoming reads. |
no outgoing calls
no test coverage detected