bouncer/internal/admin/init.go

55 lines
1.1 KiB
Go
Raw Permalink Normal View History

2023-04-24 20:52:12 +02:00
package admin
import (
"context"
"forge.cadoles.com/cadoles/bouncer/internal/setup"
"github.com/pkg/errors"
)
func (s *Server) initRepositories(ctx context.Context) error {
if err := s.initRedisClient(ctx); err != nil {
return errors.WithStack(err)
}
2023-04-24 20:52:12 +02:00
if err := s.initLayerRepository(ctx); err != nil {
return errors.WithStack(err)
}
if err := s.initProxyRepository(ctx); err != nil {
return errors.WithStack(err)
}
return nil
}
func (s *Server) initRedisClient(ctx context.Context) error {
client := setup.NewRedisClient(ctx, s.redisConfig)
s.redisClient = client
return nil
}
2023-04-24 20:52:12 +02:00
func (s *Server) initLayerRepository(ctx context.Context) error {
layerRepository, err := setup.NewLayerRepository(ctx, s.redisClient)
2023-04-24 20:52:12 +02:00
if err != nil {
return errors.WithStack(err)
}
s.layerRepository = layerRepository
return nil
}
func (s *Server) initProxyRepository(ctx context.Context) error {
proxyRepository, err := setup.NewProxyRepository(ctx, s.redisClient)
2023-04-24 20:52:12 +02:00
if err != nil {
return errors.WithStack(err)
}
s.proxyRepository = proxyRepository
return nil
}