From 747af2e2c30bc9d310929d829adc5fd862fdf7ef Mon Sep 17 00:00:00 2001 From: BryantHe Date: Thu, 27 Jul 2023 15:47:34 +0800 Subject: [PATCH] test --- .gitignore | 4 ++-- example/__init__.py | 0 example/config.yml | 5 +++++ example/rpc_demo.py | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 example/__init__.py create mode 100644 example/config.yml create mode 100644 example/rpc_demo.py diff --git a/.gitignore b/.gitignore index 5d381cc..7cb51b2 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,7 @@ MANIFEST pip-log.txt pip-delete-this-directory.txt -# Unit test / coverage reports +# Unit tests / coverage reports htmlcov/ .tox/ .nox/ @@ -158,5 +158,5 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ diff --git a/example/__init__.py b/example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example/config.yml b/example/config.yml new file mode 100644 index 0000000..1a0ee3b --- /dev/null +++ b/example/config.yml @@ -0,0 +1,5 @@ +AMQP_URI: pyamqp://${RABBIT_USER:admin}:${RABBIT_PASSWORD:admin}@${RABBIT_HOST:localhost}:${RABBIT_PORT:5672}/ +RPC_EXCHANGE: 'nameko-rpc' + +max_workers: 10 +parent_calls_tracked: 20 diff --git a/example/rpc_demo.py b/example/rpc_demo.py new file mode 100644 index 0000000..c0907e6 --- /dev/null +++ b/example/rpc_demo.py @@ -0,0 +1,27 @@ +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)