GithubHelp home page GithubHelp logo

stevelin100132 / -wisrtoni40-confluent-schema Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 3.0 101 KB

Allow request Confluent schema registry with multiple brokers in mean time

JavaScript 49.75% TypeScript 50.02% Shell 0.23%

-wisrtoni40-confluent-schema's Introduction

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

-wisrtoni40-confluent-schema's People

Contributors

stevelin100132 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.