Documentation
¶
Index ¶
Constants ¶
const ID = "storage"
Variables ¶
var HookProbeKey = xctx.NewKey[*StorageEvents]("flow.storage.events")
HookProbeKey is the context key set by the storage.events hook when any storage event fires. Test fixtures and runtime probes read it to assert that hooks fired.
The value is a *StorageEvents pointer (never nil when set) so consumers can read the accumulated event log without copying.
Functions ¶
func Bundle ¶
Bundle returns a fresh Bundle for a single @require declaration.
A single bundle instance owns:
- one storage.Registry (the backends are shared, read-only, for every compilation this bundle serves), and
- a list of per-compilation stores it created, so Shutdown can close every opened Instance on teardown.
The three callbacks below cooperate on a single per-compilation store. The order is:
- OnPreprocess creates the store from meta["storage"] once, installs the :cache_store= / :idempotent_store= / :dedup_store= advisor against it, and records it in meta[storeMetaKey].
- Materialize reuses the store from meta (does NOT create a second one) and mounts <alias>.<kind>.<op> actions that close over it.
- WrapPipeline injects the same store into the runtime context so the generic storage.* actions can resolve it via currentStore(ctx).
If a flow declares no @storage directives, all three callbacks are no-ops and the compiled program is not wrapped at all.
Types ¶
type StorageEvent ¶
type StorageEvent struct {
Kind string // "cache_hit", "cache_miss", "error"
Store string // the @storage declaration name
Action string // the action name, e.g. "storage.kv.get"
Key string // the key passed to the action, if any
}
StorageEvent records one storage operation outcome.
type StorageEvents ¶
type StorageEvents struct {
// contains filtered or unexported fields
}
StorageEvents is the per-request accumulator that the storage.events hook stamps into the context on first miss/hit. Concurrent-safe; intended for observability and test assertion.
func (*StorageEvents) Events ¶
func (s *StorageEvents) Events() []StorageEvent
Events returns a snapshot copy of the accumulated events, in chronological order.
func (*StorageEvents) Record ¶
func (s *StorageEvents) Record(e StorageEvent)
Record appends an event. Safe for concurrent use.