Merge pull request #138 from creekorful/137-allow-password-redis

Allow to customize redis password
pull/139/head
Aloïs Micard 3 years ago committed by GitHub
commit 4571208565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,11 +13,12 @@ type redisCache struct {
}
// NewRedisCache return a new Cache using redis as backend
func NewRedisCache(URI string, keyPrefix string) (Cache, error) {
func NewRedisCache(URI string, password, keyPrefix string) (Cache, error) {
return &redisCache{
client: redis.NewClient(&redis.Options{
Addr: URI,
DB: 0,
Addr: URI,
Password: password,
DB: 0,
}),
keyPrefix: keyPrefix,
}, nil

@ -44,6 +44,7 @@ const (
eventURIFlag = "event-srv"
configAPIURIFlag = "config-api"
redisURIFlag = "redis"
redisPassFlag = "redis-pass"
torURIFlag = "tor-proxy"
userAgentFlag = "user-agent"
)
@ -101,7 +102,7 @@ func (p *defaultProvider) Publisher() (event.Publisher, error) {
}
func (p *defaultProvider) Cache(keyPrefix string) (cache.Cache, error) {
return cache.NewRedisCache(p.ctx.String(redisURIFlag), keyPrefix)
return cache.NewRedisCache(p.ctx.String(redisURIFlag), p.ctx.String(redisPassFlag), keyPrefix)
}
func (p *defaultProvider) HTTPClient() (chttp.Client, error) {
@ -287,6 +288,10 @@ func getFeaturesFlags() map[Feature][]cli.Flag {
Usage: "URI to the Redis server",
Required: true,
},
&cli.StringFlag{
Name: redisPassFlag,
Usage: "Redis server password",
},
}
flags[CrawlingFeature] = []cli.Flag{

Loading…
Cancel
Save