schemaregistry

package module
v0.0.0-...-6240b64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

README

Confluent Kafka 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

CLI

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

go get github.com/datamountaineer/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
  exists      checks if the schema provided through stdin exists for the subject
  get         retrieves a schema specified by id or subject
  subjects    lists all registered subjects
  versions    lists all available versions

Flags:
  -h, --help         help for schema-registry-cli
  -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/datamountaineer/schema-registry"

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

The documentation of the package can be found here: GoDoc

Documentation

Overview

Package schemaregistry provides a client for Confluent's Kafka Schema Registry REST API.

Index

Constants

This section is empty.

Variables

View Source
var DefaultUrl = "http://localhost:8081"

DefaultUrl is the address where a local schema registry listens by default.

Functions

This section is empty.

Types

type Client

type Client interface {
	Subjects() (subjects []string, err error)
	Versions(subject string) (versions []int, err error)
	RegisterNewSchema(subject, schema string) (int, error)
	IsRegistered(subject, schema string) (bool, Schema, error)
	GetSchemaById(id int) (string, error)
	GetSchemaBySubject(subject string, ver int) (s Schema, err error)
	GetLatestSchema(subject string) (s Schema, err error)
}

A Client is a client for the schema registry.

func NewClient

func NewClient(baseurl string) (Client, error)

NewClient returns a new Client that connects to baseurl.

func NewNOOPClient

func NewNOOPClient() Client

type MockClient

type MockClient struct {
	SubjectsFn           func() (subjects []string, err error)
	VersionsFn           func(subject string) (versions []int, err error)
	RegisterNewSchemaFn  func(subject, schema string) (int, error)
	IsRegisteredFn       func(subject, schema string) (bool, Schema, error)
	GetSchemaByIdFn      func(id int) (string, error)
	GetSchemaBySubjectFn func(subject string, ver int) (Schema, error)
	GetLatestSchemaFn    func(subject string) (Schema, error)
}

func (*MockClient) GetLatestSchema

func (c *MockClient) GetLatestSchema(subject string) (Schema, error)

func (*MockClient) GetSchemaById

func (c *MockClient) GetSchemaById(id int) (string, error)

func (*MockClient) GetSchemaBySubject

func (c *MockClient) GetSchemaBySubject(subject string, ver int) (Schema, error)

func (*MockClient) IsRegistered

func (c *MockClient) IsRegistered(subject, schema string) (bool, Schema, error)

func (*MockClient) RegisterNewSchema

func (c *MockClient) RegisterNewSchema(subject, schema string) (int, error)

func (*MockClient) Subjects

func (c *MockClient) Subjects() (subjects []string, err error)

func (*MockClient) Versions

func (c *MockClient) Versions(subject string) (versions []int, err error)

type Schema

type Schema struct {
	Schema  string `json:"schema"`  // The actual AVRO schema
	Subject string `json:"subject"` // Subject where the schema is registered for
	Version int    `json:"version"` // Version within this subject
	Id      int    `json:"id"`      // Registry's unique id
}

The Schema type is an object produced by the schema registry.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL