memory

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 12 Imported by: 0

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

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 New

func New() *Client

New creates an empty in-memory storage client.

func (*Client) AbortMultipartUpload

func (c *Client) AbortMultipartUpload(_ context.Context, _, _, uploadID string) error

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

func (c *Client) Delete(_ context.Context, bucket, key string) error

Delete removes an object; a missing key is a no-op (S3 delete is idempotent).

func (*Client) DeleteBatch

func (c *Client) DeleteBatch(_ context.Context, bucket string, keys []string) error

DeleteBatch removes multiple objects by key in one call.

func (*Client) Download

func (c *Client) Download(_ context.Context, bucket, key string) (io.ReadCloser, error)

Download returns a reader over the stored bytes, or a not-found error.

func (*Client) EnsureBucket

func (c *Client) EnsureBucket(_ context.Context, bucket string) error

EnsureBucket creates the bucket if absent (idempotent).

func (*Client) Exists

func (c *Client) Exists(_ context.Context, bucket, key string) (bool, error)

Exists reports whether an object exists at bucket/key.

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.

func (*Client) Upload

func (c *Client) Upload(
	_ context.Context,
	bucket, key string,
	body io.Reader,
	contentType string,
) error

Upload reads body fully and stores it under bucket/key with computed metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL