# pubsub-tool

> Producer and Consumer Tool for every streaming component

Latest version **0.0.2** (published 2021-01-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install pubsub-tool
pnpm add pubsub-tool
yarn add pubsub-tool
bun add pubsub-tool
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-01-13 |
| First published | 2021-01-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 123.5 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Steve Y Lin |
| Maintainers | steveylin |
| Keywords | Kafka, Schema, Registry, Avro |

## Links

- npm: https://www.npmjs.com/package/pubsub-tool
- Repository: https://github.com/SteveLin100132/pubsub-tool
- Homepage: https://github.com/SteveLin100132/pubsub-tool#readme
- Issues: https://github.com/SteveLin100132/pubsub-tool/issues
- npm.io page: https://npm.io/package/pubsub-tool

## Dependencies (6)

- [avsc](https://npm.io/package/avsc.md) ^5.5.3
- [rxjs](https://npm.io/package/rxjs.md) ^6.6.3
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [request](https://npm.io/package/request.md) ^2.88.2
- [kafka-node](https://npm.io/package/kafka-node.md) ^5.0.0
- [request-promise](https://npm.io/package/request-promise.md) ^4.2.6

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.0.2 (latest) — 2021-01-13
- 0.0.1 — 2021-01-13

## README

PubSub Tool

# Install

```
npm i pubsub-tool --save
```

# Table of Contents

- [Feature](#Feature)
- [API](#API)
  - [ConfluentSubResolveStrategy](#ConfluentSubResolveStrategy): for kafka consumer
  - [ConfluentPubResolveStrategy](#ConfluentPubResolveStrategy): for kafka producer

# Feature

* Confluent Schema Registry and Avro Resolver

# API

## Confluent Schema Registry and Avro Resolver Usage

### ConfluentSubResolveStrategy

Parameter | Type | Description
-----|:-----:|-----:|
schemaRegistry | SchemaRegistry | Schema Registry
avroResolver | AvroResolveStrategy | Avro Resolve Strategy

[Full Example](https://github.com/SteveLin100132/pubsub-tool/blob/master/examples/confluent-kafka-consumer.ts)

```typescript
import {
  ConfluentAvroStrategy,
  ConfluentMultiRegistry,
  ConfluentSubResolveStrategy,
} from 'pubsub-tool';

const registryHost = 'http://localhost:8585,http://localhost:8585,http://localhost:8585';

const schemaRegistry = new ConfluentMultiRegistry(registryHost);
const avro = new ConfluentAvroStrategy();
const resolver = new ConfluentSubResolveStrategy(schemaRegistry, avro);

const data = new Buffer();
resolver.resolve(data).then(val => console.log(val));
```

### ConfluentPubResolveStrategy

Parameter | Type | Description
-----|:-----:|-----:|
schemaRegistry | SchemaRegistry | Schema Registry
avroResolver | AvroResolveStrategy | Avro Resolve Strategy
destination | string | Pubish destination

[Full Example](https://github.com/SteveLin100132/pubsub-tool/blob/master/examples/confluent-kafka-producer.ts)

```typescript
import {
  ConfluentAvroStrategy,
  ConfluentMultiRegistry,
  ConfluentPubResolveStrategy,
} from 'pubsub-tool';

const registryHost = 'http://localhost:8585,http://localhost:8585,http://localhost:8585';
const topic = 'testing.topic'

const schemaRegistry = new ConfluentMultiRegistry(registryHost);
const avro = new ConfluentAvroStrategy();
const resolver = new ConfluentPubResolveStrategy(schemaRegistry, avro, topic);

const data = { name: 'name', age: 18 };
resolver.resolve(data).then(buf => console.log(buf));
```

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