Documentation ¶
Index ¶
- func NewResource[T k8sRuntime.Object](rootCtx context.Context, lw cache.ListerWatcher) (src stream.Observable[Event[T]], run func())
- func NewResourceFromClient[T k8sRuntime.Object](ctx context.Context, resource string, namespace string, client rest.Interface) (src stream.Observable[Event[T]], run func())
- func NewResourceFromListWatch[ObjT k8sRuntime.Object, ListT k8sRuntime.Object](ctx context.Context, lw TypedListerWatcher[ListT]) (src stream.Observable[Event[ObjT]], run func())
- type DeleteEvent
- type Event
- type Key
- type SyncEvent
- type TypedListerWatcher
- type UpdateEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResource ¶
func NewResource[T k8sRuntime.Object](rootCtx context.Context, lw cache.ListerWatcher) (src stream.Observable[Event[T]], run func())
NewResource creates a stream of events from a ListerWatcher. The initial set of objects is emitted first as UpdateEvents, followed by a SyncEvent, after which updates follow. Returns the observable and the function to run the resource.
func NewResourceFromClient ¶
func NewResourceFromClient[T k8sRuntime.Object]( ctx context.Context, resource string, namespace string, client rest.Interface, ) (src stream.Observable[Event[T]], run func())
NewResourceFromClient creates a stream of events from a k8s REST client for the given resource and namespace.
func NewResourceFromListWatch ¶
func NewResourceFromListWatch[ObjT k8sRuntime.Object, ListT k8sRuntime.Object](ctx context.Context, lw TypedListerWatcher[ListT]) (src stream.Observable[Event[ObjT]], run func())
NewResourceFromListWatch creates a stream of events from the typed client, e.g. (kubernetes.Interface).Pods() etc.
Types ¶
type DeleteEvent ¶
type DeleteEvent[T k8sRuntime.Object] struct { Key Key }
DeleteEvent is emitted when an object has been deleted
func (*DeleteEvent[T]) Dispatch ¶
func (ev *DeleteEvent[T]) Dispatch(onSync func(), onUpdate func(Key, T), onDelete func(Key))
type Event ¶
type Event[T k8sRuntime.Object] interface { // Dispatch dispatches to the right event handler. Prefer this over // type switch on event. Dispatch( onSync func(), onUpdate func(Key, T), onDelete func(Key), ) // contains filtered or unexported methods }
Event emitted from resource. One of SyncEvent, UpdateEvent or DeleteEvent.
type Key ¶
type Key struct { // Name is the name of the object Name string // Namespace is the namespace, or empty if object is not namespaced. Namespace string }
Key of an K8s object, e.g. name and optional namespace.
type SyncEvent ¶
type SyncEvent[T k8sRuntime.Object] struct{}
SyncEvent is emitted when the store has completed the initial synchronization with the cluster.
type TypedListerWatcher ¶
type TypedListerWatcher[ListT k8sRuntime.Object] interface { List(context.Context, metav1.ListOptions) (ListT, error) Watch(context.Context, metav1.ListOptions) (watch.Interface, error) }
TypedListerWatcher is the interface implemented by the generated clients.
type UpdateEvent ¶
type UpdateEvent[T k8sRuntime.Object] struct { Key Key Object T }
UpdateEvent is emitted when an object has been added or updated
func (*UpdateEvent[T]) Dispatch ¶
func (ev *UpdateEvent[T]) Dispatch(onSync func(), onUpdate func(Key, T), onDelete func(Key))