objectcount

package
v0.33.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

func NewRegistry(defaultLimit int64) *Registry

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

func (r *Registry) DefaultLimit() int64

DefaultLimit returns the shard-wide default limit.

func (*Registry) EnforcementActive

func (r *Registry) EnforcementActive() bool

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

func (r *Registry) LimitFor(cluster logicalcluster.Name, annotations map[string]string) int64

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

func (r *Registry) SetEnforcementActive(active bool)

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.

func (*Scanner) Start

func (s *Scanner) Start(ctx context.Context)

Start runs the scanner until ctx is done.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL