schemaregistry

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 24 Imported by: 54

Documentation

Index

Constants

View Source
const (
	// Upgrade denotes upgrade mode
	Upgrade = 1
	// Downgrade denotes downgrade mode
	Downgrade = 2
	// UpDown denotes upgrade/downgrade mode
	UpDown = 3
	// Write denotes write mode
	Write = 4
	// Read denotes read mode
	Read = 5
	// WriteRead denotes write/read mode
	WriteRead = 6
)
View Source
const (

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Config() *Config
	Register(subject string, schema SchemaInfo, normalize bool) (id int, err error)
	RegisterFullResponse(subject string, schema SchemaInfo, normalize bool) (result SchemaMetadata, 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)
	GetSchemaMetadataIncludeDeleted(subject string, version int, deleted bool) (SchemaMetadata, error)
	GetLatestWithMetadata(subject string, metadata map[string]string, deleted bool) (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)
	TestSubjectCompatibility(subject string, schema SchemaInfo) (compatible bool, err error)
	TestCompatibility(subject string, version int, schema SchemaInfo) (compatible bool, err error)
	GetCompatibility(subject string) (compatibility Compatibility, err error)
	UpdateCompatibility(subject string, update Compatibility) (compatibility Compatibility, err error)
	GetDefaultCompatibility() (compatibility Compatibility, err error)
	UpdateDefaultCompatibility(update Compatibility) (compatibility Compatibility, err error)
	GetConfig(subject string, defaultToGlobal bool) (result ServerConfig, err error)
	UpdateConfig(subject string, update ServerConfig) (result ServerConfig, err error)
	GetDefaultConfig() (result ServerConfig, err error)
	UpdateDefaultConfig(update ServerConfig) (result ServerConfig, err error)
	Close() error
}

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

func NewClient

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

NewClient returns a Client implementation

type Compatibility

type Compatibility int

Compatibility options

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

type Config struct {
	internal.ClientConfig
}

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

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. This method is deprecated.

func NewConfigWithBasicAuthentication added in v2.4.0

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

NewConfigWithBasicAuthentication 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.

func NewConfigWithBearerAuthentication added in v2.4.0

func NewConfigWithBearerAuthentication(url, token, targetSr, identityPoolID string) *Config

NewConfigWithBearerAuthentication returns a new configuration instance using bearer authentication. For Confluent Cloud, targetSr(`bearer.auth.logical.cluster` and identityPoolID(`bearer.auth.identity.pool.id`) is required

type Metadata added in v2.5.0

type Metadata struct {
	Tags       map[string][]string `json:"tags,omitempty"`
	Properties map[string]string   `json:"properties,omitempty"`
	Sensitive  []string            `json:"sensitive,omitempty"`
}

Metadata represents user-defined metadata

type Reference

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

Reference represents a schema reference

type RestError

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

RestError represents a Schema Registry HTTP Error response

func (*RestError) Error

func (err *RestError) Error() string

Error implements the errors.Error interface

type Rule added in v2.5.0

type Rule struct {
	// Rule name
	Name string `json:"name,omitempty"`
	// Rule doc
	Doc string `json:"doc,omitempty"`
	// Rule kind
	Kind string `json:"kind,omitempty"`
	// Rule mode
	Mode string `json:"mode,omitempty"`
	// Rule type
	Type string `json:"type,omitempty"`
	// The tags to which this rule applies
	Tags []string `json:"tags,omitempty"`
	// Optional params for the rule
	Params map[string]string `json:"params,omitempty"`
	// Rule expression
	Expr string `json:"expr,omitempty"`
	// Rule action on success
	OnSuccess string `json:"onSuccess,omitempty"`
	// Rule action on failure
	OnFailure string `json:"onFailure,omitempty"`
	// Whether the rule is disabled
	Disabled bool `json:"disabled,omitempty"`
}

Rule represents a data contract rule

type RuleMode added in v2.5.0

type RuleMode = int

RuleMode represents the rule mode

func ParseMode added in v2.5.0

func ParseMode(mode string) (RuleMode, bool)

ParseMode parses the given rule mode

type RuleSet added in v2.5.0

type RuleSet struct {
	MigrationRules []Rule `json:"migrationRules,omitempty"`
	DomainRules    []Rule `json:"domainRules,omitempty"`
}

RuleSet represents a data contract rule set

func (*RuleSet) HasRules added in v2.5.0

func (r *RuleSet) HasRules(mode RuleMode) bool

HasRules checks if the ruleset has rules for the given mode

type SchemaInfo

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

SchemaInfo represents basic schema information

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

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

SchemaMetadata represents schema metadata

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

type ServerConfig added in v2.5.0

type ServerConfig struct {
	Alias               string        `json:"alias,omitempty"`
	Normalize           bool          `json:"normalize,omitempty"`
	CompatibilityUpdate Compatibility `json:"compatibility,omitempty"`
	CompatibilityLevel  Compatibility `json:"compatibilityLevel,omitempty"`
	CompatibilityGroup  string        `json:"compatibilityGroup,omitempty"`
	DefaultMetadata     *Metadata     `json:"defaultMetadata,omitempty"`
	OverrideMetadata    *Metadata     `json:"overrideMetadata,omitempty"`
	DefaultRuleSet      *RuleSet      `json:"defaultRuleSet,omitempty"`
	OverrideRuleSet     *RuleSet      `json:"overrideRuleSet,omitempty"`
}

ServerConfig represents config params for Schema Registry

NOTE: GET uses compatibilityLevel, POST uses compatibility

Directories

Path Synopsis
rules
cel
Code generated by github.com/actgardner/gogen-avro/v10.
Code generated by github.com/actgardner/gogen-avro/v10.

Jump to

Keyboard shortcuts

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