{ "info": { "author": "Felipe Ortiz, Pablo Ahumada", "author_email": "fortizc@gmail.com, pablo.ahumadadiaz@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: System" ], "description": "Micro\n=====\n\n|travis| |coverage| |pypi| |pyversion|\n\nA platform to create microservices available through ``celery`` and\nRest (using ``gunicorn``) APIs.\n\nMicro API\n---------\n\nMicro uses a very simple API to run, list and get information about\nplugins:\n\n- ``plugins()``: list all available plugins.\n- ``info(plugin_name)``: show information about a specific plugin.\n- ``help(plugin_name)``: show the plugin help.\n- ``run(plugin_name, params)``: execute the given plugin.\n\nTo use this API with Celery you can use the\n`Micro-dev `__ package who provides\ntwo important libraries, the access to the Celery API and the PluginBase\nclass who allow writing Micro plugins. To use it as API Rest you can use\nthe ``requests`` python library.\n\nAPI Celery example (using micro-dev)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n >>> from micro.api.endpoints import Requests\n >>>\n >>> req = Requests(BROKER_URL, QUEUE_NAME)\n >>>\n >>> req.plugins.delay().wait()\n '[{\"name\": \"Example Plugin\", \"version\": null, \"description\": \"A very simple example plugin\"}]'\n >>>\n >>> req.run.delay(\"Example plugin\", name=\"Micro\").wait()\n {\"msg\": \"Hello Micro!!!\"}\n\n\n\nAPI Rest example (using requests)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n >>> import requests\n >>>\n >>> url = \"http://localhost:8000/plugins\"\n >>> response = requests.request(\"GET\", url)\n >>> print(response.text)\n [{\"name\": \"Example Plugin\", \"version\": null, \"description\": \"A very simple example plugin\"}]\n >>>\n >>> url = \"http://localhost:8000/run/Example%20Plugin\"\n >>> payload = '{\"name\": \"Micro\"}'\n >>> headers = {'content-type': 'application/json'}\n >>> response = requests.request(\"POST\", url, data=payload, headers=headers)\n >>> print(response.text)\n {\"msg\": \"Hello Micro!!!\"}\n\nMicro plugins\n-------------\n\nWrite Micro plugins is very simple all that you need is to create\na file called ``interface.py`` and a class which is the plugin itself.\n\n- the ``interface.py`` file defines the plugin metadata\n- the plugin class must:\n\n - inherit from ``micro.plugin.pluginbase.PluginBase``\n - implement the ``run`` method\n - return Python dictionaries on that `run` method\n\n.. code:: python\n\n from micro.plugin.pluginbase import PluginBase\n from micro.plugin.pluginbase import PluginDescription\n\n\n class ExamplePlugin(PluginBase):\n def __init__(self):\n print(\"This is an example plugin\")\n\n # This is the method executed by Micro\n # Must return a Python dictionary\n def run(self, name):\n return {\"msg\": \"Hello \" + name + \"!!!\"}\n\n\n # This description is required by Micro\n plugin = PluginDescription(\n instance=ExamplePlugin,\n name=\"Example Plugin\",\n version=\"0.1.0\",\n url=\"https://github.com/humu1us/micro\",\n author=\"Jhon Doe\",\n author_email=\"jhon.doe@email.com\",\n description=\"A very simple example plugin\",\n long_description=\"This plugin is a very simple example, \"\n \"for that reason, we don't have a long description\",\n plugin_help=\"Params: name type string; A name to greet\"\n )\n\nEach plugin needs to have its own folder inside of the plugins directory\n(check the section `\u201cConfiguring\nMicro\u201d `__ for\ndetails)\n\nThe plugin directory should look like this:\n\n::\n\n my_plugindir/\n example-plugin/\n interface.py\n exmple_plugin_core/\n libs...\n other-plugin/\n inteface.py\n other_plugin_core/\n libs...\n\n\n**IMPORTANT:** All the plugins must provide its own libraries inside of its own\nnamespace in order to avoid overwritting files. The general recomendation is to\nuse a base directory with the same name of the plugin as the example above shows\n\nInstallation\n------------\n\nPyPi:\n\n::\n\n $ pip install micro\n\nDevelopment version:\n\n::\n\n $ git clone git@github.com:humu1us/micro.git\n $ cd micro\n $ pip install -e .\n\nor direct from repository:\n\n::\n\n $ pip install git+ssh://git@github.com/humu1us/micro.git\n\nConfiguration\n-------------\n\nParameters priority\n~~~~~~~~~~~~~~~~~~~\n\nMicro can be configurated through CLI, environment variables, config\nfile and/or default values (in that order).\n\nCommand line (CLI)\n~~~~~~~~~~~~~~~~~~\n\nThese arguments are the highest priority for Micro, so these overwrite\nany other parameters set by any other method. The CLI arguments that can\nbe used are:\n\n::\n\n $ micro -h\n usage: micro [-d] [-h] [-v] [-c CONFIG_FILE] [-b BIND] [-B BROKER_URL]\n [-C] [-cw WORKERS] [-G] [-gw WORKERS] [-H HOSTNAME]\n [-ln LOG_FILE_NAME] [-lp LOG_FOLDER_PATH] [-ll LOG_LEVEL]\n [-pp PID_FOLDER_PATH] [-p PLUGIN_PATH] [-q TASK_QUEUES]\n\n optional arguments:\n -d, --default-values show default values and exit\n -h, --help show this help message and exit\n -v, --version show program's version and exit\n -c CONFIG_FILE, --config-file CONFIG_FILE\n path to the config file\n env: MICRO_CONFIG_FILE\n default: None\n -b BIND, --bind BIND Gunicorn bind, HOST:PORT\n env: MICRO_BIND\n default: 0.0.0.0:8000\n -B BROKER_URL, --broker-url BROKER_URL\n Celery broker URL\n env: MICRO_BROKER_URL\n default: None\n -C, --celery plugins available through Celery\n env: MICRO_CELERY\n default: None\n -cw WORKERS, --celery-workers WORKERS\n Celery number of workers\n env: MICRO_CELERY_WORKERS\n default: 1\n -G, --gunicorn plugins available through API Rest\n env: MICRO_GUNICORN\n default: None\n -gw WORKERS, --gunicorn-workers WORKERS\n Gunicorn number of workers\n env: MICRO_GUNICORN_WORKERS\n default: 1\n -H HOSTNAME, --hostname HOSTNAME\n Celery worker's hostname\n env: MICRO_HOSTNAME\n default: micro\n -ln LOG_FILE_NAME, --log-file-name LOG_FILE_NAME\n Micro's log file name\n env: MICRO_LOG_FILE_NAME\n default: micro.log\n -lp LOG_FOLDER_PATH, --log-folder-path LOG_FOLDER_PATH\n path to the Micro's log folder\n env: MICRO_LOG_FOLDER_PATH\n default: /var/log/micro\n -ll LOG_LEVEL, --log-level LOG_LEVEL\n Micro's log level\n env: MICRO_LOG_LEVEL\n default: WARNING\n -pp PID_FOLDER_PATH, --pid-folder-path PID_FOLDER_PATH\n path to the Micro's PID folder\n env: MICRO_PID_FOLDER_PATH\n default: /var/run/micro\n -p PLUGIN_PATH, --plugin-path PLUGIN_PATH\n path to the plugins folder\n env: MICRO_PLUGIN_PATH\n default: None\n -q TASK_QUEUES, --task-queues TASK_QUEUES\n Celery task queues\n env: MICRO_TASK_QUEUES\n default: None\n\n**IMPORTANT:** `-G`, `--gunicorn` or `-C`, `--celery`, or both, must be included otherwise Micro will finish without any message\n\nEnvironment variables\n~~~~~~~~~~~~~~~~~~~~~\n\nThe next priority in parameters for Micro are environment variables. The\nlist of environment variables used are:\n\n::\n\n MICRO_CONFIG_FILE # config file location: /path/to/config/config.json\n MICRO_BIND # Gunicorn socket bind (host:port)\n MICRO_BROKER_URL # broker url: ampq://user:pass@host:port//\n MICRO_CELERY # plugins available through Celery\n MICRO_CELERY_WORKERS # number of Celery workers (integer number)\n MICRO_GUNICORN # plugins available through API Rest (Gunicorn)\n MICRO_GUNICORN_WORKERS # number of Gunicorn workers (integer number)\n MICRO_HOSTNAME # workers hostname\n MICRO_LOG_FILE_NAME # log file name: micro.log\n MICRO_LOG_FOLDER_PATH # path to log folder: /path/to/log/folder\n MICRO_LOG_LEVEL # minimun log level to write: DEBUG, INFO, WARNING, ERROR, CRITICAL or FATAL\n MICRO_PID_FOLDER_PATH # path to Celery pid folder: /path/to/pid/folder\n MICRO_PLUGIN_PATH # path to plugin folder: /path/to/plugin/folder\n MICRO_TASK_QUEUES # queue name used\n\nConfig file\n~~~~~~~~~~~\n\nThe lowest priority is the use of a JSON config file. The path to this\nconfig file must be set using ``-c, --config-file`` CLI arguments or\n``MICRO_CONFIG`` environment variable.\n\nCelery and Gunicorn configurations can be given through this config file as well.\n\nConfig file example:\n\n.. code:: js\n\n {\n \"gunicorn\": {\n \"bind\": \"0.0.0.0:8000\",\n \"workers\": 1\n },\n \"celery\": {\n \"broker_url\": \"\",\n \"workers\": 1,\n \"hostname\": \"micro\",\n \"task_queues\": \"\"\n },\n \"micro\": {\n \"log_file_name\": \"micro.log\",\n \"log_folder_path\": \"/var/log/micro\",\n \"log_level\": \"WARNING\",\n \"pid_folder_path\": \"/var/run/micro\",\n \"plugin_path\": \"\"\n }\n }\n\nA config file skeleton can be created using the following command:\n``$ micro --default-values > config.json``\n\nDefault values\n~~~~~~~~~~~~~~\n\nThe default values are the same shown above.\n\nCORS support\n~~~~~~~~~~~~\n\nMicro implements CORS support using `Flask-CORS `__\nthe configuration must be made inside of the Gunicorn key using the ``cors`` key, the possible\nvalues are `listed in the CORS documentation `__\n\nFor example this configuration allow any client:\n\n.. code:: js\n\n {\n \"gunicorn\": {\n \"bind\": \"0.0.0.0:8000\",\n \"workers\": 1,\n \"cors\": {\"origins\": \"*\"}\n },\n ...\n\n\nDocker\n------\n\nPull\n~~~~\n\nTo download from Docker Hub:\n\n::\n\n $ docker pull humu1us/micro:\n\nTo check the available tags please visit `Micro\u2019s repository on Docker\nHub `__\n\nBuild\n~~~~~\n\nTo build the container first move to the branch/tag to use and then use\nthe following command:\n\n::\n\n $ docker build -t micro: .\n\nRun\n~~~\n\nAll Micro environment variables are available with ``-e`` flag. For\nexample to run Micro with Celery you can do:\n\n::\n\n $ docker run -d \\\n -v /path/to/plugins:/etc/micro/plugins \\\n -v /path/to/log:/var/log/micro \\\n -e MICRO_BROKER_URL=amqp://guest:guest@my_host:5672// \\\n -e MICRO_TASK_QUEUES=test \\\n -e MICRO_HOSTNAME=my_host \\\n -e MICRO_CELERY_WORKERS=2 \\\n -e MICRO_CELERY=1 \\\n micro:\n\n``MICRO_BROKER_URL`` and ``MICRO_TASK_QUEUES`` are the only mandatory\nenvironment variables to set when Celery will be used.\n\nWhen Micro will be run with API Rest you have to bind the Gunicorn port:\n\n::\n\n $ docker run -d \\\n -v /path/to/plugins:/etc/micro/plugins \\\n -v /path/to/log:/var/log/micro \\\n -e MICRO_BIND=0.0.0.0:5000 \\\n -e MICRO_GUNICORN_WORKERS=2 \\\n -e MICRO_GUNICORN=1 \\\n -p 5000:5000 \\\n micro:\n\nTests\n-----\n\nRun all unit tests with:\n\n::\n\n $ python setup.py test\n\n.. |travis| image:: https://img.shields.io/travis/humu1us/micro.svg?branch=master&style=flat-square\n :target: https://travis-ci.org/humu1us/micro\n.. |coverage| image:: https://img.shields.io/coveralls/humu1us/micro.svg?style=flat-square\n :target: https://coveralls.io/github/humu1us/micro\n.. |pypi| image:: https://img.shields.io/pypi/v/Micro.svg?style=flat-square\n :target: https://pypi.python.org/pypi/Micro/\n.. |pyversion| image:: https://img.shields.io/pypi/pyversions/micro.svg?style=flat-square\n :target: https://pypi.python.org/pypi/Micro/\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/humu1us/micro", "keywords": "microservices celery", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "Micro", "package_url": "https://pypi.org/project/Micro/", "platform": "", "project_url": "https://pypi.org/project/Micro/", "project_urls": { "Homepage": "https://github.com/humu1us/micro" }, "release_url": "https://pypi.org/project/Micro/3.1.0/", "requires_dist": [ "amqp (<=2.2.2,>2)", "Flask (<2,>=1)", "Flask-Cors (<4,>=3.0.7)", "celery (<=4.1.0,>4)", "gunicorn (<20,>=19.8.1)", "kombu (<=4.1.0,>4)" ], "requires_python": "", "summary": "Celery platform to create microservices", "version": "3.1.0" }, "last_serial": 4948283, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0a1ac59089685701bf948ac91d8b4eb0", "sha256": "3c8d61ac3274d2b4638dcb29fba5f56286ae396abdc4d9284e640c187ae534e9" }, "downloads": -1, "filename": "Micro-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "0a1ac59089685701bf948ac91d8b4eb0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17561, "upload_time": "2017-12-28T05:54:31", "url": "https://files.pythonhosted.org/packages/33/44/06dbbd697b8d8c4fefec32bf46eeb96cae971793ce7275dd4e015a975759/Micro-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9dcf86400c67019b1f53263906644566", "sha256": "253a0f8f0e5fe8bd5246a29baf27adb1d8e95973c9cd532b7afbc51ffee80296" }, "downloads": -1, "filename": "Micro-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9dcf86400c67019b1f53263906644566", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10419, "upload_time": "2017-12-28T05:54:32", "url": "https://files.pythonhosted.org/packages/53/ab/735e5ee7c4337ebee22ec67fe658648ae88992dbf72824d144ecae683bc6/Micro-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "a7515f813ba9e9059c34acacab88ed9e", "sha256": "dd8967910f4f39b765ab43dd785cd95f963b829c62760f341cec2795bfd18134" }, "downloads": -1, "filename": "Micro-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a7515f813ba9e9059c34acacab88ed9e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17886, "upload_time": "2018-01-04T01:05:37", "url": "https://files.pythonhosted.org/packages/03/46/7effc9818b4bbcb550e897057fcade0e6191bc1937325f721659700ca316/Micro-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "402ada8296d71c34c2a5f113fd43b4df", "sha256": "cd78cf417abba3a7d25a2591690a88bd8a3dd3ea323969c6a7adccbad74826b1" }, "downloads": -1, "filename": "Micro-1.0.1.tar.gz", "has_sig": false, "md5_digest": "402ada8296d71c34c2a5f113fd43b4df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10774, "upload_time": "2018-01-04T01:05:39", "url": "https://files.pythonhosted.org/packages/fc/36/b3fd369f5f6d678af07964e23c7c8ca8fb6f1ae5f367c76d69d9f0ffd9ab/Micro-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "2a45bb4e30f381670fcd03ec8d85a829", "sha256": "91f5391a180acf9aa9beb529b806bfd827d4c612a6184d589bd1575ba10e4489" }, "downloads": -1, "filename": "Micro-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "2a45bb4e30f381670fcd03ec8d85a829", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 18411, "upload_time": "2018-06-08T04:47:54", "url": "https://files.pythonhosted.org/packages/1d/0c/8054c81fda268082ceacd2f04810bffea9f0f7b94a593273723401b5cf00/Micro-1.0.2-py3-none-any.whl" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "0d89a44b0bd3fdfaef1f6344fe656e68", "sha256": "ba47593e74bc216ba57bbc028a00a424403271b30d6fc15135020b8ed6198131" }, "downloads": -1, "filename": "Micro-2.0.0.tar.gz", "has_sig": false, "md5_digest": "0d89a44b0bd3fdfaef1f6344fe656e68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16416, "upload_time": "2018-07-18T07:21:46", "url": "https://files.pythonhosted.org/packages/3c/7f/7d5c26da8c1c47861e8e26759d98575d25c29775b37aff6fa9666a8794c3/Micro-2.0.0.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "f53b5246a631ccbbdb01bb3c41ca8398", "sha256": "06c16478861cbcac7483fd2879e5546135b587b6d21868590345422b98c7fdfb" }, "downloads": -1, "filename": "Micro-3.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f53b5246a631ccbbdb01bb3c41ca8398", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28133, "upload_time": "2019-03-13T22:28:13", "url": "https://files.pythonhosted.org/packages/00/e4/06dea67ffc02f26519be2caab06a124d133fc86c8ad30b160ec14e861bd5/Micro-3.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7618ab7a0721ebe157ea6419bcf0e80c", "sha256": "6a4ddb5b6ad53b09230a1c50aadec88420a422aeb73d66b5dd627449cf352df6" }, "downloads": -1, "filename": "Micro-3.0.0.tar.gz", "has_sig": false, "md5_digest": "7618ab7a0721ebe157ea6419bcf0e80c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24654, "upload_time": "2019-03-13T22:28:14", "url": "https://files.pythonhosted.org/packages/c6/57/b420634a888dd3a0b649a8d000815d293766e6460d5966ed1a22d648f1f4/Micro-3.0.0.tar.gz" } ], "3.1.0": [ { "comment_text": "", "digests": { "md5": "8cf75fb6837c289a192c5a9204d8233f", "sha256": "97490706a809186d1d5c2179b354946bb209ec5254b2555ec3e427251f581eb3" }, "downloads": -1, "filename": "Micro-3.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8cf75fb6837c289a192c5a9204d8233f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28357, "upload_time": "2019-03-16T18:31:33", "url": "https://files.pythonhosted.org/packages/57/9e/f91b445dc810c4759a49fb8fd63355a9f7e6d64e128f120ad086528507cd/Micro-3.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f135269f078ad6ef73e242af70cfee5c", "sha256": "ad9894d5bf2b66e7bfb7b702fb51716ee504a337c060b8b7b7647809b867fe13" }, "downloads": -1, "filename": "Micro-3.1.0.tar.gz", "has_sig": false, "md5_digest": "f135269f078ad6ef73e242af70cfee5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25239, "upload_time": "2019-03-16T18:31:35", "url": "https://files.pythonhosted.org/packages/68/6f/bab9e151ee8b146e941ba3a68e6ae50caa4217810ab3840e8316b567611c/Micro-3.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8cf75fb6837c289a192c5a9204d8233f", "sha256": "97490706a809186d1d5c2179b354946bb209ec5254b2555ec3e427251f581eb3" }, "downloads": -1, "filename": "Micro-3.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8cf75fb6837c289a192c5a9204d8233f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 28357, "upload_time": "2019-03-16T18:31:33", "url": "https://files.pythonhosted.org/packages/57/9e/f91b445dc810c4759a49fb8fd63355a9f7e6d64e128f120ad086528507cd/Micro-3.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f135269f078ad6ef73e242af70cfee5c", "sha256": "ad9894d5bf2b66e7bfb7b702fb51716ee504a337c060b8b7b7647809b867fe13" }, "downloads": -1, "filename": "Micro-3.1.0.tar.gz", "has_sig": false, "md5_digest": "f135269f078ad6ef73e242af70cfee5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25239, "upload_time": "2019-03-16T18:31:35", "url": "https://files.pythonhosted.org/packages/68/6f/bab9e151ee8b146e941ba3a68e6ae50caa4217810ab3840e8316b567611c/Micro-3.1.0.tar.gz" } ] }