Documentation
¶
Index ¶
- func NewResourceEventHandler[O client.Object, R comparable](ctx context.Context, h handler.TypedEventHandler[O, R], ...) cache.ResourceEventHandler
- func PrimaryKey(ns, name string) string
- func SplitPrimaryKey(key string) (ns, name string)
- type Cache
- type CacheKeysFunc
- type CacheLister
- type ClientManager
- type Equality
- type EventSource
- type GlobalCacheLister
- type List
- type Lister
- type ListerWatcher
- type Manager
- type ManagerBuilder
- type NewClientFunc
- type NewPollerFunc
- type NewUnderlayClientFunc
- type Object
- type Poller
- type RefreshFunc
- type RefreshableCacheLister
- type Refresher
- type SharedInformerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResourceEventHandler ¶
func NewResourceEventHandler[O client.Object, R comparable]( ctx context.Context, h handler.TypedEventHandler[O, R], q workqueue.TypedRateLimitingInterface[R], ) cache.ResourceEventHandler
NewResourceEventHandler creates a ResourceEventHandler. See "sigs.k8s.io/controller-runtime/pkg/internal/source.NewEventHandler"
func PrimaryKey ¶
func SplitPrimaryKey ¶
Types ¶
type Cache ¶
type Cache[Client, UnderlayClient any] interface { Client() Client InformerFactory() SharedInformerFactory[UnderlayClient] Keys() []string Start(ctx context.Context) Stop() }
type CacheLister ¶
type ClientManager ¶
type EventSource ¶
type EventSource interface {
source.Source
For(key string, f cache.SharedIndexInformer) error
HasSynced(key string) bool
}
func NewEventSource ¶
func NewEventSource(h handler.EventHandler) EventSource
type GlobalCacheLister ¶
type GlobalCacheLister[T any, PT Object[T]] interface { ByCluster(cluster string) CacheLister[T, PT] }
func NewGlobalCacheLister ¶
func NewGlobalCacheLister[T any, PT Object[T]](indexer cache.Indexer, gr schema.GroupResource) GlobalCacheLister[T, PT]
type List ¶
List is a list of objects. NOTE: it's only for test now
func (*List[T, PT]) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterList.
func (*List[T, PT]) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*List[T, PT]) DeepCopyObject ¶
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type ListerWatcher ¶
type ListerWatcher[UnderlayClient any] interface { cache.ListerWatcher }
func NewListerWatcher ¶
func NewListerWatcher[UnderlayClient any]( logger logr.Logger, p Poller, ) ListerWatcher[UnderlayClient]
type ManagerBuilder ¶
type ManagerBuilder[Object client.Object, UnderlayClient, Client any] interface { WithLogger(logger logr.Logger) ManagerBuilder[Object, UnderlayClient, Client] WithCacheKeysFunc(f CacheKeysFunc[Object]) ManagerBuilder[Object, UnderlayClient, Client] WithNewUnderlayClientFunc(f NewUnderlayClientFunc[Object, UnderlayClient]) ManagerBuilder[Object, UnderlayClient, Client] WithNewClientFunc(f NewClientFunc[Object, UnderlayClient, Client]) ManagerBuilder[Object, UnderlayClient, Client] WithNewPollerFunc(obj runtime.Object, f NewPollerFunc[UnderlayClient]) ManagerBuilder[Object, UnderlayClient, Client] WithResyncPeriod(time.Duration) ManagerBuilder[Object, UnderlayClient, Client] Build() Manager[Object, Client] }
func NewManagerBuilder ¶
func NewManagerBuilder[Object client.Object, UnderlayClient, Client any]() ManagerBuilder[Object, UnderlayClient, Client]
type NewClientFunc ¶
type NewClientFunc[Object client.Object, UnderlayClient, Client any] func( Object, UnderlayClient, SharedInformerFactory[UnderlayClient]) Client
NewClientFunc is the func to new an external client with the cache layer, for example, timanager.PDClient
type NewPollerFunc ¶
type NewPollerFunc[UnderlayClient any] func(name string, logger logr.Logger, c UnderlayClient) Poller
NewPollerFunc is the function to new a poller by underlay client
type NewUnderlayClientFunc ¶
type NewUnderlayClientFunc[Object client.Object, UnderlayClient any] func(obj Object) (UnderlayClient, error)
NewUnderlayClientFunc is the func to new a underlay client, for example, pdapi.PDClient
type Poller ¶
type Poller interface {
// Sync will initialize the state of poller
// It will poll and make sure state is available
// Sync must be called before Run
Sync(ctx context.Context) (runtime.Object, error)
// IF Run is called multiple times, the previous one will be stopped
// immediately and start a new one to push event to new channel
Run(ctx context.Context, ch chan<- watch.Event)
// Refresh once immediately
Refresh()
}
Poller polls from tidb and sends watch event to channel
type RefreshFunc ¶
type RefreshFunc func()
func (RefreshFunc) Refresh ¶
func (f RefreshFunc) Refresh()
type RefreshableCacheLister ¶
type RefreshableCacheLister[T any, PT Object[T]] interface { CacheLister[T, PT] Refresher }
func CacheWithRefresher ¶
func CacheWithRefresher[T any, PT Object[T]](c CacheLister[T, PT], r Refresher) RefreshableCacheLister[T, PT]
type SharedInformerFactory ¶
type SharedInformerFactory[UnderlayClient any] interface { ForEach(func(t reflect.Type, informer cache.SharedIndexInformer) error) error Refresh(obj runtime.Object) }
SharedInformerFactory is modified from k8s.io/client-go/informers/factory.go to support poll from tidb clusters.