client

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package client provides the Runtime SDK client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallExtensionCacheEntry

type CallExtensionCacheEntry struct {
	CacheKey string
	Response runtimehooksv1.ResponseObject
}

CallExtensionCacheEntry is a cache entry for the cache that can be used with the CallExtension call via the WithCaching option.

func (CallExtensionCacheEntry) Key

Key returns the cache key of a CallExtensionCacheEntry.

type CallExtensionOption

type CallExtensionOption interface {
	// ApplyToOptions applies this configuration to the given CallExtensionOptions.
	ApplyToOptions(*CallExtensionOptions)
}

CallExtensionOption is the interface for configuration that modifies CallExtensionOptions for a CallExtension call.

type CallExtensionOptions

type CallExtensionOptions struct {
	WithCaching  bool
	Cache        cache.Cache[CallExtensionCacheEntry]
	CacheKeyFunc func(extensionName, extensionConfigResourceVersion string, request runtimehooksv1.RequestObject) string
}

CallExtensionOptions contains the options for the CallExtension call.

type Client

type Client interface {
	// WarmUp can be used to initialize a "cold" RuntimeClient with all
	// known runtimev1.ExtensionConfigs at a given time.
	// After WarmUp completes the RuntimeClient is considered ready.
	WarmUp(extensionConfigList *runtimev1.ExtensionConfigList) error

	// IsReady return true after the RuntimeClient finishes warmup.
	IsReady() bool

	// Discover makes the discovery call on the extension and returns an updated ExtensionConfig
	// with extension handlers information in the ExtensionConfig status.
	Discover(context.Context, *runtimev1.ExtensionConfig) (*runtimev1.ExtensionConfig, error)

	// Register registers the ExtensionConfig.
	Register(extensionConfig *runtimev1.ExtensionConfig) error

	// Unregister unregisters the ExtensionConfig.
	Unregister(extensionConfig *runtimev1.ExtensionConfig) error

	// CallAllExtensions calls all the ExtensionHandler registered for the hook.
	CallAllExtensions(ctx context.Context, hook runtimecatalog.Hook, forObject metav1.Object, request runtimehooksv1.RequestObject, response runtimehooksv1.ResponseObject) error

	// CallExtension calls the ExtensionHandler with the given name.
	CallExtension(ctx context.Context, hook runtimecatalog.Hook, forObject metav1.Object, name string, request runtimehooksv1.RequestObject, response runtimehooksv1.ResponseObject, opts ...CallExtensionOption) error
}

Client is the runtime client to interact with extensions.

type WithCaching

type WithCaching struct {
	Cache        cache.Cache[CallExtensionCacheEntry]
	CacheKeyFunc func(extensionName, extensionConfigResourceVersion string, request runtimehooksv1.RequestObject) string
}

WithCaching enables caching for the CallExtension call.

func (WithCaching) ApplyToOptions

func (w WithCaching) ApplyToOptions(in *CallExtensionOptions)

ApplyToOptions applies WithCaching to the given CallExtensionOptions.

Jump to

Keyboard shortcuts

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