Documentation ¶
Overview ¶
Package mem is a generated GoMock package.
Index ¶
- Constants
- Variables
- func Describe(o runtime.Object) string
- func DuplicateInformerCache(informer cache.SharedIndexInformer, newIndexers cache.Indexers) cache.Indexer
- func FilterMarshal(obj runtime.Object) ([]byte, error)
- func GetControllerOf(controllee metav1.Object) (*metav1.OwnerReference, error)
- func GetOwneeReferences(owner runtime.Object, gvk schema.GroupVersionKind) ([]metav1.OwnerReference, error)
- func IsMemObject(obj metav1.Object) bool
- func IsUIDEqual(obj0, obj1 runtime.Object) (bool, error)
- func Kind(obj runtime.Object) string
- func Memorize(obj runtime.Object) error
- func MergeOwnerReferences(src []metav1.OwnerReference, dst []metav1.OwnerReference) []metav1.OwnerReference
- func MetaAccessors(fn func(accessor ...metav1.Object) error, objs ...runtime.Object) error
- func MetaName(obj runtime.Object) string
- func MetaNameKey(obj interface{}) (string, error)
- func MetaResourceVersion(obj runtime.Object) (uint64, error)
- func ParseResourceVersion(rv string) (uint64, error)
- func SetMetaResourceVersion(obj runtime.Object, ver uint64) (uint64, error)
- func SetOwnerReferences(owner runtime.Object, ownerGvk schema.GroupVersionKind, ownee metav1.Object) error
- func Stringify(o interface{}) string
- func TweakObjectMetas(obj runtime.Object, ver uint64) error
- func TweakTypeMetas(gvk schema.GroupVersionKind, obj runtime.Object) error
- func Unmemorize(obj runtime.Object) error
- type BatchObject
- type Batcher
- type FakePersister
- type FilterMarshaler
- type FsPersister
- type FuncBatcher
- type KeyFunc
- type MetaInfo
- type MockPersister
- type MockPersisterMockRecorder
- type MocknegotiatedPersister
- type MocknegotiatedPersisterMockRecorder
- type NamespacePersisterFactory
- type NewObjectFunc
- type OneBatcher
- type OpResult
- type Persister
- type ReadResult
- type ResourceScheme
- func (s *ResourceScheme) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
- func (s *ResourceScheme) LogInfo()
- func (s *ResourceScheme) New(gvr schema.GroupVersionResource) (runtime.Object, error)
- func (s *ResourceScheme) NewList(gvr schema.GroupVersionResource) (runtime.Object, error)
- func (s *ResourceScheme) Scheme() *runtime.Scheme
- type SelectionPredicate
- type Store
- type StoreOption
- type TraitsFunc
- type TraitsMatcher
- type WatchBroadcaster
- type WatchOptions
- type WriteResult
Constants ¶
const ( // MetricPersistMarshalTime marshal time in persist // labels: [namespace, batch_name, kind] MetricPersistMarshalTime = "persist_marshal_time" // MetricPersistWriteTime write marshaled data in store time // labels: [namespace, batch_name, kind] MetricPersistWriteTime = "persist_write_time" // MetricPersistFileSize the final file size write to storage // labels: [namespace, batch_name, kind] MetricPersistFileSize = "persist_file_size" // MetricPersistCountInBatch the items count in 1 batch // labels: [namespace, batch_name, kind] MetricPersistCountInBatch = "persist_count_in_batch" // MetricStoreRunTime the cost time each store.run // labels: [name, namespace, kind] MetricStoreRunTime = "store_run_time" // MetricWatchSendTime send watch event time // labels: [kind, source] MetricWatchSendTime = "watch_send_time" )
const ( // MemObjectVersionAnnoKey the label key name for object version MemObjectVersionAnnoKey = "memkube/object-version" // MemObjectVersionAnnoValue version MemObjectVersionAnnoValue = "2.0.0" // MemObjectOwnerRefsKey the annotation key to hold mem object refs MemObjectOwnerRefsKey = "memkube/owner-refs" )
const (
//TouchName new start touch file name
TouchName = ".meta"
)
Variables ¶
var ( // ErrInvalidOwnerRefs invalid owner refs ErrInvalidOwnerRefs = errors.New("invalid mem-obj owner refs") )
var ( // ErrObjectInvalid the object to add/update is invalid ErrObjectInvalid = errors.New("object is invalid") )
var ( // ErrWaitTimeout wait operation timeout ErrWaitTimeout = errors.New("wait the operation result timeout") )
var Metrics = monitor.NewMetricFactory()
Metrics is a metric factory.
var PersistedVersion = version.Must(version.NewVersion(MemObjectVersionAnnoValue))
PersistedVersion all tag version < PersistedVersion will NOT be persisted. Some fields in runtime.Object doesn't need to persisted, here we use `"github.com/liip/sheriff"` library to filter these fields. e.g: Metas map[string]string `json:"metas" until:"1.0.0"`, when 1.0.0 < PersistedVersion, `Metas` will not be persisted.
Functions ¶
func DuplicateInformerCache ¶
func DuplicateInformerCache(informer cache.SharedIndexInformer, newIndexers cache.Indexers) cache.Indexer
DuplicateInformerCache duplicates cache from informer, it binds event handlers to the informer, and update items in duplicated cache. NOTE: If use this cache to get objects, but register handlers on the raw informer, data mismatched (notified by v2, but only get v1)
func FilterMarshal ¶
FilterMarshal filter some fields for a runtime.Object
func GetControllerOf ¶
func GetControllerOf(controllee metav1.Object) (*metav1.OwnerReference, error)
GetControllerOf returns a pointer to a copy of the controllerRef if controllee has a controller
func GetOwneeReferences ¶
func GetOwneeReferences(owner runtime.Object, gvk schema.GroupVersionKind) ([]metav1.OwnerReference, error)
GetOwneeReferences constructs owner references for an object. If the owner is mem-object, return its owner refs.
func IsMemObject ¶
IsMemObject checks if an object is mem-kube object.
func IsUIDEqual ¶
IsUIDEqual check if two objects has equal uid.
func MergeOwnerReferences ¶
func MergeOwnerReferences(src []metav1.OwnerReference, dst []metav1.OwnerReference) []metav1.OwnerReference
MergeOwnerReferences merge owner refs
func MetaAccessors ¶
MetaAccessors gets meta accessors for objects and call operation function.
func MetaNameKey ¶
MetaNameKey used in cache.Indexer.
func MetaResourceVersion ¶
MetaResourceVersion get resource version for an object.
func ParseResourceVersion ¶
ParseResourceVersion parse resource version
func SetMetaResourceVersion ¶
SetMetaResourceVersion set the resource version
func SetOwnerReferences ¶
func SetOwnerReferences(owner runtime.Object, ownerGvk schema.GroupVersionKind, ownee metav1.Object) error
SetOwnerReferences set owner references to object.
- If the owner is a k8s object, it's the real owner, set the owner to `OwnerReferences`
- If the owner is a mem object, then get the k8s owner of it (from `OwnerReferences`), and set the real k8s owner to ownee's OwnerReferences, and set the direct mem owner to ownee's Annotations.
func TweakObjectMetas ¶
TweakObjectMetas tweats some required properties for an object.
func TweakTypeMetas ¶
func TweakTypeMetas(gvk schema.GroupVersionKind, obj runtime.Object) error
TweakTypeMetas tweats object type metas.
func Unmemorize ¶
Unmemorize strips memory object as a normal kubenetes object.
Types ¶
type BatchObject ¶
type BatchObject struct { Name string `json:"name"` // Traits are some special properties parsed from object, to identify this batchObject. E.g: shardId in c2. Traits map[string]string `json:"traits,omitempty"` Items pendingList `json:"items"` // contains filtered or unexported fields }
BatchObject is a batch of object.
func NewBatchObject ¶
func NewBatchObject(name string) *BatchObject
NewBatchObject creates a new batch object.
func (*BatchObject) IsDrity ¶
func (b *BatchObject) IsDrity() bool
IsDrity persist only if the batch is dirty
func (*BatchObject) Marshal ¶
func (b *BatchObject) Marshal(encodig encodingType) ([]byte, error)
Marshal marshal this batch object
type Batcher ¶
type Batcher interface {
Batch([]*pendingObject) ([]*BatchObject, error)
}
Batcher batch a list of objects into batches.
type FakePersister ¶
type FakePersister struct {
// contains filtered or unexported fields
}
FakePersister is a persister.
func NewFakePersister ¶
func NewFakePersister() *FakePersister
NewFakePersister create a fake persister
func (*FakePersister) Persist ¶
func (p *FakePersister) Persist(b *BatchObject) error
Persist persists batch object.
func (*FakePersister) PersistMeta ¶
func (p *FakePersister) PersistMeta(*MetaInfo) error
PersistMeta persist meta info
func (*FakePersister) Recover ¶
func (p *FakePersister) Recover(fn NewObjectFunc) ([]*BatchObject, *MetaInfo, error)
Recover reload all objects.
type FilterMarshaler ¶
FilterMarshaler marshals object to a json string.
type FsPersister ¶
type FsPersister struct {
// contains filtered or unexported fields
}
FsPersister is a file system persister which used fstorage.
func NewFsPersister ¶
func NewFsPersister(url, backupURL string, namespace string, gvk schema.GroupVersionKind, matcher TraitsMatcher) (*FsPersister, error)
NewFsPersister create a new FsPersister.
func (*FsPersister) NegotiateEncoding ¶
func (p *FsPersister) NegotiateEncoding(o runtime.Object)
NegotiateEncoding negotiate encoding by object
func (*FsPersister) Persist ¶
func (p *FsPersister) Persist(obj *BatchObject) error
Persist persists batch object.
func (*FsPersister) PersistMeta ¶
func (p *FsPersister) PersistMeta(meta *MetaInfo) error
PersistMeta persist meta info
func (*FsPersister) Recover ¶
func (p *FsPersister) Recover(fn NewObjectFunc) ([]*BatchObject, *MetaInfo, error)
Recover reload all objects.
type FuncBatcher ¶
type FuncBatcher struct { TraitsFunc TraitsFunc KeyFunc KeyFunc }
FuncBatcher batch objects by a custom function.
func (*FuncBatcher) Batch ¶
func (b *FuncBatcher) Batch(items []*pendingObject) ([]*BatchObject, error)
Batch batch objects. Try the best to batch all objects, skip these failed objects.
type KeyFunc ¶
KeyFunc format a key for an object.
func HashedNameFuncLabelValue ¶
HashedNameFuncLabelValue labelValue+hash
func KeyFuncHashName ¶
KeyFuncHashName return $prefixFn(obj)-hash($name) % hashNum
func KeyFuncLabelValue ¶
KeyFuncLabelValue create a KeyFunc by label value.
type MetaInfo ¶
type MetaInfo struct { // [1, N], the current max version VersionSeed uint64 `json:"versionSeed"` }
MetaInfo tracks the meta info for the specified resource
func (*MetaInfo) CurrentVersion ¶
CurrentVersion get current version
func (*MetaInfo) IncVersionSeed ¶
IncVersionSeed inc the version seed
type MockPersister ¶
type MockPersister struct {
// contains filtered or unexported fields
}
MockPersister is a mock of Persister interface.
func NewMockPersister ¶
func NewMockPersister(ctrl *gomock.Controller) *MockPersister
NewMockPersister creates a new mock instance.
func (*MockPersister) EXPECT ¶
func (m *MockPersister) EXPECT() *MockPersisterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPersister) Persist ¶
func (m *MockPersister) Persist(arg0 *BatchObject) error
Persist mocks base method.
func (*MockPersister) PersistMeta ¶
func (m *MockPersister) PersistMeta(arg0 *MetaInfo) error
PersistMeta mocks base method.
func (*MockPersister) Recover ¶
func (m *MockPersister) Recover(fn NewObjectFunc) ([]*BatchObject, *MetaInfo, error)
Recover mocks base method.
type MockPersisterMockRecorder ¶
type MockPersisterMockRecorder struct {
// contains filtered or unexported fields
}
MockPersisterMockRecorder is the mock recorder for MockPersister.
func (*MockPersisterMockRecorder) Close ¶
func (mr *MockPersisterMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockPersisterMockRecorder) Persist ¶
func (mr *MockPersisterMockRecorder) Persist(arg0 interface{}) *gomock.Call
Persist indicates an expected call of Persist.
func (*MockPersisterMockRecorder) PersistMeta ¶
func (mr *MockPersisterMockRecorder) PersistMeta(arg0 interface{}) *gomock.Call
PersistMeta indicates an expected call of PersistMeta.
func (*MockPersisterMockRecorder) Recover ¶
func (mr *MockPersisterMockRecorder) Recover(fn interface{}) *gomock.Call
Recover indicates an expected call of Recover.
type MocknegotiatedPersister ¶
type MocknegotiatedPersister struct {
// contains filtered or unexported fields
}
MocknegotiatedPersister is a mock of negotiatedPersister interface.
func NewMocknegotiatedPersister ¶
func NewMocknegotiatedPersister(ctrl *gomock.Controller) *MocknegotiatedPersister
NewMocknegotiatedPersister creates a new mock instance.
func (*MocknegotiatedPersister) EXPECT ¶
func (m *MocknegotiatedPersister) EXPECT() *MocknegotiatedPersisterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MocknegotiatedPersister) NegotiateEncoding ¶
func (m *MocknegotiatedPersister) NegotiateEncoding(o runtime.Object)
NegotiateEncoding mocks base method.
type MocknegotiatedPersisterMockRecorder ¶
type MocknegotiatedPersisterMockRecorder struct {
// contains filtered or unexported fields
}
MocknegotiatedPersisterMockRecorder is the mock recorder for MocknegotiatedPersister.
func (*MocknegotiatedPersisterMockRecorder) NegotiateEncoding ¶
func (mr *MocknegotiatedPersisterMockRecorder) NegotiateEncoding(o interface{}) *gomock.Call
NegotiateEncoding indicates an expected call of NegotiateEncoding.
type NamespacePersisterFactory ¶
type NamespacePersisterFactory struct {
// contains filtered or unexported fields
}
NamespacePersisterFactory persister factory
func NewNamespacePersisterFactory ¶
func NewNamespacePersisterFactory(url, backupURL, namespace string) (*NamespacePersisterFactory, error)
NewNamespacePersisterFactory new fac
func (*NamespacePersisterFactory) Check ¶
func (f *NamespacePersisterFactory) Check() error
Check check url vaild
func (*NamespacePersisterFactory) NewFsPersister ¶
func (f *NamespacePersisterFactory) NewFsPersister(gvk schema.GroupVersionKind, matcher TraitsMatcher) (Persister, error)
NewFsPersister new FsPersister
type OneBatcher ¶
type OneBatcher struct {
Name string
}
OneBatcher batch all object into one batch.
func (*OneBatcher) Batch ¶
func (b *OneBatcher) Batch(items []*pendingObject) ([]*BatchObject, error)
Batch batch objects.
type Persister ¶
type Persister interface { Persist(*BatchObject) error PersistMeta(*MetaInfo) error Recover(fn NewObjectFunc) ([]*BatchObject, *MetaInfo, error) Close() error }
Persister persists a list of batch objects.
type ReadResult ¶
ReadResult for read operations.
type ResourceScheme ¶
type ResourceScheme struct {
// contains filtered or unexported fields
}
ResourceScheme tracks the resource to kind mapping.
func NewResourceScheme ¶
func NewResourceScheme(scheme *runtime.Scheme) *ResourceScheme
NewResourceScheme create a new ResourceScheme
func (*ResourceScheme) KindFor ¶
func (s *ResourceScheme) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
KindFor get the kind for a resource.
func (*ResourceScheme) LogInfo ¶
func (s *ResourceScheme) LogInfo()
LogInfo log details of this scheme.
func (*ResourceScheme) New ¶
func (s *ResourceScheme) New(gvr schema.GroupVersionResource) (runtime.Object, error)
New create an runtime.Object by resource type, similar with schema.Scheme.New
func (*ResourceScheme) NewList ¶
func (s *ResourceScheme) NewList(gvr schema.GroupVersionResource) (runtime.Object, error)
NewList create a XXXList runtime.Obejct for resource.
func (*ResourceScheme) Scheme ¶
func (s *ResourceScheme) Scheme() *runtime.Scheme
Scheme returns the runtime scheme.
type SelectionPredicate ¶
SelectionPredicate filter events
type Store ¶
type Store interface { Start(stopCh <-chan struct{}) error List(labels.Selector) ([]runtime.Object, uint64, error) Watch(*WatchOptions) (watch.Interface, error) Get(name string) (ReadResult, error) Peek(name string) (runtime.Object, error) Add(obj runtime.Object) (WriteResult, error) Update(obj runtime.Object) (WriteResult, error) Delete(name string) (WriteResult, error) }
Store stores memory objects.
func NewStore ¶
func NewStore(scheme *runtime.Scheme, gvk schema.GroupVersionKind, namespace string, batcher Batcher, persister Persister, opts ...StoreOption) Store
NewStore creates a store.
func NewTestStore ¶
NewTestStore creates a store for test
type StoreOption ¶
type StoreOption func(*persistedStore) *persistedStore
StoreOption defines the options for store.
func WithSilentWatchConsumer ¶
func WithSilentWatchConsumer(stopCh <-chan struct{}) StoreOption
WithSilentWatchConsumer consumes all events from this store and drop the events.
func WithStoreConcurrentPersist ¶
func WithStoreConcurrentPersist(worker int, qsize int) StoreOption
WithStoreConcurrentPersist set persist concurrent options.
func WithStorePersistPeriod ¶
func WithStorePersistPeriod(period time.Duration) StoreOption
WithStorePersistPeriod set persist period. Default 500ms
type TraitsFunc ¶
TraitsFunc parse traits from object.
func TraitsFuncLabels ¶
func TraitsFuncLabels(keys ...string) TraitsFunc
TraitsFuncLabels create a TraitsFunc by a list of labels.
type TraitsMatcher ¶
TraitsMatcher check if traits matches in persiter recover.
type WatchBroadcaster ¶
type WatchBroadcaster interface { Watch(opts *WatchOptions, pred SelectionPredicate) (watch.Interface, error) Action(event watch.Event) error Shutdown() }
WatchBroadcaster broadcasts watch events
func NewCacheWatchBroadcaster ¶
func NewCacheWatchBroadcaster(cap int, kind string) WatchBroadcaster
NewCacheWatchBroadcaster creates a cached watch broadcaster
type WatchOptions ¶
type WatchOptions struct { metav1.ListOptions // Set to true if watch in same process, default true LocalWatch *bool // Identify source Source string }
WatchOptions options for watch
type WriteResult ¶
WriteResult is write operation result.