You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: event_watcher.go
    path of file: ./repos/flyte/flytepropeller/pkg/controller/nodes/task/k8s
    
    the code of the file until where you have to start completion: package k8s

import (
	"context"
	"fmt"
	"sort"
	"sync"
	"time"

	eventsv1 "k8s.io/api/events/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/fields"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/client-go/informers"
	informerEventsv1 "k8s.io/client-go/informers/events/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/cache"

	"github.com/flyteorg/flyte/flytestdlib/logger"
)

type EventWatcher interface {
	List(objectNsName types.NamespacedName, createdAfter time.Time) []*EventInfo
}

    
func NewEventWatcher(ctx context.Context, gvk schema.GroupVersionKind, kubeClientset kubernetes.Interface) (EventWatcher, error) {
	objectSelector := func(opts *metav1.ListOptions) {
		opts.FieldSelector = fields.OneTermEqualSelector("regarding.kind", gvk.Kind).String()
	}
	eventInformer := informers.NewSharedInformerFactoryWithOptions(
		kubeClientset, 0, informers.WithTweakListOptions(objectSelector)).Events().V1().Events()
	watcher := &eventWatcher{
		informer: eventInformer,
	}

	_, err := eventInformer.Informer().AddEventHandler(watcher)
	if err != nil {
		return nil, fmt.Errorf("failed to add event handler: %w", err)
	}

	go eventInformer.Informer().Run(ctx.Done())
	logger.Debugf(ctx, "Started informer for [%s] events", gvk.Kind)

	return watcher, nil
}