nameko-chassis provides an opinionated base class for building resilient, observable microservices.
Project description
docs |
|
---|---|
tests |
|
package |
nameko-chassis provides an opinionated base class for building resilient, observable microservices with the nameko framework.
Features
By using nameko_chassis.service.Service, you’ll get:
error reporting using Sentry
integrated metrics endpoint for Prometheus
request tracing with Zipkin
helpers for service discovery (TODO)
Installation
pip install nameko-chassis
You can also install the in-development version with:
pip install https://github.com/Emplocity/nameko-chassis/archive/master.zip
Usage
Base service class
from nameko.rpc import rpc
from nameko_chassis.service import Service
class MyService(Service):
name = "my_service"
@rpc
def my_method(self):
try:
self.zipkin.update_binary_annotations({
"foo": "bar",
})
except Exception:
self.sentry.captureException()
Backdoor debugging
nameko-chassis.debug includes helpers for introspecting running services with nameko backdoor feature. For example if your service exposes backdoor on port 12345:
$ rlwrap nc -v localhost 12345 Connection to localhost 12345 port [tcp/*] succeeded! Python 3.8.8 (default, Mar 23 2021, 11:02:14) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from nameko_chassis.debug import debug_runner >>> debug_runner(runner) ╭──────────────────────────── sleeping_http_service ───────────────────────────╮ │ 19 entrypoints │ │ 15 dependencies │ │ running 1/10 worker threads │ │ ╭────────────────── Thread #0: SleepingHttpService.sleep ──────────────────╮ │ │ │ │ │ │ │ Args: ["<Request 'http://127.0.0.1:8000/sleep/500' [GET]>"] │ │ │ │ Kwargs: {'duration': '500'} │ │ │ │ Context data: {'X-B3-ParentSpanId': '1058ef878ab0fe32'} │ │ │ │ │ │ │ │ Traceback: │ │ │ │ File │ │ │ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │ │ │ line 221, in main │ │ │ │ result = function(*args, **kwargs) │ │ │ │ File │ │ │ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/nameko/c… │ │ │ │ line 392, in _run_worker │ │ │ │ result = method(*worker_ctx.args, **worker_ctx.kwargs) │ │ │ │ File "./app/service.py", line 73, in sleep │ │ │ │ time.sleep(duration) │ │ │ │ File │ │ │ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │ │ │ line 36, in sleep │ │ │ │ hub.switch() │ │ │ │ File │ │ │ │ "/home/zbigniewsiciarz/v/sleephttp/lib/python3.8/site-packages/eventlet… │ │ │ │ line 313, in switch │ │ │ │ return self.greenlet.switch() │ │ │ │ │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────╯
Documentation
Development
To run the all tests run:
tox
License
This work is released under the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nameko_chassis-0.7.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e191746fdeef172544a93b144f0eaf9fb7bfb3fbc70aa66209c11d650fab4ac7 |
|
MD5 | 3b69dae4aef3d1c33a6bf79cb96c0e7c |
|
BLAKE2b-256 | 083c6131f4cf5f0bdd3328065a6dabed15143f589391c3990fe6e9dc8e74372f |