2023-04-24 20:52:12 +02:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/config"
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
|
|
|
redisStore "forge.cadoles.com/cadoles/bouncer/internal/store/redis"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
|
|
)
|
|
|
|
|
2024-03-26 17:28:38 +01:00
|
|
|
func NewRedisClient(ctx context.Context, conf config.RedisConfig) redis.UniversalClient {
|
|
|
|
return redis.NewUniversalClient(&redis.UniversalOptions{
|
2023-04-24 20:52:12 +02:00
|
|
|
Addrs: conf.Adresses,
|
|
|
|
MasterName: string(conf.Master),
|
|
|
|
})
|
2024-03-26 17:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewProxyRepository(ctx context.Context, client redis.UniversalClient) (store.ProxyRepository, error) {
|
2024-06-27 17:03:50 +02:00
|
|
|
return redisStore.NewProxyRepository(client, redisStore.DefaultTxMaxAttempts, redisStore.DefaultTxBaseDelay), nil
|
2024-03-26 17:28:38 +01:00
|
|
|
}
|
2023-04-24 20:52:12 +02:00
|
|
|
|
2024-03-26 17:28:38 +01:00
|
|
|
func NewLayerRepository(ctx context.Context, client redis.UniversalClient) (store.LayerRepository, error) {
|
2024-06-27 17:03:50 +02:00
|
|
|
return redisStore.NewLayerRepository(client, redisStore.DefaultTxMaxAttempts, redisStore.DefaultTxBaseDelay), nil
|
2023-04-24 20:52:12 +02:00
|
|
|
}
|