memorystorage

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

README

Memory Storage Layer v2 (Alpha)

Due to significant updates and modifications required for the memory storage layer, version 2 (v2) has been introduced. Unless otherwise necessary, memory v1 will only be supported in Clusterpedia 0.x.

⚠️ The current memory v2 is in the alpha stage, has not undergone rigorous testing, and the foundational storage layer functionalities will be gradually improved and implemented.

This version draws inspiration from the apiserver/storage/cacher library but does not necessarily follow all its design principles.

Major Changes Compared to v1
ResourceVersion Format Changes

In v1, the resource version used a base64 encoded JSON format to merge the resource versions of each cluster into the resource's resource version field.

In v2, the resource version format is <prefix>.<increase int>.<original resource version>:

  • An incrementing integer is used to represent the sequential order of resources, for version operations during List and Watch.
  • The original resource version is retained.
  • The prefix is used to identify the validity of the incrementing integer when requests switch between instances.

For Watch requests, a JSON formatted ListOptions.ResourceVersion = {"<cluster>": "<resource version>"} is supported to maintain continuity of Watch requests when switching instances.

The clusterpedia version of Informer is required to replace the k8s.io/client-go Informer.

Using a Dedicated Resource Synchro

Due to the unique nature of the memory storage layer, it is unnecessary to use the default resource synchronizer of ClusterSynchro to maintain the informer store.

Memory v2 will directly use the native k8s informer as the resource synchronizer. Memory v2 will act as the Store for the k8s Informer, saving data directly into storage, avoiding intermediate operations and memory usage.

Supporting Dual Data Source Updates

In addition to the resource synchronizer saving resources in memory v2, external active additions, deletions, and modifications of memory v2 resources are also supported.

This ensures consistency of requests when supporting write operations at the apiserver layer through dual-write operations.

Documentation

Index

Constants

View Source
const (
	StorageName = "memory.v2/alpha"
)

Variables

This section is empty.

Functions

func ConvertMemoryResourceVersionToResourceVersion

func ConvertMemoryResourceVersionToResourceVersion(rv string) (uint64, string, error)

func ConvertMemoryResourceVersionToResourceVersionForList

func ConvertMemoryResourceVersionToResourceVersionForList(rv string) (uint64, error)

func ConvertResourceVersionToMemoryResourceVersion

func ConvertResourceVersionToMemoryResourceVersion(rv string) (uint64, string)

func ConvertToMemoryResourceVersionForList

func ConvertToMemoryResourceVersionForList(indexRV uint64) string

func NewStorageFactory

func NewStorageFactory(_ string) (storage.StorageFactory, error)

Types

type ResourceStorage

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

func (*ResourceStorage) ConvertDeletedObject

func (s *ResourceStorage) ConvertDeletedObject(obj interface{}) (runobj runtime.Object, _ error)

func (*ResourceStorage) Create

func (s *ResourceStorage) Create(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Delete

func (s *ResourceStorage) Delete(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Get

func (s *ResourceStorage) Get(ctx context.Context, cluster, namespace, name string, into runtime.Object) error

func (*ResourceStorage) GetStorageConfig

func (s *ResourceStorage) GetStorageConfig() *storage.ResourceStorageConfig

func (*ResourceStorage) List

func (s *ResourceStorage) List(ctx context.Context, listObject runtime.Object, opts *internal.ListOptions) error

func (*ResourceStorage) RecordEvent

func (s *ResourceStorage) RecordEvent(ctx context.Context, cluster string, event *corev1.Event) error

func (*ResourceStorage) Update

func (s *ResourceStorage) Update(ctx context.Context, cluster string, obj runtime.Object) error

func (*ResourceStorage) Watch

type StorageFactory

type StorageFactory struct{}

func (*StorageFactory) CleanCluster

func (s *StorageFactory) CleanCluster(ctx context.Context, cluster string) error

func (*StorageFactory) CleanClusterResource

func (s *StorageFactory) CleanClusterResource(ctx context.Context, cluster string, gvr schema.GroupVersionResource) error

func (*StorageFactory) GetCollectionResources

func (s *StorageFactory) GetCollectionResources(ctx context.Context) ([]*internal.CollectionResource, error)

func (*StorageFactory) GetResourceVersions

func (*StorageFactory) GetSupportedRequestVerbs

func (s *StorageFactory) GetSupportedRequestVerbs() []string

func (*StorageFactory) NewCollectionResourceStorage

func (s *StorageFactory) NewCollectionResourceStorage(cr *internal.CollectionResource) (storage.CollectionResourceStorage, error)

func (*StorageFactory) NewResourceStorage

func (s *StorageFactory) NewResourceStorage(config *storage.ResourceStorageConfig) (storage.ResourceStorage, error)

func (*StorageFactory) PrepareCluster

func (s *StorageFactory) PrepareCluster(cluster string) error

func (*StorageFactory) Shutdown

func (s *StorageFactory) Shutdown() error

Jump to

Keyboard shortcuts

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