flask-kafka-python


Nameflask-kafka-python JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/cookieGeGe/flask-kafka-python
SummaryMake it easier to integrate flask with kafka
upload_time2023-03-13 07:39:41
maintainer
docs_urlNone
authorcookieGeGe
requires_python>=3.6
licenseMIT
keywords kafka consumer kafkaesque flask simple consumer flask style decorator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flask-kafka-python
flask-kafka-python

I refer to the [`flask_kafka`](https://github.com/NimzyMaina/flask_kafka) library and make some enhancements based on it:

- 
1. Add file locks to prevent flask from repeatedly listening in debug
2. Get config from flask app
3. Increase the registration topic monitoring interface, and support designated consumers at the same time
4. Support for multiple consumers

I hope you find this useful.

## Installation

This project has been commited to Pypi, can be installed by pip:
```shell
$ pip install flask-kafka-python
```

## Simple example

```python
from flask import Flask

from flask_kafka import FlaskKafka

app = Flask(__name__)

app.config["KAFKA_CONFIG"] = {
    "bootstrap_servers": ["172.31.2.20:32423"]
}

bus = FlaskKafka()
bus.init_app(app)


@app.route("/", methods=["get"])
def index():
    return "hello world! ----1"


@bus.topic_handler('kafka_demo')
def test_topic_handler(consumer, msg):
    print("consumed {} from test-topic".format(msg))


# or
# bus.add_topic_handler("kafka_demo", lambda con, msg: print(msg))


if __name__ == '__main__':
    bus.start()
    app.run(debug=True)

```


## License

```
MIT License

Copyright (c) 2023 cookieGeGe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cookieGeGe/flask-kafka-python",
    "name": "flask-kafka-python",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "kafka,consumer,kafkaesque,flask,simple,consumer,flask style,decorator",
    "author": "cookieGeGe",
    "author_email": "nimzy.maina@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/f4/67f5953006dc15af38fd75a19dd71c094bea8b7d9bd238575ad159715779/flask-kafka-python-0.0.2.tar.gz",
    "platform": "any",
    "description": "# flask-kafka-python\r\nflask-kafka-python\r\n\r\nI refer to the [`flask_kafka`](https://github.com/NimzyMaina/flask_kafka) library and make some enhancements based on it:\r\n\r\n- \r\n1. Add file locks to prevent flask from repeatedly listening in debug\r\n2. Get config from flask app\r\n3. Increase the registration topic monitoring interface, and support designated consumers at the same time\r\n4. Support for multiple consumers\r\n\r\nI hope you find this useful.\r\n\r\n## Installation\r\n\r\nThis project has been commited to Pypi, can be installed by pip:\r\n```shell\r\n$ pip install flask-kafka-python\r\n```\r\n\r\n## Simple example\r\n\r\n```python\r\nfrom flask import Flask\r\n\r\nfrom flask_kafka import FlaskKafka\r\n\r\napp = Flask(__name__)\r\n\r\napp.config[\"KAFKA_CONFIG\"] = {\r\n    \"bootstrap_servers\": [\"172.31.2.20:32423\"]\r\n}\r\n\r\nbus = FlaskKafka()\r\nbus.init_app(app)\r\n\r\n\r\n@app.route(\"/\", methods=[\"get\"])\r\ndef index():\r\n    return \"hello world! ----1\"\r\n\r\n\r\n@bus.topic_handler('kafka_demo')\r\ndef test_topic_handler(consumer, msg):\r\n    print(\"consumed {} from test-topic\".format(msg))\r\n\r\n\r\n# or\r\n# bus.add_topic_handler(\"kafka_demo\", lambda con, msg: print(msg))\r\n\r\n\r\nif __name__ == '__main__':\r\n    bus.start()\r\n    app.run(debug=True)\r\n\r\n```\r\n\r\n\r\n## License\r\n\r\n```\r\nMIT License\r\n\r\nCopyright (c) 2023 cookieGeGe\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Make it easier to integrate flask with kafka",
    "version": "0.0.2",
    "split_keywords": [
        "kafka",
        "consumer",
        "kafkaesque",
        "flask",
        "simple",
        "consumer",
        "flask style",
        "decorator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c28a72fcc236a5e23c7ac0cc5f9f505ef42ba089ca16470b1ddf313d4ce39872",
                "md5": "11aed7f5ff26f79e9fd2609a1c2212a0",
                "sha256": "28a4b8107b4a4274a20a08adb02ef00b2e1eb2f50503666d4344afb902448035"
            },
            "downloads": -1,
            "filename": "flask_kafka_python-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11aed7f5ff26f79e9fd2609a1c2212a0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6373,
            "upload_time": "2023-03-13T07:39:36",
            "upload_time_iso_8601": "2023-03-13T07:39:36.090620Z",
            "url": "https://files.pythonhosted.org/packages/c2/8a/72fcc236a5e23c7ac0cc5f9f505ef42ba089ca16470b1ddf313d4ce39872/flask_kafka_python-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2f467f5953006dc15af38fd75a19dd71c094bea8b7d9bd238575ad159715779",
                "md5": "ddfac31755407a854d68db02cb733e8f",
                "sha256": "eb6abedcb975692d7da205dfd41cc69b7d5152bb9d74db791ab2c6bf6818b56f"
            },
            "downloads": -1,
            "filename": "flask-kafka-python-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ddfac31755407a854d68db02cb733e8f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4548,
            "upload_time": "2023-03-13T07:39:41",
            "upload_time_iso_8601": "2023-03-13T07:39:41.021170Z",
            "url": "https://files.pythonhosted.org/packages/f2/f4/67f5953006dc15af38fd75a19dd71c094bea8b7d9bd238575ad159715779/flask-kafka-python-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-13 07:39:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "cookieGeGe",
    "github_project": "flask-kafka-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "flask-kafka-python"
}
        
Elapsed time: 0.04040s