namekoplus-examples/example/rpc_demo.py

28 lines
645 B
Python

from nameko.rpc import rpc, ServiceRpc
from namekoplus import init_statsd
class RpcResponderDemoService:
name = "rpc_responder_demo_service"
statsd = init_statsd('rpc_responder', 'localhost')
@rpc
@statsd.timer('hello')
def hello(self, name):
return "Hello, {}!".format(name)
class RpcCallerDemoService:
name = "rpc_caller_demo_service"
remote = ServiceRpc("rpc_responder_demo_service")
statsd = init_statsd('rpc_caller', 'localhost')
@rpc
@statsd.timer('remote_hello')
def remote_hello(self, value="John Doe"):
res = u"{}".format(value)
return self.remote.hello(res)