How to use the pysoa.common.metrics.NoOpMetricsRecorder function in pysoa

To help you get started, we’ve selected a few pysoa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eventbrite / pysoa / tests / unit / common / transport / redis_gateway / test_threading.py View on Github external
def _test():
        backend = _FakeBackend()

        server_transport = RedisServerTransport(
            'threaded',
            NoOpMetricsRecorder(),
            backend_type=REDIS_BACKEND_TYPE_STANDARD,
        )
        server_transport.core._backend_layer = backend  # type: ignore

        client_transport = RedisClientTransport(
            'threaded',
            NoOpMetricsRecorder(),
            backend_type=REDIS_BACKEND_TYPE_STANDARD,
        )
        client_transport.core._backend_layer = backend  # type: ignore

        server = _FakeEchoingServer(server_transport)

        client1 = _FakeClient('client-1', client_transport, {'key1': 'value1'}, 1.0)
        client2 = _FakeClient('client-2', client_transport, {'key2': 'value2'}, 0.25)

        server.start()

        client1.start()
        client2.start()
        client1.join(timeout=2)
        client2.join(timeout=2)
github eventbrite / pysoa / tests / unit / common / transport / redis_gateway / test_server.py View on Github external
def _get_transport(service='my_service', **kwargs):
        return RedisServerTransport(service, NoOpMetricsRecorder(), **kwargs)
github eventbrite / pysoa / tests / unit / common / transport / redis_gateway / test_client.py View on Github external
def _get_transport(service='my_service', **kwargs):
        return RedisClientTransport(service, NoOpMetricsRecorder(), **kwargs)
github eventbrite / pysoa / tests / common_tests / transport / test_asgi_transport.py View on Github external
def _mock_send(_, message):
            Nonlocal.message = message

        client_request_id = 1
        client_request_meta = {}
        client_request_body = 'this is an important message'
        with mock.patch('pysoa.common.transport.asgi.core.RedisChannelLayer.send', side_effect=_mock_send):
            with mock.patch('pysoa.common.transport.asgi.core.RedisChannelLayer.receive') as mock_receive:
                client_transport = ASGIClientTransport(
                    'test',
                    NoOpMetricsRecorder(),
                    asgi_channel_type=ASGI_CHANNEL_TYPE_REDIS,
                )
                server_transport = ASGIServerTransport(
                    'test',
                    NoOpMetricsRecorder(),
                    asgi_channel_type=ASGI_CHANNEL_TYPE_REDIS,
                )
                client_transport.send_request_message(client_request_id, client_request_meta, client_request_body)
                mock_receive.return_value = ('some_channel', Nonlocal.message)
                server_request_id, server_request_meta, server_request_body = server_transport.receive_request_message()
                assert client_request_id == server_request_id
                assert client_request_meta == server_request_meta
                assert client_request_body == server_request_body
github eventbrite / pysoa / tests / common_tests / transport / test_asgi_transport.py View on Github external
def test_send_request_runs_without_errors(self, _):
        """Calling send_request_message with a valid request should produce no exceptions."""
        client_transport = ASGIClientTransport(
            'test',
            NoOpMetricsRecorder(),
            asgi_channel_type=ASGI_CHANNEL_TYPE_REDIS,
        )
        message_body = 'this is an important message'
        meta = {'foo': 1}
        request_id = 1
        client_transport.send_request_message(request_id, meta, message_body)
github eventbrite / pysoa / tests / common_tests / transport / test_asgi_transport.py View on Github external
def test_valid_response(self):
        """The transport should pass ID, meta and body fields back to the caller"""
        response_message = {
            'meta': {'reply_to': 'clientID1234'},
            'request_id': 1,
            'body': 'this is an important message',
        }

        with mock.patch('pysoa.common.transport.asgi.core.RedisChannelLayer.receive',
                        return_value=('channelName', response_message)):
            client_transport = ASGIClientTransport(
                'test',
                NoOpMetricsRecorder(),
                asgi_channel_type=ASGI_CHANNEL_TYPE_REDIS,
            )
            # We don't get anything back unless the outstanding response counter is > 0
            request_id, meta, message_body = client_transport.receive_response_message()
            assert request_id is meta is message_body is None
            client_transport.requests_outstanding = 1
            request_id, meta, message_body = client_transport.receive_response_message()
            assert request_id == response_message['request_id']
            assert meta == response_message['meta']
            assert message_body == response_message['body']