コード例 #1
0
ファイル: account_service.py プロジェクト: bhanuvrat/vyked
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)
コード例 #2
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)
コード例 #3
0
ファイル: account_service.py プロジェクト: pmittal1982/vyked
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()
コード例 #4
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.get_event_loop().call_later(10, tcp.password_changed, "username")
    bus.start(REGISTRY_HOST, REGISTRY_PORT)
コード例 #5
0
ファイル: identity_service.py プロジェクト: bhanuvrat/vyked
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)
コード例 #6
0
ファイル: httpserver.py プロジェクト: awesome-python/vyked

REGISTRY_HOST = '127.0.0.1'
REGISTRY_PORT = 4500
REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379


class Hello(HTTPApplicationService):
    def __init__(self):
        super(Hello, self).__init__('Hello', 1, '127.0.0.1', '7890')

    @get(path='/')
    def root(self, request) -> Response:
        response = yield from aiohttp.request('get', 'https://github.com/timeline.json')
        result = yield from response.text()
        return Response(body=result.encode())

    @get(path='/{name}', required_params=['test', 'name'])
    def person(self, request) -> Response:
        result = 'Hello' + request.match_info.get('name', 'Anon')
        return Response(body=result.encode())


if __name__ == '__main__':
    bus = Bus()
    hello = Hello()
    hello.ronin = True
    bus.serve_http(hello)
    bus.start(REGISTRY_HOST, REGISTRY_PORT, REDIS_HOST, REDIS_PORT)
コード例 #7
0
ファイル: httpclient.py プロジェクト: shivank-gupta/vyked

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)
コード例 #8
0
ファイル: httpclient.py プロジェクト: awesome-python/vyked

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)
コード例 #9
0
REGISTRY_HOST = '127.0.0.1'
REGISTRY_PORT = 4500
REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379


class Hello(HTTPApplicationService):
    def __init__(self):
        super(Hello, self).__init__('Hello', 1, '127.0.0.1', '7890')

    @get(path='/')
    def root(self, request) -> Response:
        response = yield from aiohttp.request(
            'get', 'https://github.com/timeline.json')
        result = yield from response.text()
        return Response(body=result.encode())

    @get(path='/{name}', required_params=['test', 'name'])
    def person(self, request) -> Response:
        result = 'Hello' + request.match_info.get('name', 'Anon')
        return Response(body=result.encode())


if __name__ == '__main__':
    bus = Bus()
    hello = Hello()
    hello.ronin = True
    bus.serve_http(hello)
    bus.start(REGISTRY_HOST, REGISTRY_PORT, REDIS_HOST, REDIS_PORT)
コード例 #10
0
ファイル: httpclient.py プロジェクト: pmittal1982/vyked

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('127.0.0.1', 4500)
    bus.serve_http(ts)
    bus.require([client])
    bus.start()
コード例 #11
0
ファイル: articles.py プロジェクト: nerandell/golem
from vyked import Bus
from ..golem.golem import Golem

REGISTRY_HOST = '127.0.0.1'
REGISTRY_PORT = 4500

REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379

if __name__ == '__main__':
    bus = Bus()
    Article, tcp_service, http_service = Golem.generate("Article", [('username', 'id'), ('email', str)])
    tcp_service.ronin = True
    http_service.ronin = True
    bus.serve_tcp(tcp_service)
    bus.serve_http(http_service)
    bus.start(REGISTRY_HOST, REGISTRY_PORT, REDIS_HOST, REDIS_PORT)

コード例 #12
0
ファイル: identity_service.py プロジェクト: pmittal1982/vyked
def setup_identity_service():
    bus = Bus(REGISTRY_HOST, REGISTRY_PORT)
    identity_service = IdentityService(IDENTITY_HOST, IDENTITY_PORT)
    identity_service.bus = bus
    bus.serve_tcp(identity_service)
    bus.start()
コード例 #13
0
ファイル: httpserver.py プロジェクト: pmittal1982/vyked
from vyked import Bus


REGISTRY_HOST = '127.0.0.1'
REGISTRY_PORT = 4500


class Hello(HTTPApplicationService):
    def __init__(self):
        super(Hello, self).__init__('Hello', 1, '127.0.0.1', '7890')

    @get(path='/')
    def root(self, request) -> Response:
        response = yield from aiohttp.request('get', 'https://github.com/timeline.json')
        result = yield from response.text()
        return Response(body=result.encode())

    @get(path='/{name}', required_params=['test', 'name'])
    def person(self, request) -> Response:
        result = 'Hello' + request.match_info.get('name', 'Anon')
        return Response(body=result.encode())


if __name__ == '__main__':
    bus = Bus(REGISTRY_HOST, REGISTRY_PORT)
    hello = Hello()
    hello.ronin = True
    bus.serve_http(hello)
    bus.start()