npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wisrtoni40-confluent-schema

v1.0.0

Published

Allow request Confluent schema registry with multiple brokers in mean time

Downloads

2

Readme

wisrtoni40-confluent-schema

Install

npm i wisrtoni40-confluent-schema --save

Table of Contents

Quickstart

Consumer

Full Example

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

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 | Buffer | Required | undefined | 要解析的資料 | | returns | Promise<T> | 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 | any[] | Required | undefined | 要解析的資料 | | returns | Promise<Buffer | Buffer[]> | Required | undefined | 回傳解析後的Avro |