schemaregistry

package
v0.13.0-nightly.20241019 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a schema registry client that caches schemas. It is safe for concurrent use. The client caches schemas by ID, their subject/fingerprint and subject/version. Fingerprints are calculated using the Rabin algorithm.

func NewClient

func NewClient(logger log.CtxLogger, opts ...sr.ClientOpt) (*Client, error)

NewClient creates a new client using the provided logger and schema registry client options.

func (*Client) Check

func (c *Client) Check(ctx context.Context) error

Check checks if the schema registry is reachable.

func (*Client) CreateSchema

func (c *Client) CreateSchema(ctx context.Context, subject string, schema sr.Schema) (sr.SubjectSchema, error)

CreateSchema checks if the schema is already registered in the cache and returns the associated sr.SubjectSchema if it is found. Otherwise, the schema is sent to the schema registry and stored in the cache, if the registration was successful.

func (*Client) SchemaByID

func (c *Client) SchemaByID(ctx context.Context, id int) (sr.Schema, error)

SchemaByID checks if the schema is already registered in the cache and returns the associated sr.Schema if it is found. Otherwise, the schema is retrieved from the schema registry and stored in the cache. Note that the returned schema does not contain a subject and version, so the cache will not have an effect on methods that return a sr.SubjectSchema.

func (*Client) SchemaBySubjectVersion

func (c *Client) SchemaBySubjectVersion(ctx context.Context, subject string, version int) (sr.SubjectSchema, error)

SchemaBySubjectVersion checks if the schema is already registered in the cache and returns the associated sr.SubjectSchema if it is found. Otherwise, the schema is retrieved from the schema registry and stored in the cache.

type Registry

type Registry interface {
	CreateSchema(ctx context.Context, subject string, schema sr.Schema) (sr.SubjectSchema, error)
	SchemaByID(ctx context.Context, id int) (sr.Schema, error)
	SchemaBySubjectVersion(ctx context.Context, subject string, version int) (sr.SubjectSchema, error)
}

type RegistryWithCheck

type RegistryWithCheck interface {
	Registry
	Check(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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