{ "info": { "author": "Rob Blackbourn", "author_email": "rob.blackbourn@googlemail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# jetblack-messagebus-python3\n\n\n## Overview\n\nThis is a Python 3.7+ client for the [jetblack-messagebus](https://github.com/rob-blackbourn/jetblack-messagebus).\n\nIt follows the publish-subscribe pattern, and includes support for \"notification\" of\na subscription by another client. This allows it to provide data on-demand.\n\nSee the server documentation for more detailed information.\n\n## Example\n\nThe client below subscribes on feed \"TEST\" to topic \"FOO\" and prints out \nthe data it receives.\n\n```python\nimport asyncio\n\nfrom jetblack_messagebus import CallbackClient\n\nasync def on_data(user, host, feed, topic, data_packets, is_image):\n print(f'data: user=\"{user}\",host=\"{host}\",feed=\"{feed}\",topic=\"{topic}\",is_image={is_image}')\n if not data_packets:\n print(\"no data\")\n else:\n for packet in data_packets:\n message = packet.data.decode('utf8') if packet.data else None\n print(f'packet: entitlements={packet.entitlements},message={message}')\n\nasync def main():\n client = await CallbackClient.create('localhost', 9001)\n client.data_handlers.append(on_data)\n await client.add_subscription('TEST', 'FOO')\n await client.start()\n\nif __name__ == '__main__':\n asyncio.run(main())\n```\n\n## SSL\n\nTo create an SSL subscriber, pass in the ssl context.\n\n```python\nimport ssl\nfrom jetblack_messagebus import CallbackClient\n\n...\n\nasync def main():\n \"\"\"Start the demo\"\"\"\n ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)\n client = await CallbackClient.create('myhost.example.com', 9001, ssl=ssl_context)\n await client.add_subscription('TEST', 'FOO')\n await client.start()\n```\n\n## Authentication\n\nThe message bus currently supports the following authentication methods:\n\n- Password File\n- LDAP\n- JWT\n\n### Password File and LDAP\n\nBoth the password file and LDAP methods require a username and password. This\nis provided by the basic authenticator.\n\n```python\nimport ssl\nfrom jetblack_messagebus import CallbackClient\nfrom jetblack_messagebus.authentication import BasicAuthenticator\n\n...\n\nasync def main():\n authenticator = BasicAuthenticator(\"john.doe@example.com\", \"pa$$word\")\n ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)\n client = await CallbackClient.create(\n 'myhost.example.com',\n 9001,\n ssl=ssl_context,\n authenticator=authenticator\n )\n await client.add_subscription('TEST', 'FOO')\n await client.start()\n```\n\n### JWT\n\nJWT authentication requires a valid token to be passed by the client. This\nis provided by the token authenticator.\n\n```python\nimport ssl\nfrom jetblack_messagebus import CallbackClient\nfrom jetblack_messagebus.authentication import TokenAuthenticator\n\n...\n\nasync def main():\n authenticator = TokenAuthenticator(\n \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsIm5hbWUiOiJKb2huIERvZSIsImlhdCI6MTUxNjIzOTAyMiwiZXhwIjoxNTE3MTgzNTAxfQ.wLSGBcNUT8r1DqQvaBrrGY4NHiiVOpoxrgeoPsSsJkY\"\n )\n ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)\n client = await CallbackClient.create(\n 'myhost.example.com',\n 9001,\n ssl=ssl_context,\n authenticator=authenticator\n )\n await client.add_subscription('TEST', 'FOO')\n await client.start()\n```\n\n## Message handlers\n\nThere are three types of messages that can be received:\n\n- Data\n- Subscription notifications\n- Authorization requests.\n\n### Data\n\nA data handler looks like this:\n\n```python\n# A data handler.\nasync def on_data(\n user: str,\n host: str,\n feed: str,\n topic: str,\n data_packets: Optional[List[DataPacket]],\n is_image: bool\n) -> None:\n \"\"\"Called when data is received\"\"\"\n pass\n\n# Add the handler to the client.\nclient.data_handlers.append(on_data)\n# Remove the handler\nclient.data_handlers.remove(on_data)\n```\n\nThe data packets have two fields: `entitlements` and `data`.\n\nThe `entitlements` is a optional set of ints which express the entitlements that were\nrequired for the data to have been received.\n\nThe `data` is an optional `bytes` holding the encoded data. What this represents\nis agreed by the sender and receiver. For example it might be a simple string, some\nJSON text, or a protocol buffer.\n\n### Subscription notifications\n\nA subscription notification handler looks like this:\n\n```python\n# A notification handler.\nasync def on_notification(\n client_id: UUID,\n user: str,\n host: str,\n feed: str,\n topic: str,\n is_add: bool\n) -> None:\n \"\"\"Called for a notification\"\"\"\n pass\n\n# Add the handler to the client.\nclient.notification_handlers.append(on_notification)\n# Remove the handler\nclient.notification_handlers.remove(on_notification)\n```\n\n### Authorization requests\n\n```python\n# An authorization handler.\nasync def on_authorization(\n client_id: UUID,\n host: str,\n user: str,\n feed: str,\n topic: str\n) -> None:\n \"\"\"Called when authorization is requested\"\"\"\n pass\n\n# Add the handler to the client.\nclient._authorization_handlers.append(on_authorization)\n# Remove the handler\nclient._authorization_handlers.remove(on_authorization)\n```\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rob-blackbourn/jetblack-messagebus-python3", "keywords": "", "license": "Apache-2.0", "maintainer": "Rob Blackbourn", "maintainer_email": "rob.blackbourn@googlemail.com", "name": "jetblack-messagebus-python3", "package_url": "https://pypi.org/project/jetblack-messagebus-python3/", "platform": "", "project_url": "https://pypi.org/project/jetblack-messagebus-python3/", "project_urls": { "Homepage": "https://github.com/rob-blackbourn/jetblack-messagebus-python3", "Repository": "https://github.com/rob-blackbourn/jetblack-messagebus-python3" }, "release_url": "https://pypi.org/project/jetblack-messagebus-python3/4.1.1/", "requires_dist": null, "requires_python": ">=3.7,<4.0", "summary": "A python3 client for jetblack-messagebus", "version": "4.1.1", "yanked": false, "yanked_reason": null }, "last_serial": 6007373, "releases": { "2.2.1": [ { "comment_text": "", "digests": { "md5": "fce539de71e6b5411bc53f8336a9d8d3", "sha256": "e45d015aafaaa47d81bcca7ff013512b51f682f23330b1ed947870be0132fa00" }, "downloads": -1, "filename": "jetblack_messagebus_python3-2.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "fce539de71e6b5411bc53f8336a9d8d3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 16758, "upload_time": "2019-09-12T07:02:34", "upload_time_iso_8601": "2019-09-12T07:02:34.410911Z", "url": "https://files.pythonhosted.org/packages/3c/f4/58f158cdbf2f1db235b6c7ee783bb62a8d4fe84cac5637dd6d9be6d2bfbc/jetblack_messagebus_python3-2.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "d454d950fc4c19aabb273557412f9dbf", "sha256": "5d0f6d9b3c995d36e0a43245a6181c690d6c7197d89ad25860e12806c4edeb11" }, "downloads": -1, "filename": "jetblack-messagebus-python3-2.2.1.tar.gz", "has_sig": false, "md5_digest": "d454d950fc4c19aabb273557412f9dbf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 12013, "upload_time": "2019-09-12T07:02:33", "upload_time_iso_8601": "2019-09-12T07:02:33.008176Z", "url": "https://files.pythonhosted.org/packages/6f/a8/d132afbaa3352f923b0b4760b15abe13790454a62bb923f291956a47a838/jetblack-messagebus-python3-2.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "1b20b4149a731a24a298598b99c9261c", "sha256": "14f88c4a6859f371ec25f2045a4b7738031c2edfa12812476e15295e4a1a2dbe" }, "downloads": -1, "filename": "jetblack_messagebus_python3-3.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1b20b4149a731a24a298598b99c9261c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 18081, "upload_time": "2019-09-12T11:25:09", "upload_time_iso_8601": "2019-09-12T11:25:09.215258Z", "url": "https://files.pythonhosted.org/packages/6c/28/e7059e3af4cbebfa25ac63aae21cafa5ffe8aaea40477108a6889797e878/jetblack_messagebus_python3-3.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3e9f26e4a4567b7b4671ca8eef26376c", "sha256": "34dae03fd4e2f8798aee0910ac6b3b805b5f676ce128909a9d18e913cd490f8d" }, "downloads": -1, "filename": "jetblack-messagebus-python3-3.0.0.tar.gz", "has_sig": false, "md5_digest": "3e9f26e4a4567b7b4671ca8eef26376c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14682, "upload_time": "2019-09-12T11:25:07", "upload_time_iso_8601": "2019-09-12T11:25:07.717891Z", "url": "https://files.pythonhosted.org/packages/25/48/c3f5e31db75e21b24415641ca38ea74af066f1aa72b52ffd768c12dba161/jetblack-messagebus-python3-3.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "3.0.1": [ { "comment_text": "", "digests": { "md5": "155f7ff80f11ee1d005911e111bd1129", "sha256": "b7331909c5aa59d18284fd187fe6ab2917d518118ceb7f4abd1302f8297a475e" }, "downloads": -1, "filename": "jetblack_messagebus_python3-3.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "155f7ff80f11ee1d005911e111bd1129", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 18080, "upload_time": "2019-09-13T06:51:25", "upload_time_iso_8601": "2019-09-13T06:51:25.278635Z", "url": "https://files.pythonhosted.org/packages/f3/06/61a0d252cbaeb28ecbcdb423c3861cea4fb220cbf33a593590024eb63a37/jetblack_messagebus_python3-3.0.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "77cbaf01f221f8863c2a7861a10ee5da", "sha256": "22c629c464f30b30b11c6997ba964eeae377ce8bb732f6160a0926b2128da2a8" }, "downloads": -1, "filename": "jetblack-messagebus-python3-3.0.1.tar.gz", "has_sig": false, "md5_digest": "77cbaf01f221f8863c2a7861a10ee5da", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14683, "upload_time": "2019-09-13T06:51:23", "upload_time_iso_8601": "2019-09-13T06:51:23.497509Z", "url": "https://files.pythonhosted.org/packages/08/ee/ec9bb9e70cb4fe8ad8bd62eb14e85c3bb5945508545004fc97fadca05f87/jetblack-messagebus-python3-3.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "3.0.2": [ { "comment_text": "", "digests": { "md5": "50f4235d7cbb70ef23201948fa04d7e5", "sha256": "d06cb3a43a5cf8110569122e8d2f371082cf0b72ad9c19cf03f08acda00923b5" }, "downloads": -1, "filename": "jetblack_messagebus_python3-3.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "50f4235d7cbb70ef23201948fa04d7e5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 18144, "upload_time": "2019-09-13T09:45:21", "upload_time_iso_8601": "2019-09-13T09:45:21.555659Z", "url": "https://files.pythonhosted.org/packages/7b/64/9a51ad95c6a4dd9ac6650bfa3771df322c60a372131c916f925e8ebca2f9/jetblack_messagebus_python3-3.0.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3d0410fa038b287187ffd0e0edb16f43", "sha256": "1bb9253666eced27ef942d738e1c0da536c935c3a7080d9448aa7242eb3c785f" }, "downloads": -1, "filename": "jetblack-messagebus-python3-3.0.2.tar.gz", "has_sig": false, "md5_digest": "3d0410fa038b287187ffd0e0edb16f43", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14717, "upload_time": "2019-09-13T09:45:20", "upload_time_iso_8601": "2019-09-13T09:45:20.167665Z", "url": "https://files.pythonhosted.org/packages/52/5a/cf77a6ade578078f5a7752a102763d15ad825ab15562adafffd0c0e70d38/jetblack-messagebus-python3-3.0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "3.0.3": [ { "comment_text": "", "digests": { "md5": "63b7bd5ebb02e8d28cf60cc2b5da260a", "sha256": "6f7b8a175b6e08460fbfed0a476faaee9547302a49e7d68ddc239aca3fea3cdc" }, "downloads": -1, "filename": "jetblack_messagebus_python3-3.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "63b7bd5ebb02e8d28cf60cc2b5da260a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 17277, "upload_time": "2019-09-13T09:59:47", "upload_time_iso_8601": "2019-09-13T09:59:47.718861Z", "url": "https://files.pythonhosted.org/packages/c9/32/b768ebafe881bf6ea4f7bcb94296ba8a692dbaec48256a7351bb47306397/jetblack_messagebus_python3-3.0.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "8fdfe8984992d47e6872d2d45628b19d", "sha256": "d5ec7a291a746780ca9142786ceb8d98d92fef7209702853a37b7376b6b17ad8" }, "downloads": -1, "filename": "jetblack-messagebus-python3-3.0.3.tar.gz", "has_sig": false, "md5_digest": "8fdfe8984992d47e6872d2d45628b19d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14660, "upload_time": "2019-09-13T09:59:45", "upload_time_iso_8601": "2019-09-13T09:59:45.941123Z", "url": "https://files.pythonhosted.org/packages/e7/7b/aafaea274db25ae2ced0a381ff9ba6e3c34f2a0372fc115f719b36ed7081/jetblack-messagebus-python3-3.0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "4.0.0": [ { "comment_text": "", "digests": { "md5": "50209d5aaa6b0c456b579bce9914c6e3", "sha256": "1fbf9f7ef2aa92c7556adfa3b36cb1f04ad93ebad7e47a7ea1e1206eaa5b9f36" }, "downloads": -1, "filename": "jetblack_messagebus_python3-4.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "50209d5aaa6b0c456b579bce9914c6e3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 17470, "upload_time": "2019-09-25T08:46:01", "upload_time_iso_8601": "2019-09-25T08:46:01.129993Z", "url": "https://files.pythonhosted.org/packages/ad/0e/d6090b28f10460c0096235f32db0304028c37c855d527da1c40c82d0b196/jetblack_messagebus_python3-4.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "94d4342d63a819674d5f2612a0b756c2", "sha256": "2e46a27969103ea99e54e44bc3706604a0f9cc2c85fa88dee8a7ef55d27bd18a" }, "downloads": -1, "filename": "jetblack-messagebus-python3-4.0.0.tar.gz", "has_sig": false, "md5_digest": "94d4342d63a819674d5f2612a0b756c2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14725, "upload_time": "2019-09-25T08:45:58", "upload_time_iso_8601": "2019-09-25T08:45:58.826797Z", "url": "https://files.pythonhosted.org/packages/d8/10/61b52f398f44f6f2a7c6b8833d3e3eee1a8301a54910a07b4c350baa8940/jetblack-messagebus-python3-4.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "4.1.0": [ { "comment_text": "", "digests": { "md5": "634f45a4d672546843652257aa4c6e41", "sha256": "9bdfb8a132af07e13054d64bccb0dab48a86a12f399c6e8beafbb5f86fc38e4f" }, "downloads": -1, "filename": "jetblack_messagebus_python3-4.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "634f45a4d672546843652257aa4c6e41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 17785, "upload_time": "2019-09-26T10:10:28", "upload_time_iso_8601": "2019-09-26T10:10:28.208849Z", "url": "https://files.pythonhosted.org/packages/a6/44/8cf2f37cc2dae2bb3e980006f414d5df0984fdf4f4876222f19710cf3852/jetblack_messagebus_python3-4.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "6428483c20ad11da3962aff8e5f1e24a", "sha256": "a532e551d1ad8af549075aa49e3a2e1a68f47725fa40115008ad6798ad7f1bfc" }, "downloads": -1, "filename": "jetblack-messagebus-python3-4.1.0.tar.gz", "has_sig": false, "md5_digest": "6428483c20ad11da3962aff8e5f1e24a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 14856, "upload_time": "2019-09-26T10:10:26", "upload_time_iso_8601": "2019-09-26T10:10:26.638978Z", "url": "https://files.pythonhosted.org/packages/ba/5a/ab027f7536276cafb7c44672cdb2d73ba0c85d4e09041f46057117136d0a/jetblack-messagebus-python3-4.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "4.1.1": [ { "comment_text": "", "digests": { "md5": "75a922dceadd26c3d0a54e63bbb8d9a1", "sha256": "897356620170340ac06cc10b02579f6520610903c29c7ae5c598040a28ef2fc6" }, "downloads": -1, "filename": "jetblack_messagebus_python3-4.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "75a922dceadd26c3d0a54e63bbb8d9a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 18243, "upload_time": "2019-10-21T13:42:08", "upload_time_iso_8601": "2019-10-21T13:42:08.661922Z", "url": "https://files.pythonhosted.org/packages/ec/57/f74d7b823e99fcd4dc7009b69123cf24d08b9059d34605ae5691f315b129/jetblack_messagebus_python3-4.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a9b608e39c9a0fb3cfc924e9cef6ac91", "sha256": "260b5a1b52d18e448f87cb376f0eae18f49baff358a2e525450a5bf9051c6925" }, "downloads": -1, "filename": "jetblack-messagebus-python3-4.1.1.tar.gz", "has_sig": false, "md5_digest": "a9b608e39c9a0fb3cfc924e9cef6ac91", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 15332, "upload_time": "2019-10-21T13:42:06", "upload_time_iso_8601": "2019-10-21T13:42:06.115550Z", "url": "https://files.pythonhosted.org/packages/26/11/30ebe4de31c3629906c6708285ac212105d96a05e293b357334e310a7327/jetblack-messagebus-python3-4.1.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "75a922dceadd26c3d0a54e63bbb8d9a1", "sha256": "897356620170340ac06cc10b02579f6520610903c29c7ae5c598040a28ef2fc6" }, "downloads": -1, "filename": "jetblack_messagebus_python3-4.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "75a922dceadd26c3d0a54e63bbb8d9a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 18243, "upload_time": "2019-10-21T13:42:08", "upload_time_iso_8601": "2019-10-21T13:42:08.661922Z", "url": "https://files.pythonhosted.org/packages/ec/57/f74d7b823e99fcd4dc7009b69123cf24d08b9059d34605ae5691f315b129/jetblack_messagebus_python3-4.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a9b608e39c9a0fb3cfc924e9cef6ac91", "sha256": "260b5a1b52d18e448f87cb376f0eae18f49baff358a2e525450a5bf9051c6925" }, "downloads": -1, "filename": "jetblack-messagebus-python3-4.1.1.tar.gz", "has_sig": false, "md5_digest": "a9b608e39c9a0fb3cfc924e9cef6ac91", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 15332, "upload_time": "2019-10-21T13:42:06", "upload_time_iso_8601": "2019-10-21T13:42:06.115550Z", "url": "https://files.pythonhosted.org/packages/26/11/30ebe4de31c3629906c6708285ac212105d96a05e293b357334e310a7327/jetblack-messagebus-python3-4.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }