GithubHelp home page GithubHelp logo

lensesio / schema-registry Goto Github PK

View Code? Open in Web Editor NEW
117.0 27.0 32.0 86 KB

A CLI and Go client for Kafka Schema Registry. This repository is deprecated and no longer maintained.

Home Page: https://lenses.stream

License: Apache License 2.0

Go 100.00%
kafka schema-registry cli api go avro-schema avro schema confluent

schema-registry's Introduction

Schema Registry CLI and client

This repository contains a Command Line Interface (CLI) and a Go client for the REST API of Confluent's Kafka Schema Registry.

Build Status GoDoc Chat

CLI

To install the CLI, assuming a properly setup Go installation, do:

go get -u github.com/landoop/schema-registry/schema-registry-cli

After that, the CLI is found in $GOPATH/bin/schema-registry-cli. Running schema-registry-cli without arguments gives:

A command line interface for the Confluent schema registry

Usage:
  schema-registry-cli [command]

Available Commands:
  add         registers the schema provided through stdin
  compatible  tests compatibility between a schema from stdin and a given subject
  exists      checks if the schema provided through stdin exists for the subject
  get         retrieves a schema specified by id or subject
  get-config  retrieves global or suject specific configuration
  subjects    lists all registered subjects
  versions    lists all available versions

Flags:
  -h, --help         help for schema-registry-cli
  -n, --no-color     dont color output
  -e, --url string   schema registry url, overrides SCHEMA_REGISTRY_URL (default "http://localhost:8081")
  -v, --verbose      be verbose

Use "schema-registry-cli [command] --help" for more information about a command.

The schema registry url can be configured through the SCHEMA_REGISTRY_URL environment variable, and overridden through --url. When none is provided, http://localhost:8081 is used as default.

Client

The client package provides a client to deal with the registry from code. It is used by the CLI internally. Usage looks like:

import "github.com/landoop/schema-registry"

client, _ := schemaregistry.NewClient(schemaregistry.DefaultUrl)
client.Subjects()

Or, to use with a Schema Registry endpoint listening on HTTPS:

import (
    "crypto/tls"
    "crypto/x509"
    "io/ioutil"

    "github.com/landoop/schema-registry"
)

// Create a TLS config to use to connect to Schema Registry. This config will permit TLS connections to an endpoint
// whose TLS cert is signed by the given caFile.
caCert, err := ioutil.ReadFile("/path/to/ca/file")
if err != nil {
    panic(err)
}

caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)

tlsConfig :=  &tls.Config{
    RootCAs:            caCertPool,
    InsecureSkipVerify: true,
}

httpsClientTransport := &http.Transport{
  TLSClientConfig: tlsConfig,
}

httpsClient := &http.Client{
  Transport: httpsClientTransport,
}

// Create the Schema Registry client
client, _ := schemaregistry.NewClient(baseurl, UsingClient(httpsClient))
client.Subjects()

The documentation of the package can be found here: GoDoc

schema-registry's People

Contributors

andmarios avatar antwnis avatar josh-padnick avatar kataras avatar otaviof avatar rikonor avatar rollulus avatar steers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schema-registry's Issues

Sub schema reference support?

I am interested to know if the current release offers to define sub-schemas? Schemas can get very complex and I believe having separate nested schemas that can be referenced into the main schema can improve the maintainability?

Is that something currently offered or planned to include in future releases?

Regards
Bhupinder

License?

I noticed there was once an Apache 2.0 license in one of the files, but no license information anywhere else. Could you add a LICENSE file, or clarify what the license is for this project?

Expose schema registry errors

Hello,

Thanks for this great library!
I was wondering if there's a simple way to check for "subject not found" errors.

I can see that in the IsRegistered method, there's a check for schema not found error:

if ce, confluentErr := err.(confluentError); confluentErr && ce.ErrorCode == schemaNotFound {
	return false, fs, nil
}

But the const subjectNotFound is not used on the project. Is there any reason behind that?

Thanks!

Client interface

Hi,

We're using this project and thought it might benefit from Client being an interface rather then a struct.

This allows one to mock the Client, among other possibilities.

Currently, we're using a fork with this change, but I figured I might as well suggest it here in case there's interest.

If there is, please let me know and I can submit a PR.

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.