machinecache

package
v1.7.0-test.listv2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AKSMachineClienter

type AKSMachineClienter interface {
	NewListPager(resourceGroupName string, resourceName string, agentPoolName string, options *armcontainerservice.MachinesClientListOptions) *runtime.Pager[armcontainerservice.MachinesClientListResponse]
	Get(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, machineName string, options *armcontainerservice.MachinesClientGetOptions) (armcontainerservice.MachinesClientGetResponse, error)
}

AKSMachineClienter provides operations for AKS machines.

type MachineCache

type MachineCache struct {
	// contains filtered or unexported fields
}

MachineCache caches AKS machine resources with TTL-based expiration.

func New

func New(ctx context.Context, client AKSMachineClienter, clusterResourceGroup, clusterName, aksMachinesPoolName string, opts ...Option) *MachineCache

New creates a new cache instance with a background worker for updates. Updates to the cache are triggered when a stale cache is accessed.

func (*MachineCache) GetWithFallback

func (c *MachineCache) GetWithFallback(ctx context.Context, machineName string, useCache bool) (*armcontainerservice.Machine, error)

GetWithFallback gets a machine. If useCache is true and the cache is fresh, it will attempt to return the machine from the cache. If the cache is stale or disabled, or if the machine is not found in the cache, it will fall back to calling the AKS API directly.

func (*MachineCache) Invalidate

func (c *MachineCache) Invalidate(machineName string)

Invalidate removes a specific machine from the cache by name.

func (*MachineCache) InvalidateAll

func (c *MachineCache) InvalidateAll()

InvalidateAll clears the entire cache, forcing the next access to fall through to the API.

func (*MachineCache) ListWithFallback

func (c *MachineCache) ListWithFallback(ctx context.Context, useCache bool) ([]*armcontainerservice.Machine, error)

ListWithFallback lists all machines in the AKS machines pool. If useCache is true and the cache is fresh, it will attempt to return the list from the cache. If the cache is stale or disabled, it will fall back to calling the AKS API directly.

func (*MachineCache) PollUntilDone

func (c *MachineCache) PollUntilDone(ctx context.Context, name string) (*armcontainerservice.ErrorDetail, error)

PollUntilDone polls for AKS machine provisioning completion using the cache. This polls indefinitely until the machine reaches a terminal state (Succeeded, Failed, or Deleting) or the context is canceled. If at any point the machine is not found, PollUntilDone will return an error.

type Option

type Option func(opts) opts

Option is a functional option for configuring MachineCache.

func WithPollInterval

func WithPollInterval(d time.Duration) Option

WithPollInterval sets the interval for polling machine provisioning state when using the PollUntilDone helper.

func WithPollTimeout

func WithPollTimeout(d time.Duration) Option

WithPollTimeout sets the maximum duration to wait for a machine to reach a terminal provisioning state before considering the poll to have timed out.

func WithTTL

func WithTTL(d time.Duration) Option

WithTTL sets a custom Time-to-Live (TTL) for the cache. It determines how long the cache is considered fresh before it needs to be refreshed. A TTL of 0 means the cache is always stale.

Jump to

Keyboard shortcuts

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