Documentation
¶
Overview ¶
Package memory is an in-process storage.Storage for tests: objects live in a map, nothing touches the filesystem, and every behavior is deterministic. It keeps the whole storage contract (it passes storagetest), but it buffers each object in memory, so it is not for large files or for production.
Index ¶
- type Option
- type Store
- func (*Store) BoundedWrites()
- func (s *Store) Delete(ctx context.Context, key string) error
- func (s *Store) Keys() []string
- func (s *Store) List(ctx context.Context, prefix string, fn func(storage.ObjectInfo) error) error
- func (s *Store) Open(ctx context.Context, key string) (io.ReadCloser, storage.ObjectInfo, error)
- func (s *Store) Put(ctx context.Context, key string, r io.Reader, opts storage.PutOptions) (storage.ObjectInfo, error)
- func (s *Store) Stat(ctx context.Context, key string) (storage.ObjectInfo, error)
- func (s *Store) URL(ctx context.Context, key string, opts storage.URLOptions) (string, error)
- func (s *Store) UploadURL(ctx context.Context, key string, opts storage.UploadURLOptions) (storage.UploadRequest, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Store)
Option configures a Store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory storage.Storage. The zero value is not usable; call New. It is safe for concurrent use.
func (*Store) BoundedWrites ¶
func (*Store) BoundedWrites()
BoundedWrites implements storage.BoundedWriter: a Put publishes in the process, after checking its context, within the call.
func (*Store) Keys ¶
Keys returns the stored keys, for tests that assert what was written. The order is unspecified.
func (*Store) List ¶
List implements storage.Lister, in key order, over a snapshot taken when it starts (fn may delete).
func (*Store) Open ¶
func (s *Store) Open(ctx context.Context, key string) (io.ReadCloser, storage.ObjectInfo, error)
Open implements storage.Storage.
func (*Store) Put ¶
func (s *Store) Put(ctx context.Context, key string, r io.Reader, opts storage.PutOptions) (storage.ObjectInfo, error)
Put implements storage.Storage. The object is read completely before it replaces the old one, so a failed Put changes nothing.
func (*Store) URL ¶
URL implements storage.Storage with the store's presign.Signer (WithURLs): a public URL for a key under its public prefix, or a signed one. Without a Signer it returns storage.ErrUnsupported (after validating its arguments).
func (*Store) UploadURL ¶
func (s *Store) UploadURL(ctx context.Context, key string, opts storage.UploadURLOptions) (storage.UploadRequest, error)
UploadURL implements storage.DirectUploader with the store's presign.Signer (WithURLs): a signed PUT that presign.Handler stores. Without a Signer it returns storage.ErrUnsupported (after validating its arguments).