Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvictCluster ¶ added in v2.32.0
func EvictCluster(clusterPath logicalcluster.Path)
EvictCluster notifies every registered cache that clusterPath has been deleted and its cached client (and everything that client transitively pins — REST client, codec factory, JSON decoder state, OpenAPI schemas) can be released. Wire this to a LogicalCluster delete handler to bound retained memory per workspace lifetime. See https://github.com/kcp-dev/kcp/issues/4071.
Dead entries (caches whose only remaining reference was the weak entry in this registry) are pruned in-place during the iteration.
func SetCluster ¶
SetCluster modifies the config host path to include the cluster endpoint.
Note: it is the caller responsibility to make a copy of the rest config.
Types ¶
type Cache ¶
type Cache[R any] interface { ClusterOrDie(clusterPath logicalcluster.Path) R Cluster(clusterPath logicalcluster.Path) (R, error) // Evict drops the cached client for clusterPath, if any. Used to release // per-cluster client state (REST clients, codec factories, parsed // schemas) when a logical cluster is deleted. Safe to call concurrently // with Cluster / ClusterOrDie. No-op if the path is not cached. Evict(clusterPath logicalcluster.Path) }
Cache is a client factory that caches previous results.
func NewCache ¶
NewCache creates a new client factory cache using the given constructor. The cache is auto-registered with the package-level EvictCluster fan-out so per-cluster entries can be released when a LogicalCluster is deleted. The registry holds the cache weakly: if all references to the returned Cache are dropped, it becomes eligible for GC and is pruned from the registry lazily.