Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use redis universal client instead of a concrete type #88

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions harvester.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type Builder struct {
monitorConsulCfg *consulConfig
err error
chNotify chan<- config.ChangeNotification
monitorRedisClient *redis.Client
seedRedisClient *redis.Client
monitorRedisClient redis.UniversalClient
seedRedisClient redis.UniversalClient
monitorRedisPollInterval time.Duration
}

Expand Down Expand Up @@ -114,7 +114,7 @@ func (b *Builder) WithConsulMonitor(addr, dataCenter, token string, timeout time
}

// WithRedisSeed enables support for seeding values with redis.
func (b *Builder) WithRedisSeed(client *redis.Client) *Builder {
func (b *Builder) WithRedisSeed(client redis.UniversalClient) *Builder {
if b.err != nil {
return b
}
Expand All @@ -128,7 +128,7 @@ func (b *Builder) WithRedisSeed(client *redis.Client) *Builder {

// WithRedisMonitor enables support for monitoring keys in Redis. It automatically parses the config
// and monitors every field found tagged with ConsulLogger.
func (b *Builder) WithRedisMonitor(client *redis.Client, pollInterval time.Duration) *Builder {
func (b *Builder) WithRedisMonitor(client redis.UniversalClient, pollInterval time.Duration) *Builder {
if b.err != nil {
return b
}
Expand Down
4 changes: 2 additions & 2 deletions harvester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TestCreateWithConsulAndRedis(t *testing.T) {
type args struct {
cfg interface{}
consulAddress string
seedRedisClient *redis.Client
monitorRedisClient *redis.Client
seedRedisClient redis.UniversalClient
monitorRedisClient redis.UniversalClient
monitoringPollInterval time.Duration
}
tests := map[string]struct {
Expand Down
4 changes: 2 additions & 2 deletions monitor/redis/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (

// Watcher of Redis changes.
type Watcher struct {
client *redis.Client
client redis.UniversalClient
keys []string
pollInterval time.Duration
}

// New watcher.
func New(client *redis.Client, pollInterval time.Duration, keys []string) (*Watcher, error) {
func New(client redis.UniversalClient, pollInterval time.Duration, keys []string) (*Watcher, error) {
if client == nil {
return nil, errors.New("client is nil")
}
Expand Down
4 changes: 2 additions & 2 deletions monitor/redis/watcher_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func TestWatch(t *testing.T) {
}
}

func set(t *testing.T, client *redis.Client, key string, val string) {
func set(t *testing.T, client redis.UniversalClient, key string, val string) {
getResult, err := client.Set(context.Background(), key, val, 0).Result()
require.NoError(t, err)
require.Equal(t, "OK", getResult)
}

func del(t *testing.T, client *redis.Client, key string) {
func del(t *testing.T, client redis.UniversalClient, key string) {
delResult, err := client.Del(context.Background(), key).Result()
require.NoError(t, err)
require.Equal(t, int64(1), delResult)
Expand Down
2 changes: 1 addition & 1 deletion monitor/redis/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func TestNew(t *testing.T) {
type args struct {
client *redis.Client
client redis.UniversalClient
pollInterval time.Duration
keys []string
}
Expand Down
4 changes: 2 additions & 2 deletions seed/redis/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

// Getter definition.
type Getter struct {
client *redis.Client
client redis.UniversalClient
}

// New creates a getter.
func New(client *redis.Client) (*Getter, error) {
func New(client redis.UniversalClient) (*Getter, error) {
if client == nil {
return nil, errors.New("client is nil")
}
Expand Down
2 changes: 1 addition & 1 deletion seed/redis/getter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func TestNew(t *testing.T) {
type args struct {
client *redis.Client
client redis.UniversalClient
}
tests := map[string]struct {
args args
Expand Down