...

Package schemaregistry

import "github.com/confluentinc/confluent-kafka-go/schemaregistry"
Overview
Index

Overview ▾

Constants

const (

    // None is no compatibility
    None
    // Backward compatibility
    Backward
    // Forward compatibility
    Forward
    // Full compatibility
    Full
    // BackwardTransitive compatibility
    BackwardTransitive
    // ForwardTransitive compatibility
    ForwardTransitive
    // FullTransitive compatibility
    FullTransitive
)

type Client

Client is an interface for clients interacting with the Confluent Schema Registry. The Schema Registry's REST interface is further explained in Confluent's Schema Registry API documentation https://github.com/confluentinc/schema-registry/blob/master/client/src/main/java/io/confluent/kafka/schemaregistry/client/SchemaRegistryClient.java

type Client interface {
    Register(subject string, schema SchemaInfo, normalize bool) (id int, err error)
    GetBySubjectAndID(subject string, id int) (schema SchemaInfo, err error)
    GetID(subject string, schema SchemaInfo, normalize bool) (id int, err error)
    GetLatestSchemaMetadata(subject string) (SchemaMetadata, error)
    GetSchemaMetadata(subject string, version int) (SchemaMetadata, error)
    GetAllVersions(subject string) ([]int, error)
    GetVersion(subject string, schema SchemaInfo, normalize bool) (version int, err error)
    GetAllSubjects() ([]string, error)
    DeleteSubject(subject string, permanent bool) ([]int, error)
    DeleteSubjectVersion(subject string, version int, permanent bool) (deletes int, err error)
    GetCompatibility(subject string) (compatibility Compatibility, err error)
    UpdateCompatibility(subject string, update Compatibility) (compatibility Compatibility, err error)
    TestCompatibility(subject string, version int, schema SchemaInfo) (compatible bool, err error)
    GetDefaultCompatibility() (compatibility Compatibility, err error)
    UpdateDefaultCompatibility(update Compatibility) (compatibility Compatibility, err error)
}

func NewClient

func NewClient(conf *Config) (Client, error)

NewClient returns a Client implementation

type Compatibility

Compatibility options

type Compatibility int

func (Compatibility) MarshalJSON

func (c Compatibility) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Compatibility) ParseString

func (c *Compatibility) ParseString(val string) error

ParseString returns a Compatibility for the given string

func (Compatibility) String

func (c Compatibility) String() string

func (*Compatibility) UnmarshalJSON

func (c *Compatibility) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler

type Config

Config is used to pass multiple configuration options to the Schema Registry client.

type Config struct {
    // SchemaRegistryURL determines the URL of Schema Registry.
    SchemaRegistryURL string

    // BasicAuthUserInfo specifies the user info in the form of {username}:{password}.
    BasicAuthUserInfo string
    // BasicAuthCredentialsSource specifies how to determine the credentials, one of URL, USER_INFO, and SASL_INHERIT.
    BasicAuthCredentialsSource string

    // SaslMechanism specifies the SASL mechanism used for client connections, which defaults to GSSAPI.
    SaslMechanism string
    // SaslUsername specifies the username for SASL.
    SaslUsername string
    // SaslUsername specifies the password for SASL.
    SaslPassword string

    // SslCertificateLocation specifies the location of SSL certificates.
    SslCertificateLocation string
    // SslKeyLocation specifies the location of SSL keys.
    SslKeyLocation string
    // SslCaLocation specifies the location of SSL certificate authorities.
    SslCaLocation string
    // SslDisableEndpointVerification determines whether to disable endpoint verification.
    SslDisableEndpointVerification bool

    // ConnectionTimeoutMs determines the connection timeout in milliseconds.
    ConnectionTimeoutMs int
    // RequestTimeoutMs determines the request timeout in milliseconds.
    RequestTimeoutMs int
    // CacheCapacity positive integer or zero for unbounded capacity
    CacheCapacity int
}

func NewConfig

func NewConfig(url string) *Config

NewConfig returns a new configuration instance with sane defaults.

func NewConfigWithAuthentication

func NewConfigWithAuthentication(url string, username string, password string) *Config

NewConfigWithAuthentication returns a new configuration instance using basic authentication. For Confluent Cloud, use the API key for the username and the API secret for the password.

type Reference

Reference represents a schema reference

type Reference struct {
    Name    string `json:"name"`
    Subject string `json:"subject"`
    Version int    `json:"version"`
}

type RestError

RestError represents a Schema Registry HTTP Error response

type RestError struct {
    Code    int    `json:"error_code"`
    Message string `json:"message"`
}

func (*RestError) Error

func (err *RestError) Error() string

Error implements the errors.Error interface

type SchemaInfo

SchemaInfo represents basic schema information

type SchemaInfo struct {
    Schema     string      `json:"schema,omitempty"`
    SchemaType string      `json:"schemaType,omitempty"`
    References []Reference `json:"references,omitempty"`
}

func (*SchemaInfo) MarshalJSON

func (sd *SchemaInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*SchemaInfo) UnmarshalJSON

func (sd *SchemaInfo) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface

type SchemaMetadata

SchemaMetadata represents schema metadata

type SchemaMetadata struct {
    SchemaInfo
    ID      int    `json:"id,omitempty"`
    Subject string `json:"subject,omitempty"`
    Version int    `json:"version,omitempty"`
}

func (*SchemaMetadata) MarshalJSON

func (sd *SchemaMetadata) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*SchemaMetadata) UnmarshalJSON

func (sd *SchemaMetadata) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface