Documentation
¶
Overview ¶
Package memory provides an in-memory StorageClient backend for no-infra builds and tests.
Client keeps objects in a process-local per-bucket map so a service can build and unit-test the object-storage path with no S3/MinIO — the stub-first property (ARCHITECTURE.md#stub-first-backends). Selected by the storage tier Kind. The presign methods return a synthetic memory:// URL: a memory backend issues no real signed URLs, so it is confined to test/CI/all-stubs config and is never reachable from a real client-facing upload flow.
Index ¶
- type Client
- func (c *Client) AbortMultipartUpload(_ context.Context, _, _, uploadID string) error
- func (c *Client) CompleteMultipartUpload(_ context.Context, bucket, key, uploadID string, _ []interfaces.CompletedPart) error
- func (c *Client) CreateMultipartUpload(_ context.Context, bucket, key, contentType string) (string, error)
- func (c *Client) Delete(_ context.Context, bucket, key string) error
- func (c *Client) DeleteBatch(_ context.Context, bucket string, keys []string) error
- func (c *Client) Download(_ context.Context, bucket, key string) (io.ReadCloser, error)
- func (c *Client) EnsureBucket(_ context.Context, bucket string) error
- func (c *Client) Exists(_ context.Context, bucket, key string) (bool, error)
- func (c *Client) ListMultipartUploads(_ context.Context, bucket string) ([]interfaces.MultipartUpload, error)
- func (c *Client) ListObjects(_ context.Context, bucket, prefix string) ([]interfaces.StorageObject, error)
- func (c *Client) ListObjectsPage(_ context.Context, bucket, prefix string, limit int) ([]interfaces.StorageObject, error)
- func (c *Client) ListObjectsPageToken(_ context.Context, bucket, prefix, continuationToken string, limit int) ([]interfaces.StorageObject, string, error)
- func (c *Client) PresignPutURL(_ context.Context, bucket, key string, _ int, _ string) (string, error)
- func (c *Client) PresignURL(_ context.Context, bucket, key string, _ int, _ string) (string, error)
- func (c *Client) PresignUploadPart(_ context.Context, bucket, key, uploadID string, partNumber int32, _ int) (string, error)
- func (c *Client) Stat(_ context.Context, bucket, key string) (interfaces.StorageObject, error)
- func (c *Client) Upload(_ context.Context, bucket, key string, body io.Reader, contentType string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an in-memory StorageClient (dev/test; no external storage).
func (*Client) AbortMultipartUpload ¶
AbortMultipartUpload discards an in-progress multipart upload.
func (*Client) CompleteMultipartUpload ¶
func (c *Client) CompleteMultipartUpload( _ context.Context, bucket, key, uploadID string, _ []interfaces.CompletedPart, ) error
CompleteMultipartUpload finalizes the upload by writing an EMPTY object at the upload's bucket/key with its content type: a memory backend receives no part bytes, so parts is ignored and nothing is assembled. Like S3's NoSuchUpload, an unknown upload id — or a bucket/key other than the one the upload was created for — is CodeNotFound and writes nothing.
func (*Client) CreateMultipartUpload ¶
func (c *Client) CreateMultipartUpload( _ context.Context, bucket, key, contentType string, ) (string, error)
CreateMultipartUpload begins an in-memory multipart upload and returns its id.
func (*Client) Delete ¶
Delete removes an object; a missing key is a no-op (S3 delete is idempotent).
func (*Client) DeleteBatch ¶
DeleteBatch removes multiple objects by key in one call.
func (*Client) EnsureBucket ¶
EnsureBucket creates the bucket if absent (idempotent).
func (*Client) ListMultipartUploads ¶
func (c *Client) ListMultipartUploads( _ context.Context, bucket string, ) ([]interfaces.MultipartUpload, error)
ListMultipartUploads lists the in-progress multipart uploads in a bucket.
func (*Client) ListObjects ¶
func (c *Client) ListObjects( _ context.Context, bucket, prefix string, ) ([]interfaces.StorageObject, error)
ListObjects lists the metadata of objects in a bucket whose key starts with prefix.
func (*Client) ListObjectsPage ¶
func (c *Client) ListObjectsPage( _ context.Context, bucket, prefix string, limit int, ) ([]interfaces.StorageObject, error)
ListObjectsPage lists at most limit objects whose key starts with prefix — the bounded counterpart of ListObjects. A non-positive limit returns all matches (the memory backend has no page boundary).
func (*Client) ListObjectsPageToken ¶
func (c *Client) ListObjectsPageToken( _ context.Context, bucket, prefix, continuationToken string, limit int, ) ([]interfaces.StorageObject, string, error)
ListObjectsPageToken lists at most limit prefix-matching objects in key order starting AFTER continuationToken, returning the page plus the token to resume from ("" when exhausted). It sorts the matching keys so the in-memory store paginates deterministically like a real object store (a map has no stable iteration order), letting a test drive the streaming, resumable listing path.
func (*Client) PresignPutURL ¶
func (c *Client) PresignPutURL( _ context.Context, bucket, key string, _ int, _ string, ) (string, error)
PresignPutURL returns a synthetic memory:// PUT URL (no real signing; expiry/content-type ignored).
func (*Client) PresignURL ¶
func (c *Client) PresignURL( _ context.Context, bucket, key string, _ int, _ string, ) (string, error)
PresignURL returns a synthetic memory:// GET URL (no real signing; expiry/filename ignored).
func (*Client) PresignUploadPart ¶
func (c *Client) PresignUploadPart( _ context.Context, bucket, key, uploadID string, partNumber int32, _ int, ) (string, error)
PresignUploadPart returns a synthetic memory:// URL for one part of a multipart upload.
func (*Client) Stat ¶
func (c *Client) Stat( _ context.Context, bucket, key string, ) (interfaces.StorageObject, error)
Stat returns an object's metadata without its body, or a not-found error.