Add a RedisMetricsConnectionFactory class
This commit is contained in:
parent
1aec541906
commit
fcca5da302
@ -145,13 +145,11 @@ RETURNS Geometry AS $$
|
||||
from cartodb_services.tools import Logger
|
||||
from cartodb_services.refactor.storage.server_config import InDbServerConfigStorage
|
||||
from cartodb_services.refactor.tools.logger import LoggerConfigBuilder
|
||||
from cartodb_services.refactor.tools.redis_mock import RedisConnectionMock
|
||||
from cartodb_services.refactor.storage.redis_connection_config import RedisMetricsConnectionConfigBuilder
|
||||
from cartodb_services.refactor.storage.redis_connection import RedisConnectionBuilder
|
||||
from cartodb_services.refactor.service.mapzen_geocoder_config import MapzenGeocoderConfigBuilder
|
||||
from cartodb_services.refactor.core.environment import ServerEnvironmentBuilder
|
||||
from cartodb_services.refactor.backend.user_config import UserConfigBackendFactory
|
||||
from cartodb_services.refactor.backend.org_config import OrgConfigBackendFactory
|
||||
from cartodb_services.refactor.backend.redis_metrics_connection import RedisMetricsConnectionFactory
|
||||
|
||||
server_config_storage = InDbServerConfigStorage()
|
||||
|
||||
@ -164,12 +162,7 @@ RETURNS Geometry AS $$
|
||||
|
||||
mapzen_geocoder_config = MapzenGeocoderConfigBuilder(server_config_storage, user_config_backend, org_config_backend, username, orgname).get()
|
||||
|
||||
# TODO encapsulate the connection creation
|
||||
if environment.is_onpremise:
|
||||
redis_metrics_connection = RedisConnectionMock()
|
||||
else:
|
||||
redis_metrics_connection_config = RedisMetricsConnectionConfigBuilder(server_config_storage).get()
|
||||
redis_metrics_connection = RedisConnectionBuilder(redis_metrics_connection_config).get()
|
||||
redis_metrics_connection = RedisMetricsConnectionFactory(environment, server_config_storage).get()
|
||||
|
||||
quota_service = QuotaService(mapzen_geocoder_config, redis_metrics_connection)
|
||||
if not quota_service.check_user_quota():
|
||||
|
@ -0,0 +1,17 @@
|
||||
from cartodb_services.refactor.tools.redis_mock import RedisConnectionMock
|
||||
from cartodb_services.refactor.storage.redis_connection_config import RedisMetricsConnectionConfigBuilder
|
||||
from cartodb_services.refactor.storage.redis_connection import RedisConnectionBuilder
|
||||
|
||||
class RedisMetricsConnectionFactory(object):
|
||||
def __init__(self, environment, server_config_storage):
|
||||
self._environment = environment
|
||||
self._server_config_storage = server_config_storage
|
||||
|
||||
def get(self):
|
||||
if self._environment.is_onpremise:
|
||||
redis_metrics_connection = RedisConnectionMock()
|
||||
else:
|
||||
redis_metrics_connection_config = RedisMetricsConnectionConfigBuilder(self._server_config_storage).get()
|
||||
redis_metrics_connection = RedisConnectionBuilder(redis_metrics_connection_config).get()
|
||||
return redis_metrics_connection
|
||||
|
Loading…
Reference in New Issue
Block a user