Documentation
¶
Overview ¶
Package cell owns long-lived runtime state (counters, breaker copies, rotation state, shared caches) keyed by stable ids, so the state outlives the published generations that point at it. A cell is created on first Acquire and linked to the derived object being built; the engine reports at each publish which cells the new generation links, and Expire drops cells left unlinked for longer than IdleTTL.
Out of scope: what a cell holds, how it syncs with a store, and any timer: the registry runs no goroutine, the caller drives Expire.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶
Key identifies a cell: a type name and an id the owner builds from stable ids. Type keeps two cell types from colliding on one id.
type Linker ¶
type Linker interface{ Link(Key) }
Linker is what Acquire needs from the caller: a way to say "the object I am building uses this cell". The engine's transaction implements it.
type Options ¶
type Options struct {
// IdleTTL is how long an unlinked cell survives before Expire drops it.
// Linked and pinned cells never expire.
IdleTTL time.Duration
// OnDrop is called with the cell value when it leaves the registry, so a
// type that holds store-side state can flush it.
OnDrop func(k Key, v any)
}
Options sets the registry's expiry policy.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry owns every cell in the process. One per process.
func (*Registry) Expire ¶
Expire drops every unpinned cell left unlinked for at least IdleTTL and returns how many it dropped.