kvdbreflector

package
v3.3.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Log          logging.Logger
	Publish      keyval.KvBytesPlugin
	ServiceLabel servicelabel.ReaderAPI
	Informer     k8sCache.SharedIndexInformer
	Handler      Handler
}

Deps defines dependencies for KvdbReflector.

type DsItems

type DsItems map[string][]byte

DsItems defines the structure holding items listed from the data store.

type Handler

type Handler interface {
	// CrdName should return a name of the CRD. Used only for logging purposes,
	// i.e. it doesn't really have to match the type name, but should be readable.
	CrdName() string

	// CrdKeyPrefix should return longest-common prefix under which the instances
	// of the given CRD are reflected into KVDB.
	// If the CRD is reflected under KSR key prefix, return <underKsrPrefix> as
	// true and <prefix> as relative to the KSR prefix.
	CrdKeyPrefix() (prefix string, underKsrPrefix bool)

	// IsCrdKeySuffix should return true if the given key suffix, found in KVDB under
	// CrdKeyPrefix(), really belongs to this CRD. Unless the prefix returned by
	// CrdKeyPrefix() overlaps with some other CRDs or KSR-reflected K8s state
	// data that need to be excluded by mark-and-sweep, just return true.
	IsCrdKeySuffix(keySuffix string) bool

	// CrdObjectToKVData should convert the K8s representation of the CRD into the
	// corresponding data that should be mirrored into KVDB.
	CrdObjectToKVData(obj interface{}) (data []KVData, err error)

	// IsExclusiveKVDB should return true if KvdbReflector is the only writer
	// for the given key-space. If not, the mark-and-sweep procedure will not
	// remove extra (i.e. not defined by CRD) records from KVDB, as they
	// might have been inserted into the DB from different configuration sources
	// and should be preserved.
	IsExclusiveKVDB() bool

	// PublishCrdStatus should update the Status information associated with the resource (if defined).
	PublishCrdStatus(obj interface{}, opRetval error) error
}

Handler defines the interface that needs to be implemented to use KvdbReflector with a specific CRD type.

type KVData

type KVData struct {
	// ProtoMsg can be used when the KVDB-mirrored CRD data are modelled using protobuf.
	// If not, then use MarshalledData instead.
	ProtoMsg proto.Message

	// MarshalledData are already marshalled data to be written into the KVDB under the given key suffix.
	// Use as an alternative when proto message is not available.
	MarshalledData []byte

	// KeySuffix under which the given data should be reflected into KVDB (i.e. without the prefix returned by CrdKeyPrefix).
	KeySuffix string
}

KVData is a key->data pair to be written into KVDB to reflect a given CRD instance.

type KvdbReflector

type KvdbReflector struct {
	Deps
	// contains filtered or unexported fields
}

KvdbReflector is a generic CRD handler which just reflects created instances of a given CRD into a key-value database.

func (*KvdbReflector) Init

func (r *KvdbReflector) Init() error

Init prepared broker for the KV database access.

func (*KvdbReflector) ObjectCreated

func (r *KvdbReflector) ObjectCreated(obj interface{}) error

ObjectCreated is called when a CRD object is created

func (*KvdbReflector) ObjectDeleted

func (r *KvdbReflector) ObjectDeleted(obj interface{}) error

ObjectDeleted is called when a CRD object is deleted

func (*KvdbReflector) ObjectUpdated

func (r *KvdbReflector) ObjectUpdated(oldObj, newObj interface{}) error

ObjectUpdated is called when a CRD object is updated

func (*KvdbReflector) PublishStatus

func (r *KvdbReflector) PublishStatus(obj interface{}, opRetval error) error

PublishStatus is just forwarded to the handler.

Jump to

Keyboard shortcuts

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