예제 #1
0
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,
        )
예제 #2
0
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,
        )
예제 #3
0
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,
        )
예제 #4
0
파일: redis.py 프로젝트: vbraziel/sentry
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)
예제 #5
0
 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
예제 #6
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)
예제 #7
0
파일: redis.py 프로젝트: timchunght/sentry
    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)
예제 #8
0
파일: redis.py 프로젝트: waterdrops/sentry
    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)
예제 #9
0
파일: redis.py 프로젝트: faulkner/sentry
 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)
예제 #10
0
파일: redis.py 프로젝트: daevaorn/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(self, options)
예제 #11
0
파일: redis.py 프로젝트: WhoTrades/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options('SENTRY_BUFFER_OPTIONS', options)
예제 #12
0
파일: redis.py 프로젝트: timchunght/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(self, options)
     super(RedisQuota, self).__init__(**options)
     self.namespace = 'quota'
예제 #13
0
파일: redis.py 프로젝트: Kayle009/sentry
 def __init__(self, **options):
     cluster, options = get_cluster_from_options(
         'SENTRY_CACHE_OPTIONS', options)
     client = cluster.get_routing_client()
     CommonRedisCache.__init__(self, client, **options)
예제 #14
0
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
예제 #15
0
파일: redis.py 프로젝트: 280185386/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options('SENTRY_QUOTA_OPTIONS', options)
     super(RedisQuota, self).__init__(**options)
     self.namespace = 'quota'
예제 #16
0
파일: redis.py 프로젝트: GeekGalaxy/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options("SENTRY_RATELIMITER_OPTIONS", options)
예제 #17
0
파일: redis.py 프로젝트: mburgs/sentry
 def __init__(self, **options):
     cluster, options = get_cluster_from_options("SENTRY_CACHE_OPTIONS",
                                                 options)
     client = cluster.get_routing_client()
     CommonRedisCache.__init__(self, client, **options)
예제 #18
0
파일: redis.py 프로젝트: zeuskingzb/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(
         "SENTRY_QUOTA_OPTIONS", options)
     super(RedisQuota, self).__init__(**options)
     self.namespace = "quota"
예제 #19
0
파일: redis.py 프로젝트: 280185386/sentry
    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)
예제 #20
0
 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)
예제 #21
0
    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)
예제 #22
0
파일: redis.py 프로젝트: alexandrul/sentry
 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
예제 #23
0
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(self, options)
예제 #24
0
파일: redis.py 프로젝트: ob3/sentry
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options('SENTRY_BUFFER_OPTIONS', options)
예제 #25
0
파일: redis.py 프로젝트: pasala91/test
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(
         "SENTRY_RATELIMITER_OPTIONS", options)
예제 #26
0
파일: redis.py 프로젝트: timchunght/sentry
    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)
예제 #27
0
 def __init__(self, **options):
     self.cluster, options = get_cluster_from_options(self, options)
     super(RedisQuota, self).__init__(**options)
     self.namespace = 'quota'
예제 #28
0
파일: redis.py 프로젝트: timchunght/sentry
 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)