{ "info": { "author": "Gabor Boros", "author_email": "gabor.brs@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "# django-microservices\n\n## About\nSimple django package to easily \"connect\" microservices.\n\nThe package loads the service configurations (id, name, host) into a DB table from a json file which can be stored on a shared drive, or hosted on URL.\n\n## Installation\nYou can simply install the package with pip from **PyPI** or **GitHub**.\n\n**Install with pip from github**\n\n`pip install git+https://github.com/gabor-boros/django-microservices.git`\n\n**Install from pypi**\n\n`pip install djangomicroservices`\n\n## Configuration\nAdd the `microservices` app to your `INSTALLED_APPS` like this:\n\n```\nINSTALLED_APPS = [\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n 'microservices',\n ...\n]\n```\n\nAfter you added it to the `INSTALLED_APPS`, you **must** configure the path where your service configuration exists.\nThe configuration file is a `json` file. Basically it is an output of `python manage.py dumpdata` command.\nIt doesn't matter where is your file located. It can be hosted on a website, or located on a *shared* drive.\n\n```\nSERVICE_CONFIGURATION_FILE = 'http://myserver.com/services.json'\n```\n\nor\n\n```\nSERVICE_CONFIGURATION_FILE = 'services.json'\n```\n\n**Service configuration example**\n*sample.json*\n```\n[\n {\n \"model\": \"microservices.service\",\n \"pk\": 1,\n \"fields\": {\n \"name\": \"auth\",\n \"host\": \"http://auth.example.com/\",\n }\n },\n {\n \"model\": \"microservices.service\",\n \"pk\": 2,\n \"fields\": {\n \"name\": \"search\",\n \"host\": \"http://search.example.com/\",\n }\n }\n]\n```\n\n## Usage\nAfter you are done with the installation and configuration, and you loaded your services, you are good to go.\nThe usage is very simple. Query your service, and call the `remote_call` object method.\n\n**Remote call example**\n```\nimport json\nfrom microservices.models import Service\n\ndef can_login(username, password):\n authentication_data = json.loads({\"username\": username: \"password\": password})\n\n authentication_service = Service.objects.get(name=\"auth\")\n response = authentication_service.remote_call(\n method, api='/login/', data=authentication_data\n )\n\n if response.status_code == 200:\n return True\n\n return False\n\n```\n\nThe package ships with an other object method called `update_availability`. This method can be used to update your service's status.\nTo do this you can call it for the object as shown in the example below.\n\n**NOTE**\nIf the response code is 400, 404, 500 or 503, the value of `is_available` field will be `False`.\n\n**Update service status**\n```\nfrom microservices.models import Service\n\nfor service in Service.objects.all():\n service.update_availability()\n\n```\n\n## Management commands\nThree management command ships with this package to help to manage your service configuration.\n\n* `list_services` - Lists your services ordered by their status\n* `load_services` - Loads the configuration from the given resource location, set in `settings.py`\n* `check_services` - Going thorough your configuration and tries to reach them.\n * If the host sends any response (which is not error related), the service will be marked available\n * If the response is an error, or the service can not be reached, the service's status will be unavailable\n\n## Tests\nTo run the tests for this package use the `python manage.py test` command as usual\nIn case you would like to generate a **coverage** report as well, run the `run_test_coverage.sh` file.\n\n## Contributors\nIf you would like to help to develop this package please read the CONTRIBUTING guideline. Every PR is highly welcomed.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gabor-boros/django-microservices", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "djangomicroservices", "package_url": "https://pypi.org/project/djangomicroservices/", "platform": "", "project_url": "https://pypi.org/project/djangomicroservices/", "project_urls": { "Homepage": "https://github.com/gabor-boros/django-microservices" }, "release_url": "https://pypi.org/project/djangomicroservices/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Simple django package to easily connect microservices.", "version": "0.1.2" }, "last_serial": 4399456, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "0ff95a11bb417444bdd42e7c8032cc20", "sha256": "ddadaf517b8e2c631b39f0c881e3f36efdd6770a31f2b8602d98f4e107ab66f7" }, "downloads": -1, "filename": "djangomicroservices-0.1.0.tar.gz", "has_sig": false, "md5_digest": "0ff95a11bb417444bdd42e7c8032cc20", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4948, "upload_time": "2016-09-06T07:26:46", "url": "https://files.pythonhosted.org/packages/92/2a/9c7e7611856ba3482933af3a4223dce8d7ea6d330833ca0d5e0aa7a1b9a0/djangomicroservices-0.1.0.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "e50f69d2ac600dedb2fd4e29930a5649", "sha256": "a5b10098b40ec23c18ff60ef36bc1344cb2691254e15a4f11fe4c1fa2a175d55" }, "downloads": -1, "filename": "djangomicroservices-0.1.2.tar.gz", "has_sig": false, "md5_digest": "e50f69d2ac600dedb2fd4e29930a5649", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6399, "upload_time": "2018-10-21T12:58:21", "url": "https://files.pythonhosted.org/packages/1f/4d/c342bfb89c8440d8fa9103d92439cd0019934ec3b8ae19349a9ef5e9e954/djangomicroservices-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e50f69d2ac600dedb2fd4e29930a5649", "sha256": "a5b10098b40ec23c18ff60ef36bc1344cb2691254e15a4f11fe4c1fa2a175d55" }, "downloads": -1, "filename": "djangomicroservices-0.1.2.tar.gz", "has_sig": false, "md5_digest": "e50f69d2ac600dedb2fd4e29930a5649", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6399, "upload_time": "2018-10-21T12:58:21", "url": "https://files.pythonhosted.org/packages/1f/4d/c342bfb89c8440d8fa9103d92439cd0019934ec3b8ae19349a9ef5e9e954/djangomicroservices-0.1.2.tar.gz" } ] }