Default to the ckan.redis.url setting

99.9% of cases you probably want to use the same redis instance that
CKAN core uses so it makes sense to default to that setting. If it's not
set if will default to the hardcoded values (localhost:6379/0) which is
the same default as CKAN core. If there is an existing legacy setting
(ckan.harvest.mq.hostname) those will be used.
This commit is contained in:
amercader 2019-08-23 13:34:17 +02:00
parent b8cf47bb91
commit b1b284a810
1 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,8 @@ import logging
import datetime
import json
import redis
import pika
import sqlalchemy
@ -64,11 +66,13 @@ def get_connection_amqp():
def get_connection_redis():
import redis
return redis.StrictRedis(host=config.get('ckan.harvest.mq.hostname', HOSTNAME),
port=int(config.get('ckan.harvest.mq.port', REDIS_PORT)),
password=config.get('ckan.harvest.mq.password', None),
db=int(config.get('ckan.harvest.mq.redis_db', REDIS_DB)))
if not config.get('ckan.harvest.mq.hostname') and config.get('ckan.redis.url'):
return redis.Redis.from_url(config['ckan.redis.url'])
else:
return redis.Redis(host=config.get('ckan.harvest.mq.hostname', HOSTNAME),
port=int(config.get('ckan.harvest.mq.port', REDIS_PORT)),
password=config.get('ckan.harvest.mq.password', None),
db=int(config.get('ckan.harvest.mq.redis_db', REDIS_DB)))
def get_gather_queue_name():