mirror of
https://github.com/hexolan/panels.git
synced 2026-03-26 12:40:21 +00:00
init post-service
This commit is contained in:
29
services/post-service/internal/redis/redis.go
Normal file
29
services/post-service/internal/redis/redis.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"time"
|
||||
"context"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/hexolan/panels/post-service/internal"
|
||||
)
|
||||
|
||||
func NewRedisInterface(ctx context.Context, cfg internal.Config) *redis.Client {
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: cfg.RedisHost,
|
||||
Password: cfg.RedisPass,
|
||||
DB: 0,
|
||||
|
||||
DialTimeout: time.Millisecond * 250,
|
||||
ReadTimeout: time.Millisecond * 500,
|
||||
})
|
||||
|
||||
_, err := rdb.Ping(ctx).Result()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("failed Redis ping")
|
||||
}
|
||||
|
||||
return rdb
|
||||
}
|
||||
Reference in New Issue
Block a user