Green/Blue deploy system for the observatory functions
This commit is contained in:
@@ -14,9 +14,10 @@ class ServiceConfig(object):
|
||||
self._redis_connection = redis_connection
|
||||
self._username = username
|
||||
self._orgname = orgname
|
||||
self._db_config = ServicesDBConfig(db_conn)
|
||||
self._db_config = ServicesDBConfig(db_conn, username, orgname)
|
||||
if redis_connection:
|
||||
self._redis_config = ServicesRedisConfig(redis_connection).build(username, orgname)
|
||||
self._redis_config = ServicesRedisConfig(redis_connection).build(
|
||||
username, orgname)
|
||||
else:
|
||||
self._redis_config = None
|
||||
|
||||
@@ -53,6 +54,7 @@ class ObservatorySnapshotConfig(ServiceConfig):
|
||||
self._monthly_quota = float(self._redis_config[self.QUOTA_KEY])
|
||||
else:
|
||||
self._monthly_quota = float(self._db_config.data_observatory_monthly_quota)
|
||||
self._connection_str = self._db_config.data_observatory_connection_str
|
||||
|
||||
@property
|
||||
def service_type(self):
|
||||
@@ -70,6 +72,9 @@ class ObservatorySnapshotConfig(ServiceConfig):
|
||||
def soft_limit(self):
|
||||
return self._soft_limit
|
||||
|
||||
@property
|
||||
def connection_str(self):
|
||||
return self._connection_str
|
||||
|
||||
class RoutingConfig(ServiceConfig):
|
||||
|
||||
@@ -323,8 +328,10 @@ class GeocoderConfig(ServiceConfig):
|
||||
|
||||
class ServicesDBConfig:
|
||||
|
||||
def __init__(self, db_conn):
|
||||
def __init__(self, db_conn, username, orgname):
|
||||
self._db_conn = db_conn
|
||||
self._username = username
|
||||
self._orgname = orgname
|
||||
return self._build()
|
||||
|
||||
def _build(self):
|
||||
@@ -364,6 +371,12 @@ class ServicesDBConfig:
|
||||
else:
|
||||
do_conf = json.loads(do_conf_json)
|
||||
self._data_observatory_monthly_quota = do_conf['monthly_quota']
|
||||
if self._orgname and self._orgname in do_conf['connection']['whitelist']:
|
||||
self._data_observatory_connection_str = do_conf['connection']['staging']
|
||||
elif self._username in do_conf['connection']['whitelist']:
|
||||
self._data_observatory_connection_str = do_conf['connection']['staging']
|
||||
else:
|
||||
self._data_observatory_connection_str = do_conf['connection']['production']
|
||||
|
||||
def _get_logger_config(self):
|
||||
logger_conf_json = self._get_conf('logger_conf')
|
||||
@@ -425,6 +438,10 @@ class ServicesDBConfig:
|
||||
def data_observatory_monthly_quota(self):
|
||||
return self._data_observatory_monthly_quota
|
||||
|
||||
@property
|
||||
def data_observatory_connection_str(self):
|
||||
return self._data_observatory_connection_str
|
||||
|
||||
|
||||
class ServicesRedisConfig:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
||||
setup(
|
||||
name='cartodb_services',
|
||||
|
||||
version='0.5.1',
|
||||
version='0.5.2',
|
||||
|
||||
description='CartoDB Services API Python Library',
|
||||
|
||||
|
||||
@@ -61,4 +61,4 @@ def _plpy_execute_side_effect(*args, **kwargs):
|
||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('logger_conf') as conf":
|
||||
return [{'conf': '{"geocoder_log_path": "/dev/null"}'}]
|
||||
elif args[0] == "SELECT cartodb.CDB_Conf_GetConf('data_observatory_conf') as conf":
|
||||
return [{'conf': '{"monthly_quota": 100000}'}]
|
||||
return [{'conf': '{"connection": {"whitelist": ["ethervoid"], "production": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api", "staging": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api"}, "monthly_quota": 100000}'}]
|
||||
|
||||
Reference in New Issue
Block a user