Skip to content

PierreKieffer/pubsub-pytoolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

pip install .

Usage

Publisher

import json
from pubsub.op import publisher

data = {"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.

from pubsub.op import consumer

consumer.consume("PROJECT_ID", "SUBSCRIBER_ID", "private_key.json")

Releases

No releases published

Packages

No packages published

Languages