{ "info": { "author": "Microsoft Corporation", "author_email": "azpysdkhelp@microsoft.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# Azure EventHubs Checkpoint Store client library for Python using Storage Blobs\n\nAzure EventHubs Checkpoint Store is used for storing checkpoints while processing events from Azure Event Hubs.\nThis Checkpoint Store package works as a plug-in package to `EventProcessor`. It uses Azure Storage Blob as the persistent store for maintaining checkpoints and partition ownership information.\n\n[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs-checkpointstoreblob-aio) | [Package (PyPi)](https://pypi.org/project/azure-eventhub-checkpointstoreblob-aio/) | [API reference documentation](https://azure.github.io/azure-sdk-for-python/ref/azure.eventhub.extensions.html) | [Azure Eventhubs documentation](https://docs.microsoft.com/en-us/azure/event-hubs/) | [Azure Storage documentation](https://docs.microsoft.com/en-us/azure/storage/)\n\n## Getting started\n\n### Install the package\n\n```\n$ pip install --pre azure-eventhub-checkpointstoreblob-aio\n```\n\n**Prerequisites**\n\n- Python 3.5.3 or later.\n- **Microsoft Azure Subscription:** To use Azure services, including Azure Event Hubs, you'll need a subscription. If you do not have an existing Azure account, you may sign up for a free trial or use your MSDN subscriber benefits when you [create an account](https://azure.microsoft.com/en-us/).\n\n- **Event Hubs namespace with an Event Hub:** To interact with Azure Event Hubs, you'll also need to have a namespace and Event Hub available. If you are not familiar with creating Azure resources, you may wish to follow the step-by-step guide for [creating an Event Hub using the Azure portal](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create). There, you can also find detailed instructions for using the Azure CLI, Azure PowerShell, or Azure Resource Manager (ARM) templates to create an Event Hub.\n\n- **Azure Storage Account:** You'll need to have an Azure Storage Account and create a Azure Blob Storage Block Container to store the checkpoint data with blobs. You may follow the guide [creating an Azure Block Blob Storage Account](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-create-account-block-blob).\n\n## Key concepts\n\n### Checkpointing\n\nCheckpointing is a process by which readers mark or commit their position within a partition event sequence. \nCheckpointing is the responsibility of the consumer and occurs on a per-partition basis within a consumer group. \nThis responsibility means that for each consumer group, each partition reader must keep track of its current position \nin the event stream, and can inform the service when it considers the data stream complete. If a reader disconnects from\na partition, when it reconnects it begins reading at the checkpoint that was previously submitted by the last reader of\nthat partition in that consumer group. When the reader connects, it passes the offset to the event hub to specify the \nlocation at which to start reading. In this way, you can use checkpointing to both mark events as \"complete\" by \ndownstream applications, and to provide resiliency if a failover between readers running on different machines occurs. \nIt is possible to return to older data by specifying a lower offset from this checkpointing process. Through this \nmechanism, checkpointing enables both failover resiliency and event stream replay.\n\n### Offsets & sequence numbers\nBoth offset & sequence number refer to the position of an event within a partition. You can think of them as a \nclient-side cursor. The offset is a byte numbering of the event. The offset/sequence number enables an event consumer \n(reader) to specify a point in the event stream from which they want to begin reading events. You can specify a \ntimestamp such that you receive events enqueued only after the given timestamp. Consumers are responsible for \nstoring their own offset values outside of the Event Hubs service. Within a partition, each event includes an offset, \nsequence number and the timestamp of when it was enqueued.\n\n## Examples\n- [Create an Azure Storage Blobs `ContainerClient`](#create-an-azure-storage-blobs-containerclient)\n- [Create an Azure EventHubs `EventHubClient`](#create-an-eventhubclient)\n- [Consume events using an `EventProessor` that uses a `BlobPartitionManager`](#consume-events-using-an-eventprocessor-that-uses-a-blobpartitionmanager-to-do-checkpointing)\n\n### Create an Azure Storage Blobs `ContainerClient`\nThe easiest way to create a `ContainerClient` is to use a connection string.\n```python\nfrom azure.storage.blob.aio import ContainerClient\ncontainer_client = ContainerClient.from_connection_string(\"my_storageacount_connection_string\", \"mycontainer\")\n```\nFor other ways of creating a `ContainerClient`, go to [Blob Storage library](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob) for more details.\n\n### Create an `EventHubClient`\nThe easiest way to create a `EventHubClient` is to use a connection string.\n```python\nfrom azure.eventhub.aio import EventHubClient\neventhub_client = EventHubClient.from_connection_string(\"my_eventhub_namespace_connection_string\", event_hub_path=\"myeventhub\")\n```\nFor other ways of creating a `EventHubClient`, refer to [EventHubs library](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs) for more details.\n\n### Consume events using an `EventProcessor` that uses a `BlobPartitionManager` to do checkpointing\n```python\nimport asyncio\n\nfrom azure.eventhub.aio import EventHubClient\nfrom azure.eventhub.aio.eventprocessor import EventProcessor, PartitionProcessor\nfrom azure.storage.blob.aio import ContainerClient\nfrom azure.eventhub.extensions.checkpointstoreblobaio import BlobPartitionManager\n\neventhub_connection_str = '<< CONNECTION STRING FOR THE EVENT HUBS NAMESPACE >>'\nstorage_container_connection_str = '<< CONNECTION STRING OF THE STORAGE >>'\nstorage_container_name = '<< STORAGE CONTAINER NAME>>'\n\nclass MyPartitionProcessor(PartitionProcessor):\n async def process_events(self, events, partition_context):\n if events:\n # write your code here to process events\n # save checkpoint to the data store\n await partition_context.update_checkpoint(events[-1].offset, events[-1].sequence_number)\n\nasync def main():\n eventhub_client = EventHubClient.from_connection_string(eventhub_connection_str, receive_timeout=5, retry_total=3)\n storage_container_client = ContainerClient.from_connection_string(storage_container_connection_str, storage_container_name)\n partition_manager = BlobPartitionManager(storage_container_client) # use the BlobPartitonManager to save\n event_processor = EventProcessor(eventhub_client, \"$default\", MyPartitionProcessor, partition_manager) \n async with storage_container_client:\n asyncio.ensure_future(event_processor.start())\n await asyncio.sleep(60) # run for a while\n await event_processor.stop()\n\nif __name__ == '__main__':\n loop = asyncio.get_event_loop()\n loop.run_until_complete(main())\n```\n\n## Troubleshooting\n\n### General\nEnabling logging will be helpful to do trouble shooting.\nRefer to [Logging](#logging) to enable loggers for related libraries.\n\n## Next steps\n\n### Examples\n- [./examples/eventprocessor/event_processor_blob_storage_example.py](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/eventhub/azure-eventhubs-checkpointstoreblob-aio/examples/event_processor_blob_storage_example.py) - event processor with blob partition manager example\n\n### Documentation\n\nReference documentation is available at https://azure.github.io/azure-sdk-for-python/ref/azure.eventhub.extensions.html.\n\n### Logging\n\n- Enable `azure.eventhub.extensions.checkpointstoreblobaio` logger to collect traces from the library.\n- Enable `azure.eventhub.aio.eventprocessor` logger to collect traces from package eventprocessor of the azure-eventhub library.\n- Enable `azure.eventhub` logger to collect traces from the main azure-eventhub library.\n- Enable `azure.storage.blob` logger to collect traces from azure storage blob library.\n- Enable `uamqp` logger to collect traces from the underlying uAMQP library.\n- Enable AMQP frame level trace by setting `network_tracing=True` when creating the client.\n\n### Provide Feedback\n\nIf you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project.\n\n## Contributing\n\nThis project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python/sdk/eventhub/azure-eventhubs-checkpointstoreblob-aio/README.png)\n\n\n# Release History\n\n## 1.0.0b4 (2019-10-09)\nThis release has trivial internal changes only. No feature changes.\n\n## 1.0.0b1 (2019-09-10)\n\n**New features**\n\n- `BlobPartitionManager` that uses Azure Blob Storage Block Blob to store EventProcessor checkpoint data\n\n![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python/sdk/eventhub/azure-eventhubs-checkpointstoreblob-aio/HISTORY.png)\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/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs-checkpointerblob-aio", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "azure-eventhub-checkpointstoreblob-aio", "package_url": "https://pypi.org/project/azure-eventhub-checkpointstoreblob-aio/", "platform": "", "project_url": "https://pypi.org/project/azure-eventhub-checkpointstoreblob-aio/", "project_urls": { "Homepage": "https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/eventhub/azure-eventhubs-checkpointerblob-aio" }, "release_url": "https://pypi.org/project/azure-eventhub-checkpointstoreblob-aio/1.0.0b4/", "requires_dist": [ "azure-storage-blob (<=12.0.0b4,>=12.0.0b2)", "azure-eventhub (<6.0.0,>=5.0.0b3)", "aiohttp (<4.0,>=3.0)" ], "requires_python": ">=3.5.3", "summary": "Microsoft Azure Event Hubs checkpointer implementation with Blob Storage Client Library for Python", "version": "1.0.0b4" }, "last_serial": 5947315, "releases": { "1.0.0b1": [ { "comment_text": "", "digests": { "md5": "ff333b0216487a58aff2a48b7a27ecdd", "sha256": "0a00d60e48b2fa59be633d86d903bee8aa9182ba90b35619fc701970740a387d" }, "downloads": -1, "filename": "azure_eventhub_checkpointstoreblob_aio-1.0.0b1-py3-none-any.whl", "has_sig": false, "md5_digest": "ff333b0216487a58aff2a48b7a27ecdd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.3", "size": 8275, "upload_time": "2019-09-12T21:19:41", "url": "https://files.pythonhosted.org/packages/f6/65/425e68675aaaf3ce0bc9c39ef7dffbcf5732ad8b3177244ccfdc2a8ff194/azure_eventhub_checkpointstoreblob_aio-1.0.0b1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2bc0c3816f78a9beccbb7defdd9c661b", "sha256": "8d3dd5a0e6d808675bfa31089c2ae22005d59758a878ca825cba904614880cf4" }, "downloads": -1, "filename": "azure-eventhub-checkpointstoreblob-aio-1.0.0b1.zip", "has_sig": false, "md5_digest": "2bc0c3816f78a9beccbb7defdd9c661b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.3", "size": 20267, "upload_time": "2019-09-12T21:19:46", "url": "https://files.pythonhosted.org/packages/c2/97/9744d13fabb07a7bf4aeffcbf9e5b128ab0f561de41e51c9ec6c05983806/azure-eventhub-checkpointstoreblob-aio-1.0.0b1.zip" } ], "1.0.0b4": [ { "comment_text": "", "digests": { "md5": "3dc9c423ccb581c20a47c4445d50c7cd", "sha256": "65605d2b43e2d69184284838f4aaf3a07abc3868eeebb3e8ba6542541a589e9a" }, "downloads": -1, "filename": "azure_eventhub_checkpointstoreblob_aio-1.0.0b4-py3-none-any.whl", "has_sig": false, "md5_digest": "3dc9c423ccb581c20a47c4445d50c7cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.3", "size": 8314, "upload_time": "2019-10-09T01:11:53", "url": "https://files.pythonhosted.org/packages/e9/57/05f474e53e4f404ae4523deb58da6d6656bd3dd958b2f8e6d486306ba628/azure_eventhub_checkpointstoreblob_aio-1.0.0b4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17eae2aebebfc40075cfe4bef464d0a6", "sha256": "2fbe13d50457206ec3726c08b1327d94628119b4f48080025727e0d2606b234b" }, "downloads": -1, "filename": "azure-eventhub-checkpointstoreblob-aio-1.0.0b4.zip", "has_sig": false, "md5_digest": "17eae2aebebfc40075cfe4bef464d0a6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.3", "size": 20386, "upload_time": "2019-10-09T01:11:55", "url": "https://files.pythonhosted.org/packages/13/97/6f701367e176f8e2e3ab5d9b57497a09b6692f1da3951bac4413ddd012c2/azure-eventhub-checkpointstoreblob-aio-1.0.0b4.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3dc9c423ccb581c20a47c4445d50c7cd", "sha256": "65605d2b43e2d69184284838f4aaf3a07abc3868eeebb3e8ba6542541a589e9a" }, "downloads": -1, "filename": "azure_eventhub_checkpointstoreblob_aio-1.0.0b4-py3-none-any.whl", "has_sig": false, "md5_digest": "3dc9c423ccb581c20a47c4445d50c7cd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5.3", "size": 8314, "upload_time": "2019-10-09T01:11:53", "url": "https://files.pythonhosted.org/packages/e9/57/05f474e53e4f404ae4523deb58da6d6656bd3dd958b2f8e6d486306ba628/azure_eventhub_checkpointstoreblob_aio-1.0.0b4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17eae2aebebfc40075cfe4bef464d0a6", "sha256": "2fbe13d50457206ec3726c08b1327d94628119b4f48080025727e0d2606b234b" }, "downloads": -1, "filename": "azure-eventhub-checkpointstoreblob-aio-1.0.0b4.zip", "has_sig": false, "md5_digest": "17eae2aebebfc40075cfe4bef464d0a6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.3", "size": 20386, "upload_time": "2019-10-09T01:11:55", "url": "https://files.pythonhosted.org/packages/13/97/6f701367e176f8e2e3ab5d9b57497a09b6692f1da3951bac4413ddd012c2/azure-eventhub-checkpointstoreblob-aio-1.0.0b4.zip" } ] }