# @superbalist/js-pubsub-google-cloud

> A Google Cloud adapter for the js-pubsub package.

Latest version **3.0.2** (published 2018-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @superbalist/js-pubsub-google-cloud
pnpm add @superbalist/js-pubsub-google-cloud
yarn add @superbalist/js-pubsub-google-cloud
bun add @superbalist/js-pubsub-google-cloud
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2018-11-21 |
| First published | 2017-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 32.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Superbalist.com a division of Takealot Online |
| Maintainers | bradwhittington, mike-faut, zoidbergwill |
| Keywords | pubsub, google, cloud |

## Links

- npm: https://www.npmjs.com/package/@superbalist/js-pubsub-google-cloud
- Repository: https://github.com/Superbalist/js-pubsub-google-cloud
- Homepage: https://github.com/Superbalist/js-pubsub-google-cloud#readme
- Issues: https://github.com/Superbalist/js-pubsub-google-cloud/issues
- npm.io page: https://npm.io/package/@superbalist/js-pubsub-google-cloud

## Dependencies (2)

- [@google-cloud/pubsub](https://npm.io/package/@google-cloud/pubsub.md) ^0.11.0
- [@superbalist/js-pubsub](https://npm.io/package/@superbalist/js-pubsub.md) ^3.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.0.2 (latest) — 2018-11-21
- 3.0.1 — 2017-07-18
- 2.0.3 — 2017-07-13
- 2.0.2 — 2017-06-01
- 2.0.0 — 2017-05-17
- 1.0.2 — 2017-05-15
- 1.0.1 — 2017-05-09
- 1.0.0 — 2017-05-08
- 0.0.1 — 2017-05-02

## README

# @superbalist/js-pubsub-google-cloud

A Google Cloud adapter for the [js-pubsub](https://github.com/Superbalist/js-pubsub) package.

[![Author](http://img.shields.io/badge/author-@superbalist-blue.svg?style=flat-square)](https://twitter.com/superbalist)
[![Build Status](https://img.shields.io/travis/Superbalist/js-pubsub-google-cloud/master.svg?style=flat-square)](https://travis-ci.org/Superbalist/js-pubsub-google-cloud)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![NPM Version](https://img.shields.io/npm/v/@superbalist/js-pubsub-google-cloud.svg)](https://www.npmjs.com/package/@superbalist/js-pubsub-google-cloud)
[![NPM Downloads](https://img.shields.io/npm/dt/@superbalist/js-pubsub-google-cloud.svg)](https://www.npmjs.com/package/@superbalist/js-pubsub-google-cloud)


## Installation

```bash
npm install @superbalist/js-pubsub-google-cloud
```
    
## Usage

```node
"use strict";

let pubsub = require('@google-cloud/pubsub');
let GoogleCloudPubSubAdapter = require('@superbalist/js-pubsub-google-cloud');

process.env.GOOGLE_APPLICATION_CREDENTIALS = '/path/to/your-gcloud-key.json';

let client = pubsub({
  projectId: 'your-project-id-here'
});

let adapter = new GoogleCloudPubSubAdapter(client);

// disable auto topic & subscription creation
adapter.autoCreateTopics = false; // this is true by default
adapter.autoCreateSubscriptions = false; // this is true by default

// set a unique client identifier for the subscriber
adapter.clientIdentifier = 'search_service';

// consume messages
// note: this is a blocking call
adapter.subscribe('my_channel', (message) => {
  console.log(message);
  console.log(typeof message);
});

// publish messages
adapter.publish('my_channel', {first_name: 'Matthew'});
adapter.publish('my_channel', 'Hello World');

// publish multiple messages
let messages = [
  'message 1',
  'message 2',
];
adapter.publishBatch('my_channel', messages);
```

## Examples

The library comes with [examples](examples) for the adapter and a [Dockerfile](Dockerfile) for
running the example scripts.

Run `make up`.

You will start at a `bash` prompt in the `/usr/src/app` directory.

If you need another shell to publish a message to a blocking consumer, you can run `docker-compose run js-pubsub-google-cloud /bin/bash`

To run the examples:
```bash
$ node examples/GoogleCloudConsumerExample.js
$ node examples/GoogleCloudPublishExample.js (in a separate shell)
```

---
_Source: https://npm.io/package/@superbalist/js-pubsub-google-cloud · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
