composite

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package composite provides a k8s client composed of a cached and an uncached client. For Get operations, the cache is used, in case the target object isn't available in the cache, the client will perform a GET call using the uncached client to get the object directly from the k8s api server. For List operations, the client can be configured to use the cache or directly list from the k8s api server. Unlike Get, List does not return error when objects are not found. It returns an empty list. The decision to retry without cache can't be made for List operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientFromManager

func NewClientFromManager(mgr manager.Manager, opts Options) (client.Client, error)

NewClientFromManager combines a cached and an uncached client to return a composite client. The default cache returned by the controller manager is a cached client.

Types

type Client

type Client struct {
	client.Client
	Options
	// contains filtered or unexported fields
}

Client is a composite client, composed of cached and uncached clients. It can be used to query objects from cache and fall back to use the raw client and get the object directly from the API server when there's a cache miss.

func NewClient

func NewClient(cached client.Client, uncached client.Client, opts Options) *Client

NewClient creates and returns a composite Client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

Get first fetches the object using the cached client. If the object is not found in the cached client, it retries using the uncached client.

func (*Client) List

func (c *Client) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

List lists the objects based on the client configuration. If RawListing is true, it uses the uncached client to list, else it uses the cached client.

type Options

type Options struct {
	// RawListing is used to perform raw listing operations, uncached.
	RawListing bool
}

ClientOption is used to configure the client.

Jump to

Keyboard shortcuts

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