Exemplo n.º 1
0
def setup_identity_service():
    bus = Bus()
    http = IdentityHTTPService(IDENTITY_HOST, IDENTITY_HTTP_PORT)
    tcp = IdentityTCPService(IDENTITY_HOST, IDENTITY_TCP_PORT)
    bus.serve_http(http)
    bus.serve_tcp(tcp)
    asyncio. async (tcp.repeat_publish())
    bus.start(REGISTRY_HOST, REGISTRY_PORT, REDIS_HOST, REDIS_PORT)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0

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)