func (b *Builder) WithRedisMonitor(client redis.UniversalClient, pollInterval time.Duration) *Builder {
	if b.err != nil {
		return b
	}
	if client == nil {
		b.err = errors.New("redis monitor client is nil")
		return b
	}
	if pollInterval <= 0 {
		b.err = errors.New("redis monitor poll interval should be a positive number")
		return b
	}
	b.monitorRedisClient = client
	b.monitorRedisPollInterval = pollInterval
	return b
}
WithRedisMonitor enables support for monitoring keys in Redis. It automatically parses the config
and monitors every field found tagged with ConsulLogger.
package harvester
import (
	"context"
	"errors"
	"time"
	"github.com/beatlabs/harvester/config"
	"github.com/beatlabs/harvester/log"
	"github.com/beatlabs/harvester/monitor"
	"github.com/beatlabs/harvester/monitor/consul"
	redismon "github.com/beatlabs/harvester/monitor/redis"
	"github.com/beatlabs/harvester/seed"
	seedconsul "github.com/beatlabs/harvester/seed/consul"
	seedredis "github.com/beatlabs/harvester/seed/redis"
	"github.com/go-redis/redis/v8"
)
type Seeder interface {
	Seed(cfg *config.Config) error
}
type Monitor interface {
	Monitor(ctx context.Context) error
}
type Harvester interface {
	Harvest(ctx context.Context) error
}
type harvester struct {
	cfg     *config.Config
	seeder  Seeder
	monitor Monitor
}
func (h *harvester) Harvest(ctx context.Context) error {
	err := h.seeder.Seed(h.cfg)
	if err != nil {
		return err
	}
	if h.monitor == nil {
		return nil
	}
	return h.monitor.Monitor(ctx)
}
type consulConfig struct {
	addr, dataCenter, token, folderPrefix string
	timeout                               time.Duration
}
type Builder struct {
	cfg                      interface{}
	seedConsulCfg            *consulConfig
	monitorConsulCfg         *consulConfig
	err                      error
	chNotify                 chan<- config.ChangeNotification
	monitorRedisClient       redis.UniversalClient
	seedRedisClient          redis.UniversalClient
	monitorRedisPollInterval time.Duration
}
func New(cfg interface{}) *Builder {
	return &Builder{cfg: cfg}
}
func (b *Builder) WithNotification(chNotify chan<- config.ChangeNotification) *Builder {
	if b.err != nil {
		return b
	}
	if chNotify == nil {
		b.err = errors.New("notification channel is nil")
		return b
	}
	b.chNotify = chNotify
	return b
}
func (b *Builder) WithConsulSeed(addr, dataCenter, token string, timeout time.Duration) *Builder {
	if b.err != nil {
		return b
	}
	b.seedConsulCfg = &consulConfig{
		addr:       addr,
		dataCenter: dataCenter,
		token:      token,
		timeout:    timeout,
	}
	return b
}
func (b *Builder) WithConsulMonitor(addr, dataCenter, token string, timeout time.Duration) *Builder {
	return b.WithConsulFolderPrefixMonitor(addr, dataCenter, token, "", timeout)
}
func (b *Builder) WithConsulFolderPrefixMonitor(addr, dataCenter, token, folderPrefix string, timeout time.Duration) *Builder {
	if b.err != nil {
		return b
	}
	b.monitorConsulCfg = &consulConfig{
		addr:         addr,
		dataCenter:   dataCenter,
		token:        token,
		folderPrefix: folderPrefix,
		timeout:      timeout,
	}
	return b
}
func (b *Builder) WithRedisSeed(client redis.UniversalClient) *Builder {
	if b.err != nil {
		return b
	}
	if client == nil {
		b.err = errors.New("redis seed client is nil")
		return b
	}
	b.seedRedisClient = client
	return b
}