Documentation ¶
Index ¶
- func NewFactory() location.Factory
- type MemoryBackend
- func (be *MemoryBackend) Close() error
- func (be *MemoryBackend) Connections() uint
- func (be *MemoryBackend) Delete(ctx context.Context) error
- func (be *MemoryBackend) HasAtomicReplace() bool
- func (be *MemoryBackend) Hasher() hash.Hash
- func (be *MemoryBackend) IsNotExist(err error) bool
- func (be *MemoryBackend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error
- func (be *MemoryBackend) Load(ctx context.Context, h backend.Handle, length int, offset int64, ...) error
- func (be *MemoryBackend) Location() string
- func (be *MemoryBackend) Remove(ctx context.Context, h backend.Handle) error
- func (be *MemoryBackend) Save(ctx context.Context, h backend.Handle, rd backend.RewindReader) error
- func (be *MemoryBackend) Stat(ctx context.Context, h backend.Handle) (backend.FileInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend is a mock backend that uses a map for storing all data in memory. This should only be used for tests.
func New ¶
func New() *MemoryBackend
New returns a new backend that saves all data in a map in memory.
func (*MemoryBackend) Connections ¶
func (be *MemoryBackend) Connections() uint
func (*MemoryBackend) Delete ¶
func (be *MemoryBackend) Delete(ctx context.Context) error
Delete removes all data in the backend.
func (*MemoryBackend) HasAtomicReplace ¶
func (be *MemoryBackend) HasAtomicReplace() bool
HasAtomicReplace returns whether Save() can atomically replace files
func (*MemoryBackend) Hasher ¶
func (be *MemoryBackend) Hasher() hash.Hash
Hasher may return a hash function for calculating a content hash for the backend
func (*MemoryBackend) IsNotExist ¶
func (be *MemoryBackend) IsNotExist(err error) bool
IsNotExist returns true if the file does not exist.
func (*MemoryBackend) List ¶
func (be *MemoryBackend) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) error
List returns a channel which yields entries from the backend.
func (*MemoryBackend) Load ¶
func (be *MemoryBackend) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error
Load runs fn with a reader that yields the contents of the file at h at the given offset.
func (*MemoryBackend) Location ¶
func (be *MemoryBackend) Location() string
Location returns the location of the backend (RAM).
func (*MemoryBackend) Save ¶
func (be *MemoryBackend) Save(ctx context.Context, h backend.Handle, rd backend.RewindReader) error
Save adds new Data to the backend.