Object stores
An object store keeps named byte values: an archive of what was applied, an uploaded file, a report. It keeps a value and its content type, and every driver does it the same way. There is no listing, no other metadata and no partial read, so the same code works on a folder and on S3.
| Operation | Java | Go | Does |
|---|---|---|---|
| put | put(key, bytes), put(key, bytes, contentType) |
Put(ctx, key, content), PutObject(ctx, key, Object{Content, ContentType}) |
stores the value, replacing any earlier one completely. A reader sees the old value or the new one, never a mixture |
| get | get(key) (Optional<byte[]>), read(key) (Optional<StoredObject>) |
Get ([]byte, bool, error), GetObject |
the bytes (and content type); absent is not an error |
| delete | delete(key) |
Delete(ctx, key) |
removes the value and its content type; removing one that is not there is not an error |
Content types
Section titled “Content types”Pass the media type on put and serve it from read. A content type is a media type as Go’s
mime.ParseMediaType reads one (image/jpeg, text/plain; charset=utf-8), at most 255 printable ASCII
characters, stored as given. Empty means application/octet-stream; anything else is refused (an
argument error) and nothing is stored. Both languages accept and refuse the same values.
photos.put("proofs/" + jobId + ".jpg", jpeg, "image/jpeg");StoredObject photo = photos.read("proofs/" + jobId + ".jpg").orElseThrow();return Response.bytes(200, photo.contentType(), photo.content());A value put without a type, or by an ObjectStore of your own written before content types existed,
reads as StoredObject.DEFAULT_CONTENT_TYPE.
err := photos.PutObject(ctx, "proofs/"+jobID+".jpg", objectstore.Object{Content: jpeg, ContentType: "image/jpeg"})obj, found, err := photos.GetObject(ctx, "proofs/"+jobID+".jpg")A value stored without a type reads back as objectstore.DefaultContentType. Validation is
objectstore.CheckContentType; a bad type is ErrInvalidArgument.
Per driver: memory keeps the type with the bytes; s3 sets it as the object’s Content-Type (an
object put by another tool without one reads as application/octet-stream); folder writes it to a
hidden file .<name>.content-type beside the value and removes it with the value. A type file that
holds no media type is a store failure, not a guess. The folder driver is for local use: Java writes the
type file before the value and Go after it, so a reader racing a put that changes the type may
briefly see mismatched bytes and type.
Setting up
Section titled “Setting up”Stores are named in code, each with the driver its factory chooses; there is no object-stores
configuration, and a leftover section fails start-up. It is the same pattern as
locks.
App.builder() .module( ObjectStoresModule.builder() .store("archive", S3ObjectStores.s3("acme-archive").withPrefix("ingest/sets")) .store("scratch", ObjectStoreFactories.folder(Path.of("/tmp/ingest"))) .defaultStore("archive") .build());
ObjectStore archive = app.get(ObjectStores.class).get("archive");archive.put("sets/2026-10-21/apply-1.json", bytes);Optional<byte[]> back = archive.get("sets/2026-10-21/apply-1.json");| Factory | Driver | Needs |
|---|---|---|
ObjectStoreFactories.memory() (framework-objectstore) |
memory: this JVM only |
nothing; for tests |
ObjectStoreFactories.folder(directory) |
folder: a file per value under an absolute directory, created if missing |
APP_ENV local or test; any other value fails start-up |
S3ObjectStores.s3(bucket) (framework-objectstore-s3) |
s3: AWS SDK for Java 2 |
an existing bucket; credentials and region from the SDK’s default chains |
The memory and folder factories take withMaxBytes(n). S3 options are copies from with... methods:
withPrefix, withRegion, withEndpoint, withMaxBytes and withVerifyAtStartup.
d := objectstore.Declare(app) // in mainall, err := objectstore.Build(ctx, b, d, objectstore.WithStore("archive", s3store.Bucket("acme-archive", s3store.Prefix("ingest/sets"))), objectstore.WithStore("scratch", objectstore.Folder("/var/tmp/ingest")), objectstore.DefaultStore("archive"))archive, _ := all.Default()err = archive.Put(ctx, "sets/2026-10-21/apply-1.json", data)data, found, err := archive.Get(ctx, "sets/2026-10-21/apply-1.json")| Factory | Driver | Needs |
|---|---|---|
objectstore.Memory() |
memory |
nothing; for tests |
objectstore.Folder(dir) |
folder |
APP_ENV local (the default) or test; any other value fails start-up |
s3store.Bucket(bucket, ...) |
s3: AWS SDK for Go v2 |
an existing bucket; credentials and region from the SDK’s chains |
objectstore.MaxBytes(n) sets the largest value (at least 1; default 64 MiB). S3 options:
s3store.Prefix, Region, Endpoint, MaxBytes, VerifyAtStartup. all.Get(name) returns a store or
an error naming the known stores; all.Names() lists them.
Store names match [a-z][a-z0-9-]* and are unique. With one store it is the default; with several you
must name the default. The folder driver is refused outside local and test because a folder on one
machine is not shared storage.
S3 options
Section titled “S3 options”| Option | Meaning |
|---|---|
prefix (ingest/sets) |
everything is stored under that prefix, so several stores can share a bucket |
| region | otherwise the SDK’s chain decides (AWS_REGION, profile, role) |
| endpoint | an S3-compatible service such as LocalStack or MinIO; path-style addressing, checksums only where required |
| max bytes | largest value accepted (default 64 MiB) |
| verify at start-up | by default start-up checks the bucket with HeadBucket, which needs s3:ListBucket; turn it off if the role lacks that |
A bucket that cannot be reached fails start-up naming the store. The SDK’s own retry policy applies; the framework adds none.
Keys and limits
Section titled “Keys and limits”A key is 1 to 512 characters: segments separated by a single /, each starting with an ASCII letter or
digit and holding letters, digits, ., - and _. So there is no leading or trailing slash, no empty
segment and no . or .., which keeps a key inside a folder store. A key the rules refuse is an
argument error from every driver, so a key that works in a test works when deployed. The rule is one
shared vector, conformance/objectstore/keys.json.
Do not use one key as both a value and the start of another (a and a/b): a folder cannot hold both,
and the folder driver reports a store failure.
A value over the store’s limit (64 MiB unless changed) is an argument error on put and a store failure on get. Values are held in memory, so this is for small and medium objects, not for streaming large files.
Failures and lifecycle
Section titled “Failures and lifecycle”ObjectStoreException (Java) or an error wrapping ErrStore (Go) means the store could not be read or
written, naming the store and key. The framework never retries; the caller decides.
Stores are closed with the application (S3 closes its client, the folder driver closes its root). A store that fails to build fails start-up with a problem naming it, and stores built before it are closed.
Writing and testing a driver
Section titled “Writing and testing a driver”A driver is an ObjectStoreFactory (Java) or a Store (Go). Each language publishes the contract suite:
ObjectStoreContract in the framework-objectstore test-jar, and objectstoretest.Run(t, harness) in Go
(round trip, replacement, binary-safe and empty values, idempotent delete, refused keys, the size limit,
concurrent writers, content types). The S3 tests run against an in-process S3 and need no Docker; set
FW_S3_ENDPOINT (for example http://localhost:4566) to run the same contract against LocalStack.
Specification: Object stores.