Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

Commit

Permalink
Merge 9acc6d1 into 6a3d0c8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Dec 6, 2017
2 parents 6a3d0c8 + 9acc6d1 commit 2e4073a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions README.rst
Expand Up @@ -52,15 +52,16 @@ Then, create a pubsub client and a queue:

.. code:: python
from google.cloud import pubsub
from google.cloud import pubsub_v1
import psq
PROJECT_ID = 'your-project-id'
project = 'your-project-id'
client = pubsub.Client(project=PROJECT_ID)
publisher = pubsub_v1.PublisherClient()
subscriber = pubsub_v1.SubscriberClient()
q = psq.Queue(client)
q = psq.Queue(publisher, subscriber, project)
Now you can enqueue tasks:

Expand All @@ -74,17 +75,19 @@ In order to get task results, you have to configure storage:

.. code:: python
from google.cloud import pubsub
from google.cloud import pubsub_v1
from google.cloud import datastore
import psq
PROJECT_ID = 'your-project-id'
project = 'your-project-id'
ps_client = pubsub.Client(project=PROJECT_ID)
ds_client = datastore.Client(project=PROJECT_ID)
publisher = pubsub_v1.PublisherClient()
subscriber = pubsub_v1.SubscriberClient()
ds = datastore.Client()
q = psq.Queue(
ps_client,
publisher, subscriber, project,
storage=psq.DatastoreStorage(ds_client))
With storage configured, you can get the result of a task:
Expand All @@ -98,8 +101,8 @@ You can also define multiple queues:

.. code:: python
fast = psq.Queue(client, 'fast')
slow = psq.Queue(client, 'slow')
fast = psq.Queue(publisher, subscriber, project, 'fast')
slow = psq.Queue(publisher, subscriber, project, 'slow')
Things to note
--------------
Expand Down Expand Up @@ -166,7 +169,7 @@ server.

.. code:: python
broadcast_q = psq.BroadcastQueue(client)
broadcast_q = psq.BroadcastQueue(publisher, subscriber, project)
def restart_apache_task():
call(["apachectl", "restart"])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -23,7 +23,7 @@
setup(
name='psq',

version='0.5.0',
version='0.6.0',

description='A simple task queue using Google Cloud Pub/Sub',
long_description=long_description,
Expand Down

0 comments on commit 2e4073a

Please sign in to comment.