def setUp(self): # SentinelConnectionPool needs SENTINEL_SERVICE_NAME as mandatory connection parameter self.cf = pool.get_connection_factory( options={"SENTINEL_SERVICE_NAME": "rmaster"}) self.constring4 = "unix://tmp/foo.bar?db=1" self.constring5 = "redis://localhost/2" self.constring6 = "rediss://localhost:3333?db=2"
def setUp(self): # SentinelConnectionPool needs SENTINEL_SERVICE_NAME as mandatory connection parameter self.cf = pool.get_connection_factory( options={'SENTINEL_SERVICE_NAME': 'rmaster'}) self.constring4 = 'unix://tmp/foo.bar?db=1' self.constring5 = 'redis://localhost/2' self.constring6 = 'rediss://localhost:3333?db=2'
def __init__(self, server, params, backend): self._backend = backend self._server = server self._params = params self.reverse_key = get_key_func( params.get("REVERSE_KEY_FUNCTION") or "django_redis.util.default_reverse_key") self._options = params.get("OPTIONS", {}) if self._options.get('USE_CONSUL', False) and consulate is not None: sentinel_port = self._options.get('SENTINEL_PORT', '26379') consul = consulate.Consul( host=self._options.get('CONSUL_IP_ADDR', 'localhost')) self._server = [(node['Address'], sentinel_port) for node in consul.catalog.nodes() if node['Meta'].get('consul_role') == 'server'] if not self._server: raise ImproperlyConfigured("Missing connections string") if not isinstance(self._server, (list, tuple, set)): self._server = self._server.split(",") # In Redis Sentinel (not Redis Cluster) all slaves in read-only mode self._slave_read_only = True serializer_path = self._options.get( "SERIALIZER", "django_redis.serializers.pickle.PickleSerializer") serializer_cls = load_class(serializer_path) compressor_path = self._options.get( "COMPRESSOR", "django_redis.compressors.identity.IdentityCompressor") compressor_cls = load_class(compressor_path) self._serializer = serializer_cls(options=self._options) self._compressor = compressor_cls(options=self._options) # Hack: Add sentinels servers as options, to break legacy pool code as less as possible self._options.update({"SENTINELS": self._server}) # Create connection factory for Sentinels self.connection_factory = pool.get_connection_factory( options=self._options)
def __init__(self, server, params, backend): super(SentinelClient, self).__init__(server, params, backend) self._backend = backend self._server = server self._params = params self.reverse_key = get_key_func( params.get('REVERSE_KEY_FUNCTION') or 'django_redis.util.default_reverse_key', ) if not self._server: raise ImproperlyConfigured('Missing connections string') if not isinstance(self._server, (list, tuple, set)): self._server = self._server.split(',') self._options = params.get('OPTIONS', {}) serializer_path = self._options.get( 'SERIALIZER', 'django_redis.serializers.pickle.PickleSerializer', ) serializer_cls = import_string(serializer_path) compressor_path = self._options.get( 'COMPRESSOR', 'django_redis.compressors.identity.IdentityCompressor', ) compressor_cls = import_string(compressor_path) self._serializer = serializer_cls(options=self._options) self._compressor = compressor_cls(options=self._options) # Hack: Add sentinels servers as options, to break legacy pool code as less as possible self._options.update({'SENTINELS': self._server}) # Create connection factory for Sentinels self.connection_factory = pool.get_connection_factory( options=self._options)
def __init__(self, server, params, backend): super(SentinelClient, self).__init__(server, params, backend) self._backend = backend self._server = server self._params = params self.reverse_key = get_key_func( params.get("REVERSE_KEY_FUNCTION") or "django_redis.util.default_reverse_key") if not self._server: raise ImproperlyConfigured("Missing connections string") if not isinstance(self._server, (list, tuple, set)): self._server = self._server.split(",") self._options = params.get("OPTIONS", {}) serializer_path = self._options.get( "SERIALIZER", "django_redis.serializers.pickle.PickleSerializer") serializer_cls = load_class(serializer_path) compressor_path = self._options.get( "COMPRESSOR", "django_redis.compressors.identity.IdentityCompressor") compressor_cls = load_class(compressor_path) self._serializer = serializer_cls(options=self._options) self._compressor = compressor_cls(options=self._options) # Hack: Add sentinels servers as options, to break legacy pool code as less as possible self._options.update({"SENTINELS": self._server}) # Create connection factory for Sentinels self.connection_factory = pool.get_connection_factory( options=self._options)