google-cloud-pubsub


Namegoogle-cloud-pubsub JSON
Version 0.34.0 PyPI version JSON
download
home_pagehttps://github.com/GoogleCloudPlatform/google-cloud-python
SummaryGoogle Cloud Pub/Sub API client library
upload_time2018-04-27 22:44:43
maintainer
docs_urlNone
authorGoogle LLC
requires_python
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Python Client for Google Cloud Pub / Sub
========================================

    Python idiomatic client for `Google Cloud Pub / Sub`_

.. _Google Cloud Pub / Sub: https://cloud.google.com/pubsub/docs

|pypi| |versions|

-  `Documentation`_

.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/pubsub/

Quick Start
-----------

.. code-block:: console

    $ pip install --upgrade google-cloud-pubsub

For more information on setting up your Python development environment,
such as installing ``pip`` and ``virtualenv`` on your system, please refer
to `Python Development Environment Setup Guide`_ for Google Cloud Platform.

.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup

Authentication
--------------

With ``google-cloud-python`` we try to make authentication as painless as
possible. Check out the `Authentication section`_ in our documentation to
learn more. You may also find the `authentication document`_ shared by all
the ``google-cloud-*`` libraries to be helpful.

.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html
.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication

Using the API
-------------

Google `Cloud Pub/Sub`_ (`Pub/Sub API docs`_) is designed to provide reliable,
many-to-many, asynchronous messaging between applications. Publisher
applications can send messages to a ``topic`` and other applications can
subscribe to that topic to receive the messages. By decoupling senders and
receivers, Google Cloud Pub/Sub allows developers to communicate between
independently written applications.

.. _Cloud Pub/Sub: https://cloud.google.com/pubsub/docs
.. _Pub/Sub API docs: https://cloud.google.com/pubsub/docs/reference/rest/

See the ``google-cloud-python`` API `Pub/Sub documentation`_ to learn how to connect
to Cloud Pub/Sub using this Client Library.

.. _Pub/Sub documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/index.html


Publishing
----------

To publish data to Cloud Pub/Sub you must create a topic, and then publish
messages to it

.. code-block:: python

    import os
    from google.cloud import pubsub

    publisher = pubsub.PublisherClient()
    topic_name = 'projects/{project_id}/topics/{topic}'.format(
        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
        topic='MY_TOPIC_NAME',  # Set this to something appropriate.
    )
    publisher.create_topic(topic_name)
    publisher.publish(topic_name, b'My first message!', spam='eggs')

To learn more, consult the `publishing documentation`_.

.. _publishing documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/publisher/index.html


Subscribing
-----------

To subscribe to data in Cloud Pub/Sub, you create a subscription based on
the topic, and subscribe to that.

.. code-block:: python

    import os
    from google.cloud import pubsub

    subscriber = pubsub.SubscriberClient()
    topic_name = 'projects/{project_id}/topics/{topic}'.format(
        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
        topic='MY_TOPIC_NAME',  # Set this to something appropriate.
    )
    subscription_name = 'projects/{project_id}/subscriptions/{sub}'.format(
        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
        sub='MY_SUBSCRIPTION_NAME',  # Set this to something appropriate.
    )
    subscriber.create_subscription(
        name=subscription_name, topic=topic_name)
    subscription = subscriber.subscribe(subscription_name)

The subscription is opened asychronously, and messages are processed by
use of a callback.

.. code-block:: python

    def callback(message):
        print(message.data)
        message.ack()
    subscription.open(callback)

To learn more, consult the `subscriber documentation`_.

.. _subscriber documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/subscriber/index.html


.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-pubsub.svg
   :target: https://pypi.org/project/google-cloud-pubsub/
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-pubsub.svg
   :target: https://pypi.org/project/google-cloud-pubsub/



            

