Documentation
¶
Index ¶
- Constants
- Variables
- func Add(ctx context.Context, ref moRef, id string) (err error)
- func CacheGetStats() []any
- func Close(ctx context.Context) (err error)
- func DefaultWatchedPropertyPaths() []string
- func JoinContext(left, right context.Context) context.Context
- func NewContext() context.Context
- func Remove(ctx context.Context, ref moRef, id string) (err error)
- func ValidateContext(ctx context.Context) bool
- func WithContext(parent context.Context) context.Context
- type LookupNamespacedNameResult
- type Result
- type Watcher
Constants ¶
const ( // CacheMaxKeys is the maximum number of VMs for which to cache properties. // // A single VM takes 615 bytes when cached, which means 25,000 cached VMs // take only 14.66 MiB in memory. // // Even if each VM took 1 KiB, that would mean 25,000 VMs would only take up // 24.41 MiB in memory. CacheMaxKeys = 25000 // CacheTTL is the expiry time for items in the cache. CacheTTL = time.Hour * 24 )
Variables ¶
var ( // ErrAsyncSignalDisabled is returned from the Add/Remove functions if they // are called while async signal is disabled. ErrAsyncSignalDisabled = errors.New("async signal disabled") // ErrNoWatcher is returned from the Add/Remove functions if they are called // without a watcher in the context. ErrNoWatcher = errors.New("no watcher") )
var ( // Cache is an LRU cache used to cache the properties of VMs. Cache expcache.Cache[moRef, map[string]string] )
Functions ¶
func Add ¶
Add starts watching a container to which VirtualMachine resources may belong, such as a Folder, Cluster, ResourcePool, etc.
func CacheGetStats ¶ added in v1.10.0
func CacheGetStats() []any
CacheGetStats returns the key/value pairs required to log the cache's stats. This is an expensive operation as it locks the cache to get the base stats and then again, per object in the cache, to calculate the total size of the cache.
func DefaultWatchedPropertyPaths ¶
func DefaultWatchedPropertyPaths() []string
DefaultWatchedPropertyPaths returns the default set of property paths to watch.
func JoinContext ¶
JoinContext returns a new context that contains a reference to the functions object from the specified context. This function panics if the provided context does not contain a functions object. This function is thread-safe.
func NewContext ¶
NewContext returns a new context with a new functions object.
func Remove ¶
Remove stops watching a container to which VirtualMachine resources may belong, such as a Folder, Cluster, ResourcePool, etc.
func ValidateContext ¶
ValidateContext returns true if the provided context contains the functions object.
Types ¶
type LookupNamespacedNameResult ¶
type LookupNamespacedNameResult struct {
Namespace string
Name string
// Verified indicates whether or not the VM's Kubernetes resource has the
// vSphere VM's managed object ID in status.uniqueID.
Verified bool
VerifiedObj any
// Deleted indicates whether the VM's Kubernetes resource has a
// non-zero deletion timestamp.
Deleted bool
}
LookupNamespacedNameResult is returned from a call to lookup the namespaced name of a vSphere VM.
type Result ¶
type Result struct {
// Namespace is the namespace to which the VirtualMachine resource belongs.
Namespace string
// Name is the name of the VirtualMachine resource.
Name string
// Ref is the ManagedObjectReference for the VM in vSphere.
Ref moRef
// Verified is true if the VirtualMachine resource identified by Namespace
// and Name has already been verified to exist in this Kubernetes cluster.
Verified bool
VerifiedObj any
}
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func Start ¶
func Start( ctx context.Context, client *vim25.Client, watchedPropertyPaths []string, additionalIgnoredExtraConfigKeys []string, lookupNamespacedName lookupNamespacedNameFn, containerRefsWithIDs map[moRef][]string) (*Watcher, error)
Start begins watching a vSphere server for updates to VM Service managed VMs. If watchedPropertyPaths is nil, DefaultWatchedPropertyPaths will be used. The containerRefsWithIDs parameter may be used to start the watcher with an initial list of entities to watch.
func (*Watcher) Done ¶
func (w *Watcher) Done() <-chan struct{}
Done returns a channel that is closed when the watcher is shutdown.