schemaregistry

package module
v0.0.0-...-2a7e59b Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-schema-registry

Go-schema-registry is a library to interact with Confluent's Schema Registry, and create Codecs to be used with goavro.

Note: This is a work in progress. It is not feature complete, and do not expect any APIs to remain the same.

Installation

$ go get github.com/csmarchbanks/go-schema-registry

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedClient

type CachedClient struct {
	// contains filtered or unexported fields
}

CachedClient is a schema registry client that will cache calls to GetSchema to improve performance

func NewCachedClient

func NewCachedClient(connect []string) *CachedClient

NewCachedClient creates a cached client that will round robin requests to the servers specified

By default it will retry failed requests (5XX responses and http errors) len(connect) number of times

func NewCachedClientWithRetries

func NewCachedClientWithRetries(connect []string, retries int) *CachedClient

NewCachedClientWithRetries creates a cached client that will round robin requests to the servers specified and will retry failed requests (5XX responses and http errors) retries number of times

func (*CachedClient) CreateSubject

func (client *CachedClient) CreateSubject(subject string, codec *goavro.Codec) (int, error)

CreateSubject creates a new schema under the specified subject Will always make an http call

func (*CachedClient) DeleteSubject

func (client *CachedClient) DeleteSubject(subject string) error

DeleteSubject deletes the subject, should only be used in development Will always make an http call

func (*CachedClient) DeleteVersion

func (client *CachedClient) DeleteVersion(subject string, version int) error

DeleteVersion deletes the a specific version of a subject, should only be used in development. Will always make an http call

func (*CachedClient) GetLatestSchema

func (client *CachedClient) GetLatestSchema(subject string) (*goavro.Codec, error)

GetLatestSchema returns the highest version schema for a subject Will always make an http call

func (*CachedClient) GetSchema

func (client *CachedClient) GetSchema(id int) (*goavro.Codec, error)

GetSchema will return and cache the codec with the given id

func (*CachedClient) GetSchemaByVersion

func (client *CachedClient) GetSchemaByVersion(subject string, version int) (*goavro.Codec, error)

GetSchemaByVersion returns the codec for a specific version of a subject

func (*CachedClient) GetSubjects

func (client *CachedClient) GetSubjects() ([]string, error)

GetSubjects returns a list of subjects Will always make an http call

func (*CachedClient) GetVersions

func (client *CachedClient) GetVersions(subject string) ([]int, error)

GetVersions returns a list of all versions of a subject. Will always make an http call Will always make an http call

func (*CachedClient) IsSchemaRegistered

func (client *CachedClient) IsSchemaRegistered(subject string, codec *goavro.Codec) (int, error)

IsSchemaRegistered checks if a specific codec is already registered to a subject Will always make an http call

type Client

type Client interface {
	GetSchema(int) (*goavro.Codec, error)
	GetSubjects() ([]string, error)
	GetVersions(string) ([]int, error)
	GetSchemaByVersion(string, int) (*goavro.Codec, error)
	GetLatestSchema(string) (*goavro.Codec, error)
	CreateSubject(string, *goavro.Codec) (int, error)
	IsSchemaRegistered(string, *goavro.Codec) (int, error)
	DeleteSubject(string) error
	DeleteVersion(string, int) error
}

Client defines the api for all clients interfacing with schema registry

type Error

type Error struct {
	ErrorCode int    `json:"error_code"`
	Message   string `json:"message"`
}

Error holds more detailed information about errors coming back from schema registry

func (*Error) Error

func (e *Error) Error() string

type HTTPClient

type HTTPClient struct {
	SchemaRegistryConnect []string
	// contains filtered or unexported fields
}

HTTPClient is a basic http client to interact with schema registry

func NewHTTPClient

func NewHTTPClient(connect []string) *HTTPClient

NewHTTPClient creates a client to talk with the schema registry at the connect string

By default it will retry failed requests (5XX responses and http errors) len(connect) number of times

func NewHTTPClientWithRetries

func NewHTTPClientWithRetries(connect []string, retries int) *HTTPClient

NewHTTPClientWithRetries creates an http client with a configurable amount of retries on 5XX responses

func (*HTTPClient) CreateSubject

func (client *HTTPClient) CreateSubject(subject string, codec *goavro.Codec) (int, error)

CreateSubject adds a schema to the subject

func (*HTTPClient) DeleteSubject

func (client *HTTPClient) DeleteSubject(subject string) error

DeleteSubject deletes a subject. It should only be used in development

func (*HTTPClient) DeleteVersion

func (client *HTTPClient) DeleteVersion(subject string, version int) error

DeleteVersion deletes a subject. It should only be used in development

func (*HTTPClient) GetLatestSchema

func (client *HTTPClient) GetLatestSchema(subject string) (*goavro.Codec, error)

GetLatestSchema returns a goavro.Codec for the latest version of the subject

func (*HTTPClient) GetSchema

func (client *HTTPClient) GetSchema(id int) (*goavro.Codec, error)

GetSchema returns a goavro.Codec by unique id

func (*HTTPClient) GetSchemaByVersion

func (client *HTTPClient) GetSchemaByVersion(subject string, version int) (*goavro.Codec, error)

GetSchemaByVersion returns a goavro.Codec for the version of the subject

func (*HTTPClient) GetSubjects

func (client *HTTPClient) GetSubjects() ([]string, error)

GetSubjects returns a list of all subjects in the schema registry

func (*HTTPClient) GetVersions

func (client *HTTPClient) GetVersions(subject string) ([]int, error)

GetVersions returns a list of the versions of a subject

func (*HTTPClient) IsSchemaRegistered

func (client *HTTPClient) IsSchemaRegistered(subject string, codec *goavro.Codec) (int, error)

IsSchemaRegistered tests if the schema is registered, if so it returns the unique id of that schema

Jump to

Keyboard shortcuts

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