Raw data

            {
    "maintainer": "", 
    "docs_url": null, 
    "requires_python": "", 
    "maintainer_email": "", 
    "keywords": "", 
    "upload_time": "2018-04-27 22:44:43", 
    "author": "Google LLC", 
    "home_page": "https://github.com/GoogleCloudPlatform/google-cloud-python", 
    "github_user": "GoogleCloudPlatform", 
    "appveyor": true, 
    "download_url": "https://files.pythonhosted.org/packages/dc/23/199b515853c8b44ab86b1a4ea0817bbcf1e53cbda89829bc9282a10919b4/google-cloud-pubsub-0.34.0.tar.gz", 
    "platform": "Posix; MacOS X; Windows", 
    "version": "0.34.0", 
    "description": "Python Client for Google Cloud Pub / Sub\n========================================\n\n    Python idiomatic client for `Google Cloud Pub / Sub`_\n\n.. _Google Cloud Pub / Sub: https://cloud.google.com/pubsub/docs\n\n|pypi| |versions|\n\n-  `Documentation`_\n\n.. _Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/pubsub/\n\nQuick Start\n-----------\n\n.. code-block:: console\n\n    $ pip install --upgrade google-cloud-pubsub\n\nFor more information on setting up your Python development environment,\nsuch as installing ``pip`` and ``virtualenv`` on your system, please refer\nto `Python Development Environment Setup Guide`_ for Google Cloud Platform.\n\n.. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup\n\nAuthentication\n--------------\n\nWith ``google-cloud-python`` we try to make authentication as painless as\npossible. Check out the `Authentication section`_ in our documentation to\nlearn more. You may also find the `authentication document`_ shared by all\nthe ``google-cloud-*`` libraries to be helpful.\n\n.. _Authentication section: https://google-cloud-python.readthedocs.io/en/latest/core/auth.html\n.. _authentication document: https://github.com/GoogleCloudPlatform/google-cloud-common/tree/master/authentication\n\nUsing the API\n-------------\n\nGoogle `Cloud Pub/Sub`_ (`Pub/Sub API docs`_) is designed to provide reliable,\nmany-to-many, asynchronous messaging between applications. Publisher\napplications can send messages to a ``topic`` and other applications can\nsubscribe to that topic to receive the messages. By decoupling senders and\nreceivers, Google Cloud Pub/Sub allows developers to communicate between\nindependently written applications.\n\n.. _Cloud Pub/Sub: https://cloud.google.com/pubsub/docs\n.. _Pub/Sub API docs: https://cloud.google.com/pubsub/docs/reference/rest/\n\nSee the ``google-cloud-python`` API `Pub/Sub documentation`_ to learn how to connect\nto Cloud Pub/Sub using this Client Library.\n\n.. _Pub/Sub documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/index.html\n\n\nPublishing\n----------\n\nTo publish data to Cloud Pub/Sub you must create a topic, and then publish\nmessages to it\n\n.. code-block:: python\n\n    import os\n    from google.cloud import pubsub\n\n    publisher = pubsub.PublisherClient()\n    topic_name = 'projects/{project_id}/topics/{topic}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        topic='MY_TOPIC_NAME',  # Set this to something appropriate.\n    )\n    publisher.create_topic(topic_name)\n    publisher.publish(topic_name, b'My first message!', spam='eggs')\n\nTo learn more, consult the `publishing documentation`_.\n\n.. _publishing documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/publisher/index.html\n\n\nSubscribing\n-----------\n\nTo subscribe to data in Cloud Pub/Sub, you create a subscription based on\nthe topic, and subscribe to that.\n\n.. code-block:: python\n\n    import os\n    from google.cloud import pubsub\n\n    subscriber = pubsub.SubscriberClient()\n    topic_name = 'projects/{project_id}/topics/{topic}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        topic='MY_TOPIC_NAME',  # Set this to something appropriate.\n    )\n    subscription_name = 'projects/{project_id}/subscriptions/{sub}'.format(\n        project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),\n        sub='MY_SUBSCRIPTION_NAME',  # Set this to something appropriate.\n    )\n    subscriber.create_subscription(\n        name=subscription_name, topic=topic_name)\n    subscription = subscriber.subscribe(subscription_name)\n\nThe subscription is opened asychronously, and messages are processed by\nuse of a callback.\n\n.. code-block:: python\n\n    def callback(message):\n        print(message.data)\n        message.ack()\n    subscription.open(callback)\n\nTo learn more, consult the `subscriber documentation`_.\n\n.. _subscriber documentation: http://google-cloud-python.readthedocs.io/en/latest/pubsub/subscriber/index.html\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-pubsub.svg\n   :target: https://pypi.org/project/google-cloud-pubsub/\n.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-pubsub.svg\n   :target: https://pypi.org/project/google-cloud-pubsub/\n\n\n", 
    "lcname": "google-cloud-pubsub", 
    "name": "google-cloud-pubsub", 
    "github": true, 
    "coveralls": true, 
    "bugtrack_url": "", 
    "license": "Apache 2.0", 
    "travis_ci": false, 
    "github_project": "google-cloud-python", 
    "summary": "Google Cloud Pub/Sub API client library", 
    "split_keywords": [], 
    "author_email": "googleapis-packages@google.com", 
    "urls": [
        {
            "has_sig": false, 
            "upload_time": "2018-04-27T22:44:42", 
            "comment_text": "", 
            "python_version": "py2.py3", 
            "url": "https://files.pythonhosted.org/packages/23/47/f741353cceced8835925a1457319fb027cb0fe33003804ad20c4b2c4da94/google_cloud_pubsub-0.34.0-py2.py3-none-any.whl", 
            "md5_digest": "1a78841d8f0709784fbea69ae2544595", 
            "downloads": -1, 
            "filename": "google_cloud_pubsub-0.34.0-py2.py3-none-any.whl", 
            "packagetype": "bdist_wheel", 
            "digests": {
                "sha256": "35694ed3f95031d9a40731fbeec7594a55ef0456b6d569435957ed845f5e0d7e", 
                "md5": "1a78841d8f0709784fbea69ae2544595"
            }, 
            "size": 110384
        }, 
        {
            "has_sig": false, 
            "upload_time": "2018-04-27T22:44:43", 
            "comment_text": "", 
            "python_version": "source", 
            "url": "https://files.pythonhosted.org/packages/dc/23/199b515853c8b44ab86b1a4ea0817bbcf1e53cbda89829bc9282a10919b4/google-cloud-pubsub-0.34.0.tar.gz", 
            "md5_digest": "1e8909e8689814dc407849e4fee3b2c0", 
            "downloads": -1, 
            "filename": "google-cloud-pubsub-0.34.0.tar.gz", 
            "packagetype": "sdist", 
            "digests": {
                "sha256": "5463a257ef64143e1c8ade9d695cfe669865d2f88d26b3cc8723fb77364d937b", 
                "md5": "1e8909e8689814dc407849e4fee3b2c0"
            }, 
            "size": 108011
        }
    ], 
    "_id": null
}