Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventParameters ¶
type EventParameters struct { v1alpha1.WatchRequest Type pb.EventType ClusterName string Object *unstructured.Unstructured TimeStamp time.Time }
EventParameters is used to send the event related info to GRPCClient
type GRPCClient ¶
type GRPCClient interface { SendEvent(ctx context.Context, params EventParameters) (pb.ResponseType, error) GetServerParams() (addr, port string) }
GRPCClient sends events to the edgewatcher server
type Params ¶
type Params struct { v1alpha1.WatchRequest // InvokeWatcherAgentController is provided by watcheragent controller to // invoke the controller's Reconcile(https://pkgo.dev/sigs.k8s.io/controller-runtime/pkg/reconcile#Func.Reconcile) // func with the correct request (https://pkgo.dev/sigs.k8s.io/controller-runtime/pkg/reconcile#Request). // This is needed for notifying the controller to update the resourceVersion // of a watch in the v1alpha1.WatcherAgentStatus. InvokeWatcherAgentController func() Clock clock.Clock ResourceInterface dynamic.ResourceInterface ClusterName string }
Params is used to initialize Watcher
type Watcher ¶
type Watcher struct { Cancel context.CancelFunc *Params // ResourceVersionCh carries the most recent resourceVersion from // cache.Reflector for a one time read by watcheragent controller ResourceVersionCh chan string // contains filtered or unexported fields }
Watcher watches the k8s resources using cache.Reflector(https://pkgo.dev/k8s.io/client-go/tools/cache#Reflector). It creates a watcherStore (which implements cache.Store[https://pkgo.dev/k8s.io/client-go/tools/cache#Store]), which is passed on to cache.Reflector. watcherStore then sends the events provided by cache.Reflector to the GRPCClient. It also sends the current resourceVersion to the watcheragent controller. It first puts the new resourceVersion in the ResourceVersionCh (replacing the old one if present), then it invokes the controller's Reconcile func with the correct ctrl.Request(https://pkgo.dev/sigs.k8s.io/controller-runtime/pkg/reconcile#Request) using the Params.InvokeWatcherAgentController func.
func (*Watcher) GetGRPCClient ¶
func (w *Watcher) GetGRPCClient() GRPCClient
func (*Watcher) GetRestartCount ¶
func (*Watcher) Run ¶
func (w *Watcher) Run()
Run creates a new cache.Reflector and watcherStore and sets them to watch the given resources. It recreates the reflector whenever an error is received since reflector doesn't provide method to forcefully re-list.
func (*Watcher) SetGRPCClient ¶
func (w *Watcher) SetGRPCClient(client GRPCClient)