chassis/examples/nameko_demo/rpc_demo.py

21 lines
440 B
Python
Raw Normal View History

2023-07-18 10:32:44 +08:00
from nameko.rpc import rpc, ServiceRpc
2023-05-22 15:54:01 +08:00
class RpcResponderDemoService:
name = "rpc_responder_demo_service"
@rpc
def hello(self, name):
return "Hello, {}!".format(name)
class RpcCallerDemoService:
name = "rpc_caller_demo_service"
2023-07-18 10:32:44 +08:00
remote = ServiceRpc("rpc_responder_demo_service")
2023-05-22 15:54:01 +08:00
@rpc
def remote_hello(self, value="John Doe"):
res = u"{}".format(value)
return self.remote.hello(res)