Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pierrekieffer/pubsub-pytoolbox
Google Cloud Platform Pub/Sub python toolbox
https://github.com/pierrekieffer/pubsub-pytoolbox
gcp-pubsub pubsub pubsub-interface pubsub-publisher pubsub-subscriber
Last synced: about 2 months ago
JSON representation
Google Cloud Platform Pub/Sub python toolbox
- Host: GitHub
- URL: https://github.com/pierrekieffer/pubsub-pytoolbox
- Owner: PierreKieffer
- License: bsd-2-clause
- Created: 2020-10-14T08:54:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-14T14:48:07.000Z (over 4 years ago)
- Last Synced: 2023-03-07T01:31:41.813Z (almost 2 years ago)
- Topics: gcp-pubsub, pubsub, pubsub-interface, pubsub-publisher, pubsub-subscriber
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pubsub-pytoolbox
Google Cloud Platform Pub/Sub toolbox## Prerequisities
- GCP project with a Pub/Sub up & running.
- GCP service account and the credential file `private_key.json` associated.## Install
```bash
pip install .
```## Usage
### Publisher
```python
import json
from pubsub.op import publisherdata = {"field1" : "value1", "field2" : "value2"}
event = json.dumps(data)publisher.publish("PROJECT_ID", "TOPIC_ID", "private_key.json", event)
```### Consumer
Start a background thread to receive messages from Pub/Sub and calls a callback with each message received.```python
from pubsub.op import consumerconsumer.consume("PROJECT_ID", "SUBSCRIBER_ID", "private_key.json")
```