From 1ea2f20df461506de405c0be185406dc53388597 Mon Sep 17 00:00:00 2001 From: Na'aman Hirschfeld Date: Tue, 28 Nov 2023 08:11:38 +0100 Subject: [PATCH] chore: fix dashboard main no calling ptesting init --- .../internal/ptestingclient/ptestingclient.go | 2 +- services/dashboard-backend/main.go | 3 +++ shared/go/rediscache/rediscache.go | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/services/dashboard-backend/internal/ptestingclient/ptestingclient.go b/services/dashboard-backend/internal/ptestingclient/ptestingclient.go index 82470a52..daebd5e1 100644 --- a/services/dashboard-backend/internal/ptestingclient/ptestingclient.go +++ b/services/dashboard-backend/internal/ptestingclient/ptestingclient.go @@ -56,7 +56,7 @@ func Init(ctx context.Context, opts ...grpc.DialOption) { } // StreamPromptTest - streams a prompt test to the PromptTesting gRPC service. -func (c *Client) StreamPromptTest( +func (c *Client) StreamPromptTest( //nolint: revive ctx context.Context, projectID string, applicationID string, diff --git a/services/dashboard-backend/main.go b/services/dashboard-backend/main.go index 0f5a3409..631fcde2 100644 --- a/services/dashboard-backend/main.go +++ b/services/dashboard-backend/main.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/basemind-ai/monorepo/services/dashboard-backend/internal/api" "github.com/basemind-ai/monorepo/services/dashboard-backend/internal/middleware" + "github.com/basemind-ai/monorepo/services/dashboard-backend/internal/ptestingclient" "github.com/basemind-ai/monorepo/shared/go/config" "github.com/basemind-ai/monorepo/shared/go/db" "github.com/basemind-ai/monorepo/shared/go/logging" @@ -44,6 +45,8 @@ func main() { log.Fatal().Err(connErr).Msg("failed to connect to DB") } + ptestingclient.Init(ctx) + defer conn.Close() mux := router.New(router.Options{ diff --git a/shared/go/rediscache/rediscache.go b/shared/go/rediscache/rediscache.go index c47ee8be..097965ed 100644 --- a/shared/go/rediscache/rediscache.go +++ b/shared/go/rediscache/rediscache.go @@ -6,6 +6,7 @@ import ( "github.com/basemind-ai/monorepo/shared/go/exc" "github.com/go-redis/cache/v9" "github.com/redis/go-redis/v9" + "github.com/rs/zerolog/log" "os" "sync" "time" @@ -26,8 +27,14 @@ func SetClient(c *cache.Cache) { func New(redisURL string) *cache.Cache { once.Do(func() { opt := exc.MustResult(redis.ParseURL(redisURL)) - opt.ClientName = os.Getenv("SERVICE_NAME") + opt.OnConnect = func(ctx context.Context, cn *redis.Conn) error { + if err := cn.Ping(ctx).Err(); err != nil { + log.Fatal().Err(err).Msg("failed to ping redis") + } + log.Info().Msg("connected to redis") + return nil + } SetClient(cache.New(&cache.Options{ Redis: redis.NewClient(opt), LocalCache: cache.NewTinyLFU(1000, time.Minute),