0.0.2 • Published 3 years ago

pubsub-tool v0.0.2

Weekly downloads
8
License
ISC
Repository
github
Last release
3 years ago

PubSub Tool

Install

npm i pubsub-tool --save

Table of Contents

Feature

  • Confluent Schema Registry and Avro Resolver

API

Confluent Schema Registry and Avro Resolver Usage

ConfluentSubResolveStrategy

ParameterTypeDescription
schemaRegistrySchemaRegistrySchema Registry
avroResolverAvroResolveStrategyAvro Resolve Strategy

Full Example

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

ParameterTypeDescription
schemaRegistrySchemaRegistrySchema Registry
avroResolverAvroResolveStrategyAvro Resolve Strategy
destinationstringPubish destination

Full Example

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