npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oakpubsub

v0.7.0

Published

gcloud-node google pubsub functional wrapper using bluebird promises

Downloads

88

Readme

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

| Param | Type | Description | | --- | --- | --- | | options | Object | passed 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()

| Param | Type | Description | | --- | --- | --- | | pubsub | Object | gcloud-node pubsub object | | topic_title | string | the 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()

| Param | Type | Description | | --- | --- | --- | | pubsub | Object | gcloud-node pubsub object | | topic_title | string | the name of the topic | | [options] | Object | additional 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()

| Param | Type | Description | | --- | --- | --- | | pubsub | Object | gcloud-node pubsub object | | topic_title | string | the name of the topic | | [options] | Object | additional 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()

| 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 |

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()

| 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 |

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()

| Param | Type | Description | | --- | --- | --- | | topic | Object | gcloud-node topic object | | messages | Object | 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()

| Param | Type | Description | | --- | --- | --- | | topic | Object | gcloud-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()

| Param | Type | Description | | --- | --- | --- | | subscription | Object | gcloud-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()

| Param | Type | Description | | --- | --- | --- | | subscription | Object | gcloud-node subscription object | | acknowledge | string | 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()

| Param | Type | Description | | --- | --- | --- | | subscription | Object | gcloud-node subscription object | | [options] | Object | additional 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()

| 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 |

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()

| Param | Type | Description | | --- | --- | --- | | message | Object | 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()

| Param | Type | Description | | --- | --- | --- | | messages | Array.<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()

| Param | Type | Description | | --- | --- | --- | | message | Object | returned 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

| 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() |

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

| 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() |

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

| 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) |

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

| 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) |

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