コード例 #1
0
ファイル: test_sentinel.py プロジェクト: seyeojumu/pysoa
    def test_invalid_hosts(self):
        with self.assertRaises(ValueError):
            SentinelRedisClient(
                hosts='redis://localhost:1234/0')  # type: ignore

        with self.assertRaises(ValueError):
            SentinelRedisClient(hosts=['redis://localhost:1234/0'
                                       ])  # type: ignore
コード例 #2
0
    def test_invalid_hosts(self):
        with self.assertRaises(ValueError):
            SentinelRedisClient(
                hosts='redis://localhost:1234/0')  # type: ignore

        with self.assertRaises(ValueError):
            SentinelRedisClient(hosts=[1234])  # type: ignore

        with self.assertRaises(ValueError):
            SentinelRedisClient(hosts=[('host_name', 'not_an_int')
                                       ])  # type: ignore
コード例 #3
0
    def backend_layer(self):  # type: () -> BaseRedisClient
        if self._backend_layer is None:
            cache_key = (self.backend_type, dict_to_hashable(cast(Dict[Hashable, Any], self.backend_layer_kwargs)))
            if cache_key not in self._backend_layer_cache:
                with self._get_timer('backend.initialize'):
                    backend_layer_kwargs = deepcopy(self.backend_layer_kwargs)
                    if self.backend_type == REDIS_BACKEND_TYPE_SENTINEL:
                        self._backend_layer_cache[cache_key] = SentinelRedisClient(**backend_layer_kwargs)
                    else:
                        self._backend_layer_cache[cache_key] = StandardRedisClient(**backend_layer_kwargs)

            self._backend_layer = self._backend_layer_cache[cache_key]

        # Each time the backend layer is accessed, use _this_ transport's metrics recorder for the backend layer
        self._backend_layer.metrics_counter_getter = self._get_counter
        return self._backend_layer
コード例 #4
0
ファイル: test_sentinel.py プロジェクト: zetahernandez/pysoa
    def test_no_hosts_send_receive(self):
        client = SentinelRedisClient()

        payload = {'test': 'test_no_hosts_send_receive'}

        client.send_message_to_queue(
            queue_key='test_no_hosts_send_receive',
            message=msgpack.packb(payload, use_bin_type=True),
            expiry=10,
            capacity=10,
            connection=client.get_connection('test_no_hosts_send_receive'),
        )

        message = None
        for i in range(3):
            # Message will be on random server
            message = message or client.get_connection('test_no_hosts_send_receive').lpop('test_no_hosts_send_receive')

        self.assertIsNotNone(message)
        self.assertEqual(payload, msgpack.unpackb(message, raw=False))
コード例 #5
0
 def _set_up_client(**kwargs):
     return SentinelRedisClient(hosts=[('169.254.7.12', 26379),
                                       ('169.254.8.12', 26379),
                                       ('169.254.9.12', 26379)],
                                **kwargs)