Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(maestro): update cache with creation of yaml. #2169

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions maestro/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package maestro
import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/go-redis/redis/v8"
Expand Down Expand Up @@ -93,6 +94,11 @@ func (svc *maestroService) Start(ctx context.Context, cancelFunction context.Can
svc.logger.Warn("failed to create deploymentEntry for sink, skipping", zap.String("sink-id", sinkRes.Id))
continue
}
err = svc.updateSinkCache(ctx, data)
if err != nil {
svc.logger.Warn("failed to update cache for sink", zap.String("sink-id", sinkRes.Id))
continue
}
svc.logger.Info("successfully created deploymentEntry for sink", zap.String("sink-id", sinkRes.Id), zap.String("state", sinkRes.State))
}

Expand Down Expand Up @@ -135,6 +141,23 @@ func (svc *maestroService) Start(ctx context.Context, cancelFunction context.Can
return nil
}

func (svc *maestroService) updateSinkCache(ctx context.Context, data maestroconfig.SinkData) (err error) {
data.State = maestroconfig.Unknown
keyPrefix := "sinker_key"
skey := fmt.Sprintf("%s-%s:%s", keyPrefix, data.OwnerID, data.SinkID)
bytes, err := json.Marshal(data)
if err != nil {
return err
}
if err = svc.sinkerRedisClient.Set(ctx, skey, bytes, 0).Err(); err != nil {
return err
}
if err != nil {
return err
}
return
}

func (svc *maestroService) subscribeToSinkerES(ctx context.Context) {
if err := svc.eventStore.SubscribeSinker(ctx); err != nil {
svc.logger.Error("Bootstrap service failed to subscribe to event sourcing sinker", zap.Error(err))
Expand Down