# mavidevcombr-google-pubsub-queue

> ## How to install

Latest version **1.0.0** (published 2021-08-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install mavidevcombr-google-pubsub-queue
pnpm add mavidevcombr-google-pubsub-queue
yarn add mavidevcombr-google-pubsub-queue
bun add mavidevcombr-google-pubsub-queue
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-08-24 |
| First published | 2021-08-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mavidevcombr |

## Links

- npm: https://www.npmjs.com/package/mavidevcombr-google-pubsub-queue
- npm.io page: https://npm.io/package/mavidevcombr-google-pubsub-queue

## Dependencies (2)

- [grpc](https://npm.io/package/grpc.md) ^1.19.0
- [@google-cloud/pubsub](https://npm.io/package/@google-cloud/pubsub.md) ^0.28.1

## Recent versions

- 1.0.0 (latest) — 2021-08-24

## README

# Gcloud Pub/Sub Queue Class

## How to install

``` sh
npm install --save mavidevcombr-google-pubsub-queue
```

### How to instantiate class


 - Param **project_id** - ``` string ``` : ``` example-proj ```
 - Param **topic_name** - ``` string ``` : ``` example_topic ```

``` js
const PubSubQueue = require('mavidevcombr-google-pubsub-queue');
var pubSubQueue = new PubSubQueue(project_id, topic_name);
```

### How to send job to topic_name

 - Param **data** - ``` object|array ``` : ``` {"foo" : "bar"} ```

``` js
data = {"foo" : "bar"}
await pubSubQueue.sendJob(data);

```

### How to get job from subscriber

 - Param **subscriber_name** - ``` string ``` : ``` example_sub ``` - name of subscriber
 - Param **limit** - ``` int ``` : 10 - Quantity of messages to receive


``` js
async function do_process()
{
  const items = await pubSubQueue.getJob('sub_teste', 1);

  const response = items.payload.receivedMessages;
  for(var i in response)
  {
    item = response[i];
    console.log(item);
    console.log(Buffer.from(item.message.data, 'base64').toString('utf-8'));
    const ackRequest = {
           subscription: items.subscription_path,
           ackIds: [item.ackId],
    };
    await items.client.acknowledge(ackRequest);
  }
}


do_process();
```


### Release notes
#### 1.0.7
 - Bugfix readme
#### 1.0.6
 - Bugfix readme
 - Bugfix base64 buffer enconding
#### 1.0.5
 - Bugfix base64 buffer enconding

#### 1.0.4
 - Bugfix readme docs

#### 1.0.3
 - Bugfix readme docs

#### 1.0.2
 - Bugfix readme docs

#### 1.0.1
 - Bugfix readme docs

#### 1.0.0
 - First commit
 - Class defined and all functions working

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