Documentation
¶
Index ¶
- type Deps
- type DsItems
- type Handler
- type KVData
- type KvdbReflector
- func (r *KvdbReflector) Init() error
- func (r *KvdbReflector) ObjectCreated(obj interface{}) error
- func (r *KvdbReflector) ObjectDeleted(obj interface{}) error
- func (r *KvdbReflector) ObjectUpdated(oldObj, newObj interface{}) error
- func (r *KvdbReflector) PublishStatus(obj interface{}, opRetval error) error
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 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.
Click to show internal directories.
Click to hide internal directories.