gcloud-node google pubsub functional wrapper using bluebird promises
npm install oakpubsubSee tests for usage.
Use care when doing mass deletes of topics or subscriptions, an incorrect regular expression could destroy data. It would be nice if google pubsub supported namespaces to avoid potential clobbering.
Tested with node v4 LTS
* oakpubsub
* .getPubsub(options) ⇒ Object
* .createTopic_P(pubsub, topic_title) ⇒ Promise
* [.getTopic(pubsub, topic_title, [options])](#module_oakpubsub.getTopic) ⇒ Object
* [.getOrCreateTopic_P(pubsub, topic_title, [options])](#module_oakpubsub.getOrCreateTopic_P) ⇒ Promise
* [.getSubscription(topic, subscription_id, [options])](#module_oakpubsub.getSubscription) ⇒ Object
* [.createSubscription_P(topic, subscription_id, [options])](#module_oakpubsub.createSubscription_P) ⇒ Promise
* .publish_P(topic, messages) ⇒ Promise
* .deleteTopic_P(topic) ⇒ Promise
* .deleteSubscription_P(subscription) ⇒ Promise
* .ack_P(subscription, acknowledge) ⇒ Promise
* [.pull_P(subscription, [options])](#module_oakpubsub.pull_P) ⇒ Promise
* [.makeMessage(data, [attributes])](#module_oakpubsub.makeMessage) ⇒ Object
* .pluckAcks(message) ⇒ Array.<string>
* .resetMessages(messages) ⇒ Array.<Object>
* .resetMessage(message) ⇒ Object
* [.processTopics_P(pubsub, worker_P, [query_options])](#module_oakpubsub.processTopics_P) ⇒ Promise
* [.processSubs_P(pubsub, worker_P, [query_options])](#module_oakpubsub.processSubs_P) ⇒ Promise
* [.deleteTopicsMatching_P(pubsub, regex, [page_size], [concurrency])](#module_oakpubsub.deleteTopicsMatching_P) ⇒ Promise
* [.deleteSubsMatching_P(pubsub, regex, [page_size], [concurrency])](#module_oakpubsub.deleteSubsMatching_P) ⇒ Promise
Kind: static method of oakpubsub
Returns: Object - an authenticated pubsub object from gcloud-node
| Param | Type | Description |
| --- | --- | --- |
| options | Object | passed directly to gcloud-node for i.e. authentication |
Kind: static method of oakpubsub
Returns: Promise - resolving to topic returned by gcloud-node pubsub#createTopic()
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| topic_title | string | the name of the topic |
Kind: static method of oakpubsub
Returns: Object - topic returned by gcloud-node pubsub#topic()
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| topic_title | string | the name of the topic |
| [options] | Object | additional gcloud-node options |
Kind: static method of oakpubsub
Returns: Promise - resolving to the topic returned by gcloud-node pubsub#createTopic()
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| topic_title | string | the name of the topic |
| [options] | Object | additional gcloud-node options |
Kind: static method of oakpubsub
Returns: Object - returns a subscription from gcloud-node topic#subscription()
| Param | Type | Description |
| --- | --- | --- |
| topic | Object | gcloud-node topic object |
| subscription_id | string | the name of the subscription |
| [options] | Object | gcloud-node subscription options: autoAck, interval |
Kind: static method of oakpubsub
Returns: Promise - resolving to subscription returned by gcloud-node topic#subscribe()
| Param | Type | Description |
| --- | --- | --- |
| topic | Object | gcloud-node topic object |
| subscription_id | string | the name of the subscription |
| [options] | Object | gcloud-node subscribe options: ackDeadlineSeconds, autoAck, interval, maxInProgress, reuseExisting, timeout |
Kind: static method of oakpubsub
Returns: Promise - resolving to array of message ids returned by gcloud-node topic#publish()
| Param | Type | Description |
| --- | --- | --- |
| topic | Object | gcloud-node topic object |
| messages | Object | Array.<Object> | the message(s) to pass to gcloude-node topic#publish() |
Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node topic#delete()
| Param | Type | Description |
| --- | --- | --- |
| topic | Object | gcloud-node topic object |
Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node subscription#delete()
| Param | Type | Description |
| --- | --- | --- |
| subscription | Object | gcloud-node subscription object |
Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node subscription#ack()
| Param | Type | Description |
| --- | --- | --- |
| subscription | Object | gcloud-node subscription object |
| acknowledge | string | Array.<string> | IDs |
Kind: static method of oakpubsub
Returns: Promise - resolving to array of messages returned by gcloud-node subscription#pull()
| Param | Type | Description |
| --- | --- | --- |
| subscription | Object | gcloud-node subscription object |
| [options] | Object | additional gcloud-node options for subscription#pull(): maxResults, returnImmediately |
Kind: static method of oakpubsub
Returns: Object - message object that can be used in publish_P()
| Param | Type | Description |
| --- | --- | --- |
| data | string | number | array | Object | to publish (gcloud-node will JSON encode/decode for you) |
| [attributes] | Object | additional key-value attributes attached to the message |
Kind: static method of oakpubsub
Returns: Array.<string> - array of ackIds, can be passed to ack_P()
| Param | Type | Description |
| --- | --- | --- |
| message | Object | Array.<Object> | or messages returned by pull_P() |
Kind: static method of oakpubsub
Returns: Array.<Object> - messages that can be used in publish_P()
| Param | Type | Description |
| --- | --- | --- |
| messages | Array.<Object> | returned by pull_P() |
Kind: static method of oakpubsub
Returns: Object - message object that can be used in publish_P()
| Param | Type | Description |
| --- | --- | --- |
| message | Object | returned by pull_P() |
Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| worker_P | Promise | function | a function or promise processing each array of topics |
| [query_options] | Object | additional gcloud-node pubsub query options for pubsub.getTopics() |
Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| worker_P | Promise | function | a function or promise processing each array of subscriptions |
| [query_options] | Object | additional gcloud-node pubsub query options for pubsub.getSubscriptions() |
Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| regex | string | javascript regular expression in string format, e.g. '^match_me' |
| [page_size] | integer | number of topics to fetch per response (default: 100) |
| [concurrency] | integer | max number of topics to delete simultaneously (default: 5) |
Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse
| Param | Type | Description |
| --- | --- | --- |
| pubsub | Object | gcloud-node pubsub object |
| regex | string | javascript regular expression matching subscription name in string format, e.g. '^match_me' |
| [page_size] | integer | number of subscriptions to fetch per response (default: 100) |
| [concurrency] | integer | max number of subscriptions to delete simultaneously (default: 5) |
doc/generate
`Development
Transpile with gulp or, if using the atom editor, the atom babel package.
$3
npm test
or
npm run testwatch
or
npm test -- watch`