Documentation
¶
Index ¶
- type Registry
- func (r *Registry) Count(cluster logicalcluster.Name) int64
- func (r *Registry) Dec(cluster logicalcluster.Name)
- func (r *Registry) DefaultLimit() int64
- func (r *Registry) EnforcementActive() bool
- func (r *Registry) Inc(cluster logicalcluster.Name)
- func (r *Registry) LimitFor(cluster logicalcluster.Name, annotations map[string]string) int64
- func (r *Registry) ReplaceBase(counts map[logicalcluster.Name]int64)
- func (r *Registry) SetEnforcementActive(active bool)
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry tracks the total number of objects per logical cluster on this shard. A periodic etcd scan provides the authoritative base counts, and the admission plugin applies deltas (+1 per admitted create, -1 per delete) between scans. The effective count is base + delta. Every completed scan replaces the base and resets all deltas, so any drift (e.g. from writes that failed after admission) self-corrects within one scan interval.
func NewRegistry ¶
NewRegistry creates a Registry with the given shard-wide default limit. A defaultLimit <= 0 means no default limit is enforced.
func (*Registry) Count ¶
func (r *Registry) Count(cluster logicalcluster.Name) int64
Count returns the effective object count for the given logical cluster.
func (*Registry) Dec ¶
func (r *Registry) Dec(cluster logicalcluster.Name)
Dec records an object deletion in the given logical cluster.
func (*Registry) DefaultLimit ¶
DefaultLimit returns the shard-wide default limit.
func (*Registry) EnforcementActive ¶
EnforcementActive reports whether any limit is potentially in effect on this shard. It is maintained by the scanner and serves as a cheap fast path for admission when the feature is unused.
func (*Registry) Inc ¶
func (r *Registry) Inc(cluster logicalcluster.Name)
Inc records an admitted object creation in the given logical cluster.
func (*Registry) LimitFor ¶
LimitFor resolves the effective limit for a logical cluster from its annotations, falling back to the shard-wide default. A return value <= 0 means no limit is enforced. An unparseable annotation value falls back to the default.
The shard-wide default does not apply to the root and system logical clusters: the shard writes bootstrap content there after they are ready, and a default limit would break shard bootstrapping (and upgrades adding new root content). They can still be limited with an explicit annotation.
func (*Registry) ReplaceBase ¶
func (r *Registry) ReplaceBase(counts map[logicalcluster.Name]int64)
ReplaceBase replaces the authoritative base counts with the result of a completed scan and resets all deltas.
func (*Registry) SetEnforcementActive ¶
SetEnforcementActive is called by the scanner to enable or disable enforcement.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner periodically counts all objects per logical cluster on this shard by scanning etcd keys and feeds the results into a Registry.
func NewScanner ¶
func NewScanner( kv clientv3.KV, prefix string, interval time.Duration, registry *Registry, lcLister corev1alpha1listers.LogicalClusterClusterLister, shardName string, ) *Scanner
NewScanner creates a Scanner. prefix is the etcd storage prefix of this shard.