def setup_accounts_service(): bus = Bus(REGISTRY_HOST, REGISTRY_PORT) accounts_service = AccountService(ACCOUNTS_HOST, ACCOUNTS_PORT) identity_client = IdentityClient() bus.require([identity_client]) bus.serve_tcp(accounts_service) asyncio.get_event_loop().call_later(5, identity_client.create, None, 'test@123') bus.start()
def setup_accounts_service(): bus = Bus() accounts_service = AccountService(ACCOUNTS_HOST, ACCOUNTS_PORT) identity_client = IdentityClient() bus.require([identity_client]) bus.serve_tcp(accounts_service) asyncio.async(identity_client.repeat_request()) bus.start(REGISTRY_HOST, REGISTRY_PORT, REDIS_HOST, REDIS_PORT)
def process_response(response): body = yield from response.text() return body class TestService(HTTPApplicationService): def __init__(self, host, port): super(TestService, self).__init__("Test", 1, host, port) self._client = None def set_client(self, hello_client): self._client = hello_client @get('/test') def get_res(self, request): url = 'ankit' yield from self._client.person(url) return Response() if __name__ == '__main__': ts = TestService('127.0.0.1', 4502) client = Hello() ts.set_client(client) bus = Bus() bus.serve_http(ts) bus.require([client]) bus.start('127.0.0.1', 4500)