0.7.0 • Published 8 years ago

oakpubsub v0.7.0

Weekly downloads
38
License
MIT
Repository
github
Last release
8 years ago

oakpubsub

A partial gcloud-node (google cloud) pubsub wrapper with bluebird promises, in functional style. Only does minimally what we need, no guarantees expressed or implied. Pull Requests for expanded functions/features are welcome.

See 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

API Reference

oakpubsub module.

oakpubsub.getPubsub(options) ⇒ Object

Get a pubsub object, for use in subsequent module function calls

Kind: static method of oakpubsub
Returns: Object - an authenticated pubsub object from gcloud-node

ParamTypeDescription
optionsObjectpassed directly to gcloud-node for i.e. authentication

oakpubsub.createTopic_P(pubsub, topic_title) ⇒ Promise

Remote call to create a google pubsub topic

Kind: static method of oakpubsub
Returns: Promise - resolving to topic returned by gcloud-node pubsub#createTopic()

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
topic_titlestringthe name of the topic

oakpubsub.getTopic(pubsub, topic_title, options) ⇒ Object

Get a pubsub topic, for use in subsequent module function calls

Kind: static method of oakpubsub
Returns: Object - topic returned by gcloud-node pubsub#topic()

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
topic_titlestringthe name of the topic
optionsObjectadditional gcloud-node options

oakpubsub.getOrCreateTopic_P(pubsub, topic_title, options) ⇒ Promise

Remote call to get or create a topic

Kind: static method of oakpubsub
Returns: Promise - resolving to the topic returned by gcloud-node pubsub#createTopic()

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
topic_titlestringthe name of the topic
optionsObjectadditional gcloud-node options

oakpubsub.getSubscription(topic, subscription_id, options) ⇒ Object

Gets a subscription

Kind: static method of oakpubsub
Returns: Object - returns a subscription from gcloud-node topic#subscription()

ParamTypeDescription
topicObjectgcloud-node topic object
subscription_idstringthe name of the subscription
optionsObjectgcloud-node subscription options: autoAck, interval

oakpubsub.createSubscription_P(topic, subscription_id, options) ⇒ Promise

Remote call to create a subscription

Kind: static method of oakpubsub
Returns: Promise - resolving to subscription returned by gcloud-node topic#subscribe()

ParamTypeDescription
topicObjectgcloud-node topic object
subscription_idstringthe name of the subscription
optionsObjectgcloud-node subscribe options: ackDeadlineSeconds, autoAck, interval, maxInProgress, reuseExisting, timeout

oakpubsub.publish_P(topic, messages) ⇒ Promise

Remote call to publish a message

Kind: static method of oakpubsub
Returns: Promise - resolving to array of message ids returned by gcloud-node topic#publish()

ParamTypeDescription
topicObjectgcloud-node topic object
messagesObject | Array.<Object>the message(s) to pass to gcloude-node topic#publish()

oakpubsub.deleteTopic_P(topic) ⇒ Promise

Remote call to delete a topic

Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node topic#delete()

ParamTypeDescription
topicObjectgcloud-node topic object

oakpubsub.deleteSubscription_P(subscription) ⇒ Promise

Remote call to delete a subscription

Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node subscription#delete()

ParamTypeDescription
subscriptionObjectgcloud-node subscription object

oakpubsub.ack_P(subscription, acknowledge) ⇒ Promise

Remote call to acknowledge completion of message processing

Kind: static method of oakpubsub
Returns: Promise - resolving to apiResponse returned by gcloud-node subscription#ack()

ParamTypeDescription
subscriptionObjectgcloud-node subscription object
acknowledgestring | Array.<string>IDs

oakpubsub.pull_P(subscription, options) ⇒ Promise

Remote call to pull messages from server

Kind: static method of oakpubsub
Returns: Promise - resolving to array of messages returned by gcloud-node subscription#pull()

ParamTypeDescription
subscriptionObjectgcloud-node subscription object
optionsObjectadditional gcloud-node options for subscription#pull(): maxResults, returnImmediately

oakpubsub.makeMessage(data, attributes) ⇒ Object

Utility to create a message object

Kind: static method of oakpubsub
Returns: Object - message object that can be used in publish_P()

ParamTypeDescription
datastring | number | array | Objectto publish (gcloud-node will JSON encode/decode for you)
attributesObjectadditional key-value attributes attached to the message

oakpubsub.pluckAcks(message) ⇒ Array.<string>

Utility to pluck ackIds from messages

Kind: static method of oakpubsub
Returns: Array.<string> - array of ackIds, can be passed to ack_P()

ParamTypeDescription
messageObject | Array.<Object>or messages returned by pull_P()

oakpubsub.resetMessages(messages) ⇒ Array.<Object>

Utility to create an array of message objects from previously pulled messages, useful for pubsub message passing

Kind: static method of oakpubsub
Returns: Array.<Object> - messages that can be used in publish_P()

ParamTypeDescription
messagesArray.<Object>returned by pull_P()

oakpubsub.resetMessage(message) ⇒ Object

Utility to create a publishable message object from a previously pulled message

Kind: static method of oakpubsub
Returns: Object - message object that can be used in publish_P()

ParamTypeDescription
messageObjectreturned by pull_P()

oakpubsub.processTopics_P(pubsub, worker_P, query_options) ⇒ Promise

Helper to get multiple pubsub topics and process them asynchronously

Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
worker_PPromise | functiona function or promise processing each array of topics
query_optionsObjectadditional gcloud-node pubsub query options for pubsub.getTopics()

oakpubsub.processSubs_P(pubsub, worker_P, query_options) ⇒ Promise

Helper to get multiple pubsub subscriptions and process them asynchronously

Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
worker_PPromise | functiona function or promise processing each array of subscriptions
query_optionsObjectadditional gcloud-node pubsub query options for pubsub.getSubscriptions()

oakpubsub.deleteTopicsMatching_P(pubsub, regex, page_size, concurrency) ⇒ Promise

Helper to get delete pubsub topics matching a regular expression, using processTopics_P and deleteTopic_P

Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
regexstringjavascript regular expression in string format, e.g. '^match_me'
page_sizeintegernumber of topics to fetch per response (default: 100)
concurrencyintegermax number of topics to delete simultaneously (default: 5)

oakpubsub.deleteSubsMatching_P(pubsub, regex, page_size, concurrency) ⇒ Promise

Helper to get delete pubsub subscriptions matching a regular expression, using processSubs_P and deleteSubscription_P

Kind: static method of oakpubsub
Returns: Promise - resolving to the final apiResponse

ParamTypeDescription
pubsubObjectgcloud-node pubsub object
regexstringjavascript regular expression matching subscription name in string format, e.g. '^match_me'
page_sizeintegernumber of subscriptions to fetch per response (default: 100)
concurrencyintegermax number of subscriptions to delete simultaneously (default: 5)

Update Docs

doc/generate

Development

Transpile with gulp or, if using the atom editor, the atom babel package.

Test

npm test or npm run testwatch or npm test -- watch

0.7.0

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.14

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.10

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.4

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago