# wisrtoni40-confluent-schema

> Allow request Confluent schema registry with multiple brokers in mean time

Latest version **1.0.0** (published 2022-08-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install wisrtoni40-confluent-schema
pnpm add wisrtoni40-confluent-schema
yarn add wisrtoni40-confluent-schema
bun add wisrtoni40-confluent-schema
```

## 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 | 2022-08-21 |
| First published | 2021-01-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 133.6 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Y Lin |
| Maintainers | steveylin |
| Keywords | confluent, avro, schema, registry |

## Links

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

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

- 1.0.0 (latest) — 2022-08-21
- 0.0.1 — 2021-01-29

## README

# wisrtoni40-confluent-schema

# Install

```
npm i wisrtoni40-confluent-schema --save
```

# Table of Contents

- [Quickstart](#Quickstart)
- [Feature](#Feature)
- [API](#API)
  - [ConfluentMultiRegistry](#ConfluentMultiRegistry)
  - [ConfluentAvroStrategy](#ConfluentAvroStrategy)
  - [ConfluentSubResolveStrategy](#ConfluentSubResolveStrategy)
  - [ConfluentPubResolveStrategy](#ConfluentPubResolveStrategy)

# Quickstart

## Consumer

[Full Example](https://github.com/SteveLin100132/-wisrtoni40-confluent-schema/blob/master/examples/confluent-kafka-consumer.ts)

```typescript
import {
  ConfluentAvroStrategy,
  ConfluentMultiRegistry,
  ConfluentSubResolveStrategy,
} from 'wisrtoni40-confluent-schema';

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));
```

## Producer

[Full Example](https://github.com/SteveLin100132/-wisrtoni40-confluent-schema/blob/master/examples/confluent-kafka-producer.ts)

```typescript
import {
  ConfluentAvroStrategy,
  ConfluentMultiRegistry,
  ConfluentPubResolveStrategy,
} from 'wisrtoni40-confluent-schema';

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));
```

# Feature

* 提供多個Brokers的Confluent Avro Schema解析API

# API

## **ConfluentMultiRegistry**

**Class implements SchemaRegistry**，多個Brokers的Confluent Schema Registry

### constructor

ConfluentMultiRegistry的建構值

Parameter | Type | Required | Default | Description
|:-----|:-----:|:-----:|:-----:|:-----|
| host | string | Required | ```undefined``` | Brokers Host 多筆可用```,```隔開，如: 'http://localhost:8585,http://localhost:8585,http://localhost:8585' |

## **ConfluentAvroStrategy**

**Class implements AvroResolveStrategy**，Confluent Avro Schema的解析策略

## **ConfluentSubResolveStrategy**

**Class implements ConsumerResolveStrategy**，Confluent Schema Consumer的解析器

### constructor

ConfluentSubResolveStrategy的建構值

Parameter | Type | Required | Default | Description
|:-----|:-----:|:-----:|:-----:|:-----|
| schemaRegistry | SchemaRegistry | Required | ```undefined``` | Schema Registry |
| avroResolver | AvroResolveStrategy | Required | ```undefined``` | Avro解析策略 |

### Methods

#### resolve

將Avro資料解析成特定JSON格式

Parameter | Type | Required | Default | Description
|:-----|:-----:|:-----:|:-----:|:-----|
| input | string &#124; Buffer | Required | ```undefined``` | 要解析的資料 |
| returns | Promise&lt;T&gt; | Required | ```undefined``` | 回傳解析後的資料 |

## **ConfluentPubResolveStrategy**

**Class implements ProducerResolveStrategy**，Confluent Schema Producer的解析器

### constructor

ConfluentPubResolveStrategy的建構值

Parameter | Type | Required | Default | Description
|:-----|:-----:|:-----:|:-----:|:-----|
| schemaRegistry | SchemaRegistry | Required | ```undefined``` | Schema Registry |
| avroResolver | AvroResolveStrategy | Required | ```undefined``` | Avro解析策略 |
| destination | string | Required | ```undefined``` | 發送資料的目的地 |

#### resolve

將特定JSON資料解析成Avro

Parameter | Type | Required | Default | Description
|:-----|:-----:|:-----:|:-----:|:-----|
| input | any &#124; any[] | Required | ```undefined``` | 要解析的資料 |
| returns | Promise&lt;Buffer &#124; Buffer[]&gt; | Required | ```undefined``` | 回傳解析後的Avro |

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