{ "info": { "author": "Lovely Systems", "author_email": "office@lovelysystems.com", "bugtrack_url": null, "classifiers": [ "Framework :: Pyramid", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "=========================\nLovely Webservices Status\n=========================\n\n.. image:: https://img.shields.io/pypi/v/lovely-ws-status.svg\n :target: https://pypi.org/project/lovely-ws-status/\n\n.. image:: https://img.shields.io/pypi/pyversions/lovely-ws-status.svg\n :target: https://pypi.org/project/lovely-ws-status/\n\n.. image:: https://travis-ci.org/lovelysystems/lovely-ws-status.svg?branch=master\n :target: https://travis-ci.org/lovelysystems/lovely-ws-status\n\nThis package provides service status utilities for Pyramid applications.\nRegister your own status handlers and see the service status of all registered\nhandlers in the ``svc_status`` Pyramid view.\n\n\nStatus Handler\n==============\n\nA status handler can be any method or class that checks any part of your\napplication stack. This can be for example a check that your database\nconnection is still working, or checking some external service. The status\nhandler must return a dict with a state property which can have the value\n``OK``, ``YELLOW`` or ``RED``. Additional properties like ``detail`` can be\noptionally added, but will only be displayed in the JSON SVC status view.\n\n\nAs Callable\n-----------\n\nCreate a status handler as a python function::\n\n >>> from lovely.ws.status import OK\n >>> def statusHandler():\n ... # Do whatever you need to do to check the status\n ... return {\n ... 'state': OK\n ... }\n\nRegister the status handler::\n\n >>> from lovely.ws.status import addStatusHandler\n >>> addStatusHandler('DatabaseConnection', statusHandler)\n\nStatus handlers can also be classes, just provide a ``__call__`` method::\n\n >>> from lovely.ws.status import RED\n >>> class StatusHandler(object):\n ... def __call__(self):\n ... # Do whatever you need to do to check the status\n ... return {\n ... 'state': RED,\n ... 'detail': 'Service not available',\n ... }\n >>> statusHandler2 = StatusHandler()\n >>> addStatusHandler('UserService', statusHandler2)\n\n\nMixin Class\n-----------\n\nTo simplify the implementation of status providers there is a mixin class\nwhich handles the state and provides logging on status changes::\n\n >>> from lovely.ws.status import YELLOW, GREEN\n >>> from lovely.ws.status.statehandler import StateHandlerMixin\n >>> class MyHandler(StateHandlerMixin):\n ... def __init__(self):\n ... self.setState(YELLOW)\n >>> myHandler = MyHandler()\n >>> addStatusHandler('myHandler', myHandler)\n\nNow just use ``setState`` to change the state. ``setState`` allows to set any\nadditional property on the state::\n\n >>> myHandler.setState(GREEN, detail='running')\n\n\nSVC Status View\n===============\n\nThere's a Pyramid view that can be added to your project which creates an\nendpoint to see the live service status provided by all registered status\nhandlers.\n\nFor the view to get registered, you need to configure this module in your application\nby adding these two lines in your app factory::\n\n config.include('lovely.ws.status.svcstatus')\n config.scan('lovely.ws.status.svcstatus')\n\nCalling the ``/svc_status`` endpoint will return a CSV response with an output\nlike this::\n\n DatabaseConnection OK\n UserService RED\n\nIt's also possible to receive the response in JSON format by calling the\n``svc_status`` endpoint with accept header ``application/json`` or by calling\nthe ``svc_status.json`` endpoint. Additional properties like the detail will\nonly be shown in the JSON formatted output. The output will look like this::\n\n {\n \"DatabaseConnection\": {\n \"state\": \"OK\"\n },\n \"UserService\":{\n \"state\": \"OK\",\n \"detail\": \"Service not available\"\n }\n }\n\nCalling the ``svc_status.prometheus`` endpoint returns the service status as\na prometheus template. The output will look like this::\n\n # HELP svc_status Status 0->OK, 1->YELLOW, 2->RED\n # TYPE svc_status untyped\n svc_status{name=\"DatabaseConnection\"} 0\n # HELP svc_status Status 0->OK, 1->YELLOW, 2->RED\n # TYPE svc_status untyped\n svc_status{name=\"UserService\"} 2\n\nMore information can be found in the `SVC status test suite\n`_.\n\n\nProbe Status View\n=================\n\nThis view allows to check if the service is available and to decommission the\nservice. The view returns status 200 and the body ``OK`` by default.\n\nThe probe status view can be included into a Pyramid project in the\n``server.py`` file by adding these two lines in your app factory::\n\n config.include('lovely.ws.status.probestatus')\n config.scan('lovely.ws.status.probestatus')\n\nDecommissioning can be used to make the service unavailable for load balancers\nbefore the service is shut down.\n\nMore information can be found in the `probe status test suite\n`_.\n\n\nDevelopment\n===========\n\nInformation on how to contribute can be found in the `DEVELOPMENT.rst\n`_ file.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lovelysystems/lovely-ws-status", "keywords": "pyramid service status monitoring prometheus", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "lovely-ws-status", "package_url": "https://pypi.org/project/lovely-ws-status/", "platform": "", "project_url": "https://pypi.org/project/lovely-ws-status/", "project_urls": { "Homepage": "https://github.com/lovelysystems/lovely-ws-status" }, "release_url": "https://pypi.org/project/lovely-ws-status/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "Service Status Utilities for Pyramid Apps", "version": "1.0.0" }, "last_serial": 4158612, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3ceab913fc7e327995b4b1efb8d0e1f9", "sha256": "ff5e610c6ce3951654448bd3f033866676bb67f4bfdb4bbed6f56bc98c98c257" }, "downloads": -1, "filename": "lovely-ws-status-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3ceab913fc7e327995b4b1efb8d0e1f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10202, "upload_time": "2018-08-10T22:53:16", "url": "https://files.pythonhosted.org/packages/4d/47/692a023401c541ebfb469c25bb155977e124ea9160dc0e830355a3f2d03b/lovely-ws-status-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3ceab913fc7e327995b4b1efb8d0e1f9", "sha256": "ff5e610c6ce3951654448bd3f033866676bb67f4bfdb4bbed6f56bc98c98c257" }, "downloads": -1, "filename": "lovely-ws-status-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3ceab913fc7e327995b4b1efb8d0e1f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10202, "upload_time": "2018-08-10T22:53:16", "url": "https://files.pythonhosted.org/packages/4d/47/692a023401c541ebfb469c25bb155977e124ea9160dc0e830355a3f2d03b/lovely-ws-status-1.0.0.tar.gz" } ] }