Documentation ¶
Overview ¶
Package schemaregistry provides a client for Confluent's Kafka Schema Registry REST API.
Index ¶
- Constants
- func IsSchemaNotFound(err error) bool
- func IsSubjectNotFound(err error) bool
- func JSONAvroSchema(avroSchema string) (json.RawMessage, error)
- type Client
- func (c *Client) DeleteSubject(subject string) (versions []int, err error)
- func (c *Client) GetConfig(subject string) (Config, error)
- func (c *Client) GetLatestSchema(subject string) (Schema, error)
- func (c *Client) GetSchemaByID(subjectID int) (string, error)
- func (c *Client) GetSchemaById(id int) (string, error)
- func (c *Client) GetSchemaBySubject(subject string, versionID int) (Schema, error)
- func (c *Client) IsLatestSchemaCompatible(subject string, avroSchema string) (bool, error)
- func (c *Client) IsRegistered(subject, schema string) (bool, Schema, error)
- func (c *Client) IsSchemaCompatible(subject string, avroSchema string, versionID int) (bool, error)
- func (c *Client) RegisterNewSchema(subject string, avroSchema string) (int, error)
- func (c *Client) Subjects() (subjects []string, err error)
- func (c *Client) Versions(subject string) (versions []int, err error)
- type Config
- type Option
- type ResourceError
- type Schema
Constants ¶
const DefaultURL = "http://localhost:8081"
DefaultURL is the address where a local schema registry listens by default.
const DefaultUrl = DefaultURL
DefaultUrl is the address where a local schema registry listens by default.
DEPRECATED: Use `schemaregistry.DefaultURL` instead.
const SchemaLatestVersion = "latest"
SchemaLatestVersion is the only one valid string for the "versionID", it's the "latest" version string and it's used on `GetLatestSchema`.
Variables ¶
This section is empty.
Functions ¶
func IsSchemaNotFound ¶
IsSchemaNotFound checks the returned error to see if it is kind of a schema not found error code.
func IsSubjectNotFound ¶
IsSubjectNotFound checks the returned error to see if it is kind of a subject not found error code.
func JSONAvroSchema ¶
func JSONAvroSchema(avroSchema string) (json.RawMessage, error)
JSONAvroSchema converts and returns the json form of the "avroSchema" as []byte.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the registry schema REST API client.
func NewClient ¶
NewClient creates & returns a new Registry Schema Client based on the passed url and the options.
func NewTlsClient ¶
NewTlsClient returns a new Client that securely connects to baseurl.
DEPRECATED: Use `schemaregistry.NewClient(baseURL, schemaregistry.UsingClient(customHTTPSClient))` instead.
func (*Client) DeleteSubject ¶
DeleteSubject deletes the specified subject and its associated compatibility level if registered. It is recommended to use this API only when a topic needs to be recycled or in development environment. Returns the versions of the schema deleted under this subject.
func (*Client) GetConfig ¶
GetConfig returns the configuration (Config type) for global Schema-Registry or a specific subject. When Config returned has "compatibilityLevel" empty, it's using global settings.
func (*Client) GetLatestSchema ¶
GetLatestSchema returns the latest version of a schema. See `GetSchemaAtVersion` to retrieve a subject schema by a specific version.
func (*Client) GetSchemaByID ¶
GetSchemaByID returns the Auro schema string identified by the id. id (int) – the globally unique identifier of the schema.
func (*Client) GetSchemaById ¶
GetSchemaById returns the schema for some id. The schema registry only provides the schema itself, not the id, subject or version.
DEPRECATED: Use `Client#GetSchemaByID` instead.
func (*Client) GetSchemaBySubject ¶
GetSchemaBySubject returns the schema for a particular subject and version.
func (*Client) IsLatestSchemaCompatible ¶
IsLatestSchemaCompatible tests compatibility with the latest version of a subject's schema.
func (*Client) IsRegistered ¶
IsRegistered tells if the given "schema" is registered for this "subject".
func (*Client) IsSchemaCompatible ¶
IsSchemaCompatible tests compatibility with a specific version of a subject's schema.
func (*Client) RegisterNewSchema ¶
RegisterNewSchema registers a schema. The returned identifier should be used to retrieve this schema from the schemas resource and is different from the schema’s version which is associated with that name.
func (*Client) Subjects ¶
Subjects returns a list of the available subjects(schemas). https://docs.confluent.io/current/schema-registry/docs/api.html#subjects
type Config ¶
type Config struct { // CompatibilityLevel mode of subject or global CompatibilityLevel string `json:"compatibilityLevel"` }
Config describes a subject or globa schema-registry configuration
type Option ¶
type Option func(*Client)
Option describes an optional runtime configurator that can be passed on `NewClient`. Custom `Option` can be used as well, it's just a type of `func(*schemaregistry.Client)`.
Look `UsingClient`.
func UsingClient ¶
UsingClient modifies the underline HTTP Client that schema registry is using for contact with the backend server.
type ResourceError ¶
type ResourceError struct { ErrorCode int `json:"error_code"` Method string `json:"method,omitempty"` URI string `json:"uri,omitempty"` Message string `json:"message,omitempty"` }
ResourceError is being fired from all API calls when an error code is received.
func (ResourceError) Error ¶
func (err ResourceError) Error() string
type Schema ¶
type Schema struct { // Schema is the Avro schema string. Schema string `json:"schema"` // Subject where the schema is registered for. Subject string `json:"subject"` // Version of the returned schema. Version int `json:"version"` ID int `json:"id,omitempty"` }
Schema describes a schema, look `GetSchema` for more.