Storage singleton
Expose a durable key-value style store via RPC on a singleton Flow.
Problem and approach
This package demonstrates a singleton flow that acts as a small persistent key-value store via RPC.
Key Components
- StorageFlow: Long-running singleton flow; RPCs add/get/remove items.
AttributeMap<String>: One Dex attribute instance per key (not one blob for the whole map).- AddStorageItemRequest: Request body for add.
API Endpoints
POST /design-pattern/storage/add— add or overwrite a keyGET /design-pattern/storage/get— get a key (null if missing)POST /design-pattern/storage/remove— delete a key
Why AttributeMap
Storing a Map inside a single Attribute rewrites the entire map on every
update and serializes all keys under one lock. AttributeMap keeps each key as
its own persistence entry, so updates are smaller and different keys do not
contend. Per-key set / delete need no whole-store RPC lock.
Each physical attribute still has a size limit (on the order of a few MB); this pattern is for small KV Step, not a general database.
Usage notes
- Controller auto-starts the singleton flow if it is not running.
- Prefer search attributes when you need many non-singleton storage flows to be queryable.
Code examples
Full runnable samples live under examples/{go,java,python,typescript} (HTTP prefix /design-pattern/... where applicable).
# See examples/python/dex_examples/patterns/workflow/storage/