Skip to content

Commit

Permalink
chore: fix dashboard main no calling ptesting init
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Nov 28, 2023
1 parent 41bf8ae commit 1ea2f20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions services/dashboard-backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down
9 changes: 8 additions & 1 deletion shared/go/rediscache/rediscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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),
Expand Down

0 comments on commit 1ea2f20

Please sign in to comment.