Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pubsub to README #259

Merged
merged 1 commit into from
Oct 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This client supports the following Google Cloud Platform services:

* [Google Cloud Datastore](https://cloud.google.com/products/cloud-datastore/)
* [Google Cloud Storage](https://cloud.google.com/products/cloud-storage/)
* [Google Cloud Pub/Sub][cloud-pubsub] (Developer Preview)

If you need support for other Google APIs, check out the [Google Node.js API Client library][googleapis].

Expand Down Expand Up @@ -101,6 +102,50 @@ bucket.write('demo.txt', 'Hello World', function(err) {
});
```

## Google Cloud Pub/Sub (Alpha)

> Google Cloud Pub/Sub is in **Alpha status**. As a result, it might change in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy.

[Google Cloud Pub/Sub][cloud-pubsub] allows you to connect your services with reliable, many-to-many, asynchronous messaging hosted on Google's infrastructure. Cloud Pub/Sub automatically scales as you need it and provides a foundation for building your own robust, global services.

See [the gcloud-node API documentation][gcloud-pubsub] to learn how to connect to the Cloud Pub/Sub using this Client Library.

``` js
var gcloud = require('gcloud');

// From Google Compute Engine:
var pubsub = gcloud.pubsub();

// Or from elsewhere:
var pubsub = gcloud.pubsub({
keyFilename: '/path/to/keyfile.json',
projectId: 'my-project'
});

// Create a new topic.
pubsub.createTopic('my-new-topic', function(err, topic) {
// Subscribe to the topic.
topic.subscribe('new-subscription', function(err, subscription) {
// Create listeners to start listening for messages.
function onError(err) {}
function onMessage(message) {}
subscription.on('error', onError);
subscription.on('message', onMessage);

// Publish a message to the topic.
topic.publish('New message!', function(err) {});

// Clean up listeners.
subscription.removeListener('message', onMessage);
subscription.removeListener('error', onError);
});
});

// Or reference an existing topic.
var topic = pubsub.topic('my-existing-topic');
// etc...
```

## Contributing

Contributions to this library are always welcome and highly encouraged.
Expand All @@ -113,3 +158,6 @@ Apache 2.0 - See [COPYING](COPYING) for more information.

[googleapis]: https://github.com/google/google-api-nodejs-client
[gcloud-todos]: https://github.com/GoogleCloudPlatform/gcloud-node-todos
[cloud-pubsub]: https://cloud.google.com/pubsub/
[pubsub-preview]: https://docs.google.com/a/google.com/forms/d/1IQY4LAbISLa86uxRv2dKAzkeWOyNZda_tUn7xgVYeoE/viewform
[gcloud-pubsub]: https://googlecloudplatform.github.io/gcloud-node/#/docs/pubsub