2023-04-24 20:52:12 +02:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/setup"
|
|
|
|
"github.com/pkg/errors"
|
2024-03-26 17:28:38 +01:00
|
|
|
"github.com/redis/go-redis/v9"
|
2023-04-24 20:52:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) initRepositories(ctx context.Context) error {
|
2024-09-23 15:16:30 +02:00
|
|
|
client := setup.NewSharedClient(s.redisConfig)
|
2024-03-26 17:28:38 +01:00
|
|
|
|
|
|
|
if err := s.initProxyRepository(ctx, client); err != nil {
|
2023-04-24 20:52:12 +02:00
|
|
|
return errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
2024-03-26 17:28:38 +01:00
|
|
|
if err := s.initLayerRepository(ctx, client); err != nil {
|
2023-04-24 20:52:12 +02:00
|
|
|
return errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-03-26 17:28:38 +01:00
|
|
|
func (s *Server) initProxyRepository(ctx context.Context, client redis.UniversalClient) error {
|
|
|
|
proxyRepository, err := setup.NewProxyRepository(ctx, client)
|
2023-04-24 20:52:12 +02:00
|
|
|
if err != nil {
|
|
|
|
return errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.proxyRepository = proxyRepository
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-03-26 17:28:38 +01:00
|
|
|
func (s *Server) initLayerRepository(ctx context.Context, client redis.UniversalClient) error {
|
|
|
|
layerRepository, err := setup.NewLayerRepository(ctx, client)
|
2023-04-24 20:52:12 +02:00
|
|
|
if err != nil {
|
|
|
|
return errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.layerRepository = layerRepository
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|