bouncer/internal/proxy/init.go
William Petit f37425018b
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
feat: use shared redis client to maximize pooling usage (#39)
2024-09-23 15:16:30 +02:00

46 lines
992 B
Go

package proxy
import (
"context"
"forge.cadoles.com/cadoles/bouncer/internal/setup"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
)
func (s *Server) initRepositories(ctx context.Context) error {
client := setup.NewSharedClient(s.redisConfig)
if err := s.initProxyRepository(ctx, client); err != nil {
return errors.WithStack(err)
}
if err := s.initLayerRepository(ctx, client); err != nil {
return errors.WithStack(err)
}
return nil
}
func (s *Server) initProxyRepository(ctx context.Context, client redis.UniversalClient) error {
proxyRepository, err := setup.NewProxyRepository(ctx, client)
if err != nil {
return errors.WithStack(err)
}
s.proxyRepository = proxyRepository
return nil
}
func (s *Server) initLayerRepository(ctx context.Context, client redis.UniversalClient) error {
layerRepository, err := setup.NewLayerRepository(ctx, client)
if err != nil {
return errors.WithStack(err)
}
s.layerRepository = layerRepository
return nil
}