store

package
v0.0.0-...-1aa1ecb Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Kubernetes identifies kubernetes as the scheduler
	Kubernetes = "kubernetes"
)

PX specific scheduler constants

Variables

View Source
var (
	// ErrKvdbNotInitialized is returned when kvdb is not initialized
	ErrKvdbNotInitialized = errors.New("KVDB is not initialized")
)

Functions

func GetSanitizedK8sName

func GetSanitizedK8sName(k8sName string) string

GetSanitizedK8sName will sanitize the name conforming to RFC 1123 standards so that it's a "qualified name" per k8s

Types

type KeyDoesNotExist

type KeyDoesNotExist struct {
	Key string
}

KeyDoesNotExist is error type when the key does not exist

func (*KeyDoesNotExist) Error

func (e *KeyDoesNotExist) Error() string

type KeyExists

type KeyExists struct {
	// Key that exists
	Key string
	// Message is an optional message to the user
	Message string
}

KeyExists is error type when the key already exist in store

func (*KeyExists) Error

func (e *KeyExists) Error() string

type Lock

type Lock struct {
	// Key is the name on which the lock is acquired.
	// This is used by the callers for logging purpose. Hence public
	Key string
	// Name of the Owner who acquired the lock
	Owner string
	// true if this lock was acquired using LockWithKey() interface
	LockedWithKey bool
	// contains filtered or unexported fields
}

Lock identifies a lock taken over CloudDrive store

type Params

type Params struct {
	// Kv is the bootstrap kvdb instance
	Kv kvdb.Kvdb
	// InternalKvdb indicates if PX is using internal kvdb or not
	InternalKvdb bool
	// SchedulerType indicates the platform pods are running on. e.g Kubernetes
	SchedulerType string
}

Params is the parameters to use for the Store object

type Store

type Store interface {
	// Lock locks the cloud drive store for a node to perform operations
	Lock(owner string) (*Lock, error)
	// Unlock unlocks the cloud drive store
	Unlock(storeLock *Lock) error
	// LockWithKey locks the cloud drive store with an arbitrary key
	LockWithKey(owner, key string) (*Lock, error)
	// IsKeyLocked checks if the specified key is currently locked
	IsKeyLocked(key string) (bool, string, error)
	// CreateKey creates the given key with the value. lockAs argument is used as an owner to lock the key.
	CreateKey(lockAs, key string, value []byte) error
	// PutKey updates the given key with the value. lockAs argument is used as an owner to lock the key.
	PutKey(lockAs, key string, value []byte) error
	// GetKey returns the value for the given key
	GetKey(key string) ([]byte, error)
	// DeleteKey deletes the given key. Sanitized version of the key is used internally for locking.
	DeleteKey(key string) error
	// EnumerateWithKeyPrefix enumerates all keys in the store that begin with the given key
	EnumerateWithKeyPrefix(key string) ([]string, error)
}

Store provides a set of APIs to CloudDrive to store its metadata in a persistent store

func GetStoreWithParams

func GetStoreWithParams(
	kv kvdb.Kvdb,
	schedulerType string,
	internalKvdb bool,
	name string,
	lockTryDuration time.Duration,
	lockHoldTimeout time.Duration,
) (Store, error)

GetStoreWithParams returns instance for Store kv: bootstrap kvdb schedulerType: node scheduler type e.g Kubernetes internalKvdb: If the cluster is configured to have internal kvdb name: Name for the store lockTryDuration: Total time to try acquiring the lock for lockHoldTimeout: Once a lock is acquired, if it's held beyond this time, there will be panic

func NewK8sStore

func NewK8sStore(clusterID string) (Store, configmap.ConfigMap, error)

NewK8sStore returns a Store implementation which uses k8s configmaps to store data.

func NewKVStore

func NewKVStore(kv kvdb.Kvdb) (Store, error)

NewKVStore returns a Store implementation which is a wrapper over kvdb.

Jump to

Keyboard shortcuts

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