Skip to content

Commit f758d07

Browse files
committed
move pubsub sample placement
1 parent ca6e982 commit f758d07

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,57 @@ languageClient.analyzeSentiment({document: document}).then(function(responses) {
450450
```
451451

452452

453+
## Cloud Pub/Sub (Beta)
454+
455+
- [API Documentation][gcloud-pubsub-docs]
456+
- [Official Documentation][cloud-pubsub-docs]
457+
458+
#### Using the Cloud Pub/Sub API module
459+
460+
```
461+
$ npm install --save @google-cloud/pubsub
462+
```
463+
464+
```js
465+
var pubsub = require('@google-cloud/pubsub');
466+
```
467+
468+
#### Authentication
469+
470+
See [Authentication](#authentication).
471+
472+
#### Preview
473+
474+
```js
475+
var pubsubClient = pubsub({
476+
projectId: 'grape-spaceship-123',
477+
keyFilename: '/path/to/keyfile.json'
478+
});
479+
480+
// Reference a topic that has been previously created.
481+
var topic = pubsubClient.topic('my-topic');
482+
483+
// Publish a message to the topic.
484+
var publisher = topic.publisher();
485+
var message = new Buffer('New message!');
486+
487+
publisher.publish(message, function(err, messageId) {});
488+
489+
// Subscribe to the topic.
490+
topic.createSubscription('subscription-name', function(err, subscription) {
491+
// Register listeners to start pulling for messages.
492+
function onError(err) {}
493+
function onMessage(message) {}
494+
subscription.on('error', onError);
495+
subscription.on('message', onMessage);
496+
497+
// Remove listeners to stop pulling for messages.
498+
subscription.removeListener('message', onMessage);
499+
subscription.removeListener('error', onError);
500+
});
501+
```
502+
503+
453504
## Cloud Spanner (Beta)
454505

455506
- [API Documentation][gcloud-spanner-docs]
@@ -816,57 +867,6 @@ zone.export('/zonefile.zone', function(err) {});
816867
```
817868

818869

819-
## Cloud Pub/Sub (Alpha)
820-
821-
- [API Documentation][gcloud-pubsub-docs]
822-
- [Official Documentation][cloud-pubsub-docs]
823-
824-
#### Using the Cloud Pub/Sub API module
825-
826-
```
827-
$ npm install --save @google-cloud/pubsub
828-
```
829-
830-
```js
831-
var pubsub = require('@google-cloud/pubsub');
832-
```
833-
834-
#### Authentication
835-
836-
See [Authentication](#authentication).
837-
838-
#### Preview
839-
840-
```js
841-
var pubsubClient = pubsub({
842-
projectId: 'grape-spaceship-123',
843-
keyFilename: '/path/to/keyfile.json'
844-
});
845-
846-
// Reference a topic that has been previously created.
847-
var topic = pubsubClient.topic('my-topic');
848-
849-
// Publish a message to the topic.
850-
var publisher = topic.publisher();
851-
var message = new Buffer('New message!');
852-
853-
publisher.publish(message, function(err, messageId) {});
854-
855-
// Subscribe to the topic.
856-
topic.createSubscription('subscription-name', function(err, subscription) {
857-
// Register listeners to start pulling for messages.
858-
function onError(err) {}
859-
function onMessage(message) {}
860-
subscription.on('error', onError);
861-
subscription.on('message', onMessage);
862-
863-
// Remove listeners to stop pulling for messages.
864-
subscription.removeListener('message', onMessage);
865-
subscription.removeListener('error', onError);
866-
});
867-
```
868-
869-
870870
## Cloud Resource Manager (Alpha)
871871

872872
- [API Documentation][gcloud-resource-docs]

0 commit comments

Comments
 (0)