Categorygithub.com/gocardless/schema-registry
modulepackage
0.2.3
Repository: https://github.com/gocardless/schema-registry.git
Documentation: pkg.go.dev

# README

Schema Registry CLI and Client

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

CLI

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

go get -u github.com/gocardless/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/gocardless/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/gocardless/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

# Packages

No description provided by the author
No description provided by the author

# Functions

IsSchemaNotFound checks the returned error to see if it is kind of a schema not found error code.
IsSubjectNotFound checks the returned error to see if it is kind of a subject not found error code.
JSONAvroSchema converts and returns the json form of the "avroSchema" as []byte.
NewClient creates & returns a new Registry Schema Client based on the passed url and the options.
UsingClient modifies the underline HTTP Client that schema registry is using for contact with the backend server.

# Constants

DefaultURL is the address where a local schema registry listens by default.
SchemaLatestVersion is the only one valid string for the "versionID", it's the "latest" version string and it's used on `GetLatestSchema`.

# Structs

No description provided by the author
No description provided by the author
ResourceError is being fired from all API calls when an error code is received.
No description provided by the author

# Type aliases

No description provided by the author