def test_get_cluster_from_options(): backend = object() manager = make_manager() cluster, options = get_cluster_from_options( backend, {"cluster": "foo", "foo": "bar"}, cluster_manager=manager ) assert cluster is manager.get("foo") assert cluster.pool_cls is _shared_pool assert options == {"foo": "bar"} cluster, options = get_cluster_from_options( backend, {"hosts": {0: {"db": 0}}, "foo": "bar"}, cluster_manager=manager ) assert cluster is not manager.get("foo") # kind of a silly assertion assert cluster.pool_cls is _shared_pool assert options == {"foo": "bar"} with pytest.raises(InvalidConfiguration): cluster, options = get_cluster_from_options( backend, {"hosts": {0: {"db": 0}}, "cluster": "foo", "foo": "bar"}, cluster_manager=manager, )
def test_get_cluster_from_options(): backend = object() manager = make_manager() cluster, options = get_cluster_from_options( backend, { 'cluster': 'foo', 'foo': 'bar', }, cluster_manager=manager, ) assert cluster is manager.get('foo') assert cluster.pool_cls is _shared_pool assert options == {'foo': 'bar'} cluster, options = get_cluster_from_options( backend, { 'hosts': { 0: { 'db': 0 }, }, 'foo': 'bar', }, cluster_manager=manager, ) assert cluster is not manager.get('foo') # kind of a silly assertion assert cluster.pool_cls is _shared_pool assert options == {'foo': 'bar'} with pytest.raises(InvalidConfiguration): cluster, options = get_cluster_from_options( backend, { 'hosts': { 0: { 'db': 0 }, }, 'cluster': 'foo', 'foo': 'bar', }, cluster_manager=manager, )
def get_dynamic_cluster_from_options(setting, config): cluster_name = config.get("cluster", "default") cluster_opts = options.default_manager.get("redis.clusters").get(cluster_name) if cluster_opts is not None and cluster_opts.get("is_redis_cluster"): return True, redis_clusters.get(cluster_name), config return (False,) + get_cluster_from_options(setting, config)
def __init__(self, pending_partitions=1, incr_batch_size=2, **options): self.cluster, options = get_cluster_from_options( "SENTRY_BUFFER_OPTIONS", options) self.pending_partitions = pending_partitions self.incr_batch_size = incr_batch_size assert self.pending_partitions > 0 assert self.incr_batch_size > 0
def __init__(self, prefix="ts:", vnodes=64, **options): self.cluster, options = get_cluster_from_options( "SENTRY_TSDB_OPTIONS", options) self.prefix = prefix self.vnodes = vnodes self.enable_frequency_sketches = options.pop( "enable_frequency_sketches", False) super(RedisTSDB, self).__init__(**options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options(self, options) self.namespace = options.pop('namespace', 'd') # Sets the time-to-live (in seconds) for records, timelines, and # digests. This can (and should) be a relatively high value, since # timelines, digests, and records should all be deleted after they have # been processed -- this is mainly to ensure stale data doesn't hang # around too long in the case of a configuration error. This should be # larger than the maximum scheduling delay to ensure data is not evicted # too early. self.ttl = options.pop('ttl', 60 * 60) super(RedisBackend, self).__init__(**options)
def __init__(self, **options: Any) -> None: self.cluster, options = get_cluster_from_options( "SENTRY_DIGESTS_OPTIONS", options) self.locks = LockManager(RedisLockBackend(self.cluster)) self.namespace = options.pop("namespace", "d") # Sets the time-to-live (in seconds) for records, timelines, and # digests. This can (and should) be a relatively high value, since # timelines, digests, and records should all be deleted after they have # been processed -- this is mainly to ensure stale data doesn't hang # around too long in the case of a configuration error. This should be # larger than the maximum scheduling delay to ensure data is not evicted # too early. self.ttl = options.pop("ttl", 60 * 60) super().__init__(**options)
def __init__(self, prefix='ts:', vnodes=64, **options): self.cluster, options = get_cluster_from_options('SENTRY_TSDB_OPTIONS', options) self.prefix = prefix self.vnodes = vnodes self.enable_frequency_sketches = options.pop('enable_frequency_sketches', False) super(RedisTSDB, self).__init__(**options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options(self, options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options('SENTRY_BUFFER_OPTIONS', options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options(self, options) super(RedisQuota, self).__init__(**options) self.namespace = 'quota'
def __init__(self, **options): cluster, options = get_cluster_from_options( 'SENTRY_CACHE_OPTIONS', options) client = cluster.get_routing_client() CommonRedisCache.__init__(self, client, **options)
def redis_cluster(config: Dict[str, Any]) -> redis._RedisCluster: cluster, options = redis.get_cluster_from_options( "TEST_CLUSTER", config, cluster_manager=redis.redis_clusters) return cluster
def __init__(self, **options): self.cluster, options = get_cluster_from_options('SENTRY_QUOTA_OPTIONS', options) super(RedisQuota, self).__init__(**options) self.namespace = 'quota'
def __init__(self, **options): self.cluster, options = get_cluster_from_options("SENTRY_RATELIMITER_OPTIONS", options)
def __init__(self, **options): cluster, options = get_cluster_from_options("SENTRY_CACHE_OPTIONS", options) client = cluster.get_routing_client() CommonRedisCache.__init__(self, client, **options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options( "SENTRY_QUOTA_OPTIONS", options) super(RedisQuota, self).__init__(**options) self.namespace = "quota"
def __init__(self, **options): self.cluster, options = get_cluster_from_options('SENTRY_CACHE_OPTIONS', options) self.client = self.cluster.get_routing_client() super(RedisCache, self).__init__(**options)
def __init__(self, prefix='ts:', vnodes=64, **options): self.cluster, options = get_cluster_from_options(self, options) self.prefix = prefix self.vnodes = vnodes super(RedisTSDB, self).__init__(**options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options( 'SENTRY_CACHE_OPTIONS', options) self.client = self.cluster.get_routing_client() super(RedisCache, self).__init__(**options)
def __init__(self, pending_partitions=1, incr_batch_size=2, **options): self.cluster, options = get_cluster_from_options('SENTRY_BUFFER_OPTIONS', options) self.pending_partitions = pending_partitions self.incr_batch_size = incr_batch_size assert self.pending_partitions > 0 assert self.incr_batch_size > 0
def __init__(self, **options): self.cluster, options = get_cluster_from_options( "SENTRY_RATELIMITER_OPTIONS", options)
def __init__(self, **options): self.cluster, options = get_cluster_from_options(self, options) self.client = self.cluster.get_routing_client() super(RedisCache, self).__init__(**options)