perf: remove lc dependency
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
||||
"flink-kube-operator/internal/crd/v1alpha1"
|
||||
"fmt"
|
||||
|
||||
"gitea.com/logicamp/lc"
|
||||
"flink-kube-operator/pkg"
|
||||
|
||||
"github.com/reactivex/rxgo/v2"
|
||||
"go.uber.org/zap"
|
||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -19,25 +20,25 @@ func (crd Crd) watchFlinkJobs() rxgo.Observable {
|
||||
ch := make(chan rxgo.Item)
|
||||
|
||||
go func() {
|
||||
lc.Logger.Debug("[crd] starting watch")
|
||||
pkg.Logger.Debug("[crd] starting watch")
|
||||
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer watcher.Stop()
|
||||
for event := range watcher.ResultChan() {
|
||||
lc.Logger.Debug("[crd] event received", zap.Any("type", event.Type))
|
||||
pkg.Logger.Debug("[crd] event received", zap.Any("type", event.Type))
|
||||
unstructuredJob := event.Object.(*unstructured.Unstructured)
|
||||
unstructuredMap, _, err := unstructured.NestedMap(unstructuredJob.Object)
|
||||
if err != nil {
|
||||
lc.Logger.Error("cannot create unstructured map", zap.Error(err))
|
||||
pkg.Logger.Error("cannot create unstructured map", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
job := &v1alpha1.FlinkJob{}
|
||||
|
||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredMap, job)
|
||||
if err != nil {
|
||||
lc.Logger.Error("cannot convert unstructured to structured", zap.Error(err))
|
||||
pkg.Logger.Error("cannot convert unstructured to structured", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -50,11 +51,11 @@ func (crd Crd) watchFlinkJobs() rxgo.Observable {
|
||||
switch event.Type {
|
||||
case watch.Bookmark:
|
||||
case watch.Modified:
|
||||
lc.Logger.Info("[crd] [watch] flink job updated")
|
||||
pkg.Logger.Info("[crd] [watch] flink job updated")
|
||||
fmt.Printf("FlinkJob updated: %s\n", job.GetName())
|
||||
crd.repsert(job)
|
||||
case watch.Added:
|
||||
lc.Logger.Info("[crd] [watch] new flink job created")
|
||||
pkg.Logger.Info("[crd] [watch] new flink job created")
|
||||
crd.repsert(job)
|
||||
case watch.Deleted:
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user