Name | aiosfpubsub JSON |
Version |
0.0.6
JSON |
| download |
home_page | None |
Summary | An async Python gRPC client for the Salesforce PubSub API. |
upload_time | 2024-06-29 18:52:41 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
sf
salesforce
pubsub
pub/sub
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# aiosfpubsub
An async Python gRPC client for the Salesforce Pub/Sub API.
https://github.com/forcedotcom/pub-sub-api/blob/main/pubsub_api.proto
# install
```bash
pip install aiosfpubsub
```
# usage
```python
import asyncio
from aiosfpubsub import Client
from datetime import datetime
def callback(event, client):
"""
This is a callback that gets passed to the `Client.subscribe()` method.
When no events are received within a certain time period, the API's subscribe
method sends keepalive messages and the latest replay ID through this callback.
"""
if event.events:
print("Number of events received in FetchResponse: ", len(event.events))
for evt in event.events:
# Get the event payload and schema, then decode the payload
payload_bytes = evt.event.payload
json_schema = client.get_schema_json(evt.event.schema_id)
decoded_event = client.decode(json_schema, payload_bytes)
print(decoded_event)
else:
print(f"[{datetime.now():%Y-%m-%d %H:%M:%S}] The subscription is active.")
async def main():
client = Client(**{
"url": "https://login.salesforce.com",
"username": "myuser",
"password": "mypass",
"grpc_host": "api.pubsub.salesforce.com",
"grpc_port": 7443,
"api_version": "57.0"
})
client.auth()
await client.subscribe(
topic="/event/My_Event__e",
replay_type="EARLIEST",
replay_id=None,
num_requested=10,
callback=callback
)
if __name__ == "__main__":
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "aiosfpubsub",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "sf, salesforce, pubsub, pub/sub",
"author": null,
"author_email": "Benton Snyder <benton@bensnyde.me>",
"download_url": "https://files.pythonhosted.org/packages/fc/00/058caa7a9a0edf0c662ae5d7e5827367fe7e47ad78f3eacd0b02d2538a4d/aiosfpubsub-0.0.6.tar.gz",
"platform": null,
"description": "# aiosfpubsub\r\nAn async Python gRPC client for the Salesforce Pub/Sub API.\r\n\r\nhttps://github.com/forcedotcom/pub-sub-api/blob/main/pubsub_api.proto\r\n\r\n# install\r\n```bash\r\npip install aiosfpubsub\r\n```\r\n\r\n# usage \r\n```python\r\nimport asyncio\r\nfrom aiosfpubsub import Client\r\nfrom datetime import datetime \r\n\r\n\r\ndef callback(event, client):\r\n \"\"\"\r\n This is a callback that gets passed to the `Client.subscribe()` method.\r\n When no events are received within a certain time period, the API's subscribe\r\n method sends keepalive messages and the latest replay ID through this callback.\r\n \"\"\"\r\n if event.events:\r\n print(\"Number of events received in FetchResponse: \", len(event.events))\r\n\r\n for evt in event.events:\r\n # Get the event payload and schema, then decode the payload\r\n payload_bytes = evt.event.payload\r\n json_schema = client.get_schema_json(evt.event.schema_id)\r\n decoded_event = client.decode(json_schema, payload_bytes)\r\n print(decoded_event)\r\n else:\r\n print(f\"[{datetime.now():%Y-%m-%d %H:%M:%S}] The subscription is active.\")\r\n\r\nasync def main():\r\n client = Client(**{\r\n \"url\": \"https://login.salesforce.com\",\r\n \"username\": \"myuser\",\r\n \"password\": \"mypass\",\r\n \"grpc_host\": \"api.pubsub.salesforce.com\",\r\n \"grpc_port\": 7443,\r\n \"api_version\": \"57.0\"\r\n })\r\n client.auth()\r\n await client.subscribe(\r\n topic=\"/event/My_Event__e\",\r\n replay_type=\"EARLIEST\",\r\n replay_id=None,\r\n num_requested=10,\r\n callback=callback\r\n )\r\n\r\nif __name__ == \"__main__\":\r\n asyncio.run(main())\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "An async Python gRPC client for the Salesforce PubSub API.",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/bensnyde/aiosfpubsub",
"Issues": "https://github.com/bensnyde/aiosfpubsub/issues"
},
"split_keywords": [
"sf",
" salesforce",
" pubsub",
" pub/sub"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "283510229c46f98c3ac1ab04ff96316eda257261513ed7915ac908d974dd8662",
"md5": "4b4934d40b270e8ba244ecaa2dbb71d1",
"sha256": "e0d7ccfeb377941eb11846ba5a6a33b3ce81ac39c149c1d9b5da78f674c9bd3a"
},
"downloads": -1,
"filename": "aiosfpubsub-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4b4934d40b270e8ba244ecaa2dbb71d1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11330,
"upload_time": "2024-06-29T18:52:40",
"upload_time_iso_8601": "2024-06-29T18:52:40.175181Z",
"url": "https://files.pythonhosted.org/packages/28/35/10229c46f98c3ac1ab04ff96316eda257261513ed7915ac908d974dd8662/aiosfpubsub-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fc00058caa7a9a0edf0c662ae5d7e5827367fe7e47ad78f3eacd0b02d2538a4d",
"md5": "6617b5ab90e46d94fb921be1dfd7d4f4",
"sha256": "3933a426ca6377aff0c767da87b43d18f33c974dc750d55e12823f138959a353"
},
"downloads": -1,
"filename": "aiosfpubsub-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "6617b5ab90e46d94fb921be1dfd7d4f4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12545,
"upload_time": "2024-06-29T18:52:41",
"upload_time_iso_8601": "2024-06-29T18:52:41.502837Z",
"url": "https://files.pythonhosted.org/packages/fc/00/058caa7a9a0edf0c662ae5d7e5827367fe7e47ad78f3eacd0b02d2538a4d/aiosfpubsub-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-29 18:52:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bensnyde",
"github_project": "aiosfpubsub",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"tox": true,
"lcname": "aiosfpubsub"
}