Make RedisConnectionConfigBuilder abstract
and also use custom ConfigException instead of generic one.
This commit is contained in:
+7
-2
@@ -1,3 +1,6 @@
|
|||||||
|
from cartodb_services.refactor.config.exceptions import ConfigException
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
"""
|
"""
|
||||||
How to use this (just a draft, WIP):
|
How to use this (just a draft, WIP):
|
||||||
|
|
||||||
@@ -43,12 +46,14 @@ class RedisConnectionConfig(object):
|
|||||||
return self._sentinel_id
|
return self._sentinel_id
|
||||||
|
|
||||||
|
|
||||||
# TODO make it abstract
|
|
||||||
class RedisConnectionConfigBuilder(object):
|
class RedisConnectionConfigBuilder(object):
|
||||||
|
|
||||||
|
__metaclass__ = ABCMeta
|
||||||
|
|
||||||
DEFAULT_USER_DB = 5
|
DEFAULT_USER_DB = 5
|
||||||
DEFAULT_TIMEOUT = 1.5 # seconds
|
DEFAULT_TIMEOUT = 1.5 # seconds
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
def __init__(self, server_config_storage, config_key):
|
def __init__(self, server_config_storage, config_key):
|
||||||
self._server_config_storage = server_config_storage
|
self._server_config_storage = server_config_storage
|
||||||
self._config_key = config_key
|
self._config_key = config_key
|
||||||
@@ -56,7 +61,7 @@ class RedisConnectionConfigBuilder(object):
|
|||||||
def get(self):
|
def get(self):
|
||||||
conf = self._server_config_storage.get(self._config_key)
|
conf = self._server_config_storage.get(self._config_key)
|
||||||
if conf is None:
|
if conf is None:
|
||||||
raise Exception("There is no redis configuration defined")
|
raise ConfigException("There is no redis configuration defined")
|
||||||
|
|
||||||
host = conf['redis_host']
|
host = conf['redis_host']
|
||||||
port = conf['redis_port']
|
port = conf['redis_port']
|
||||||
|
|||||||
Reference in New Issue
Block a user