Class InMemoryObjectStore
-
- All Implemented Interfaces:
-
com.pkgrove.pkgrovekit.storage.ObjectStore,java.lang.AutoCloseable
public final class InMemoryObjectStore implements ObjectStore
Reference/testing implementation of ObjectStore — plain JDK, thread-safe, strongly consistent, full capability set. This is what consumers unit-test storage workflows against without a container, and what defines expected semantics for provider adapters (the MinIO suite in
pkgrovekit-storage-s3runs the same assertions against a real provider).
-
-
Field Summary
Fields Modifier and Type Field Description private final StorageCapabilitiescapabilities
-
Constructor Summary
Constructors Constructor Description InMemoryObjectStore(Clock clock)
-
Method Summary
Modifier and Type Method Description StorageCapabilitiesgetCapabilities()What THIS store/provider supports; stable for the store's lifetime. ObjectMetadatahead(ObjectKey key)Metadata without content, or null when the object does not exist. Sequence<ObjectSummary>list(String prefix, Integer pageSize)Lazily-paginated listing of every object whose key starts with prefix, in lexicographic key order. PutResultput(ObjectKey key, ContentSource source, PutOptions options)Streaming single-object write. ObjectContentget(ObjectKey key, GetOptions options)Streaming read. Unitdelete(ObjectKey key)Idempotent delete: deleting an absent key is not an error. LongdeletePrefix(String prefix)Delete every object under prefix; returns how many keys were deleted. PutResultcopy(ObjectKey from, ObjectKey to, CopyOptions options)Server-side copy (no content through the client). MultipartUploadstartMultipart(ObjectKey key, PutOptions options)Begin a multipart upload lifecycle (capability-gated: StorageCapability.MULTIPART_UPLOAD). final Set<String>incompleteUploadIds()Testing hook: ids of multipart uploads started but not completed/aborted. -
-
Constructor Detail
-
InMemoryObjectStore
InMemoryObjectStore(Clock clock)
-
-
Method Detail
-
getCapabilities
StorageCapabilities getCapabilities()
What THIS store/provider supports; stable for the store's lifetime.
-
head
ObjectMetadata head(ObjectKey key)
Metadata without content, or null when the object does not exist.
-
list
Sequence<ObjectSummary> list(String prefix, Integer pageSize)
Lazily-paginated listing of every object whose key starts with prefix, in lexicographic key order. Consistency is whatever the provider gives — see StorageCapability.CONSISTENT_LISTING.
-
put
PutResult put(ObjectKey key, ContentSource source, PutOptions options)
Streaming single-object write. The content is read ONCE from ContentSource.open and never materialized whole; ContentSource.lengthBytes must be known (unknown-length streams belong to MultipartTransfer).
A declared PutOptions.checksum is VERIFIED (server-side where the provider can, client-side otherwise) — a mismatch throws ChecksumMismatchException and never leaves a corrupt published object. PutOptions.condition gives conditional-create/update semantics; an unmet condition throws PreconditionFailedException.
-
get
ObjectContent get(ObjectKey key, GetOptions options)
Streaming read. The caller OWNS the returned ObjectContent and must close it. With GetOptions.expectedChecksum (or a stored checksum and GetOptions.verifyChecksum) the stream verifies at EOF and throws ChecksumMismatchException on corruption — a short read that never reaches EOF is NOT a verification.
-
deletePrefix
Long deletePrefix(String prefix)
Delete every object under prefix; returns how many keys were deleted.
-
copy
PutResult copy(ObjectKey from, ObjectKey to, CopyOptions options)
Server-side copy (no content through the client). CopyOptions.condition applies to the DESTINATION where the provider supports it; note Amazon S3 itself cannot make CopyObject conditional on the destination — which is exactly why StagingArea commits via a conditional manifest PUT, never via a conditional copy.
-
startMultipart
MultipartUpload startMultipart(ObjectKey key, PutOptions options)
Begin a multipart upload lifecycle (capability-gated: StorageCapability.MULTIPART_UPLOAD). Callers should prefer MultipartTransfer.upload, which adds bounded buffering/concurrency and guaranteed abort; using the raw lifecycle, the caller owns calling MultipartUpload.complete or MultipartUpload.abort — MultipartUpload.close aborts anything not completed so an incomplete upload is never leaked.
-
incompleteUploadIds
final Set<String> incompleteUploadIds()
Testing hook: ids of multipart uploads started but not completed/aborted.
-
-
-
-