backend

package
v0.0.4-0...-de66a47 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigMapKey = "data"

Variables

This section is empty.

Functions

This section is empty.

Types

type AppLogic

type AppLogic[T1 client.Object] interface {
	Get(ctx context.Context, a T1) (T1, error)
	Validate(ctx context.Context, a T1) (string, error)
	Apply(ctx context.Context, a T1) (T1, error)
	Delete(ctx context.Context, a T1) error
}

func NewApplogic

func NewApplogic[T1 client.Object](cfg *ApplogicConfig[T1]) (AppLogic[T1], error)

type ApplogicConfig

type ApplogicConfig[T1 client.Object] struct {
	GetHandler      GetHandler[T1]
	ValidateHandler ValidateHandler[T1]
	ApplyHandler    ApplyHandler[T1]
	DeleteHandler   DeleteHandler[T1]
}

type ApplyHandler

type ApplyHandler[T1 client.Object] func(context.Context, T1) (T1, error)

type Backend

type Backend interface {
	// CreateIndex creates a backend index
	CreateIndex(ctx context.Context, cr []byte) error
	// DeleteIndex deletes a backend index
	DeleteIndex(ctx context.Context, cr []byte) error
	// List the data from the backend index
	List(ctx context.Context, cr []byte) (any, error)
	// Add a dynamic watch with callback to the backend index
	AddWatch(ownerGvkKey, ownerGvk string, fn CallbackFn)
	// Delete a dynamic watch with callback deom the backend index
	DeleteWatch(ownerGvkKey, ownerGvk string)
	//GetClaim return the claim if it exists
	GetClaim(ctx context.Context, cr []byte) ([]byte, error)
	// Claim claims an entry in the backend index
	Claim(ctx context.Context, cr []byte) ([]byte, error)
	// DeleteClaim delete a claim in the backend index
	DeleteClaim(ctx context.Context, cr []byte) error
}

type CMConfig

type CMConfig struct {
	Client      client.Client
	GetData     GetDataFn
	RestoreData RestoreDataFn
	Prefix      string
}

type Cache

type Cache[T1 any] interface {
	IsInitialized(corev1.ObjectReference) bool
	SetInitialized(corev1.ObjectReference) error
	Get(corev1.ObjectReference, bool) (T1, error)
	Create(corev1.ObjectReference, T1)
	Delete(corev1.ObjectReference)
}

func NewCache

func NewCache[T1 any]() Cache[T1]

type CallbackFn

type CallbackFn func(table.Routes, resourcepb.StatusCode)

type DeleteHandler

type DeleteHandler[T1 client.Object] func(context.Context, T1) error

type GetDataFn

type GetDataFn func(ctx context.Context, ref corev1.ObjectReference) ([]byte, error)

type GetHandler

type GetHandler[T1 client.Object] func(context.Context, T1) (T1, error)

type RestoreDataFn

type RestoreDataFn func(ctx context.Context, ref corev1.ObjectReference, cm *corev1.ConfigMap) error

type Storage

type Storage[T1, T2 any] interface {
	Restore(ctx context.Context, ref corev1.ObjectReference) error
	// only used in configmap
	SaveAll(ctx context.Context, ref corev1.ObjectReference) error
	// Destroy removes the store db
	Destroy(ctx context.Context, ref corev1.ObjectReference) error

	Get(ctx context.Context, claim T1) ([]T2, error)
	Set(ctx context.Context, claim T1) error
	Delete(ctx context.Context, claim T1) error
}

func NewCMBackend

func NewCMBackend[claim, entry any](cfg *CMConfig) (Storage[claim, entry], error)

func NewNopStorage

func NewNopStorage[T1, T2 any]() Storage[T1, T2]

type ValidateHandler

type ValidateHandler[T1 client.Object] func(context.Context, T1) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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