remote_registry

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(ctx context.Context, subject string) (*jsonschema.Schema, bool)
	Set(ctx context.Context, subject string, schema *jsonschema.Schema)
	Delete(ctx context.Context, subject string)
}

Cache stores compiled schemas fetched from the remote registry, keyed by subject name.

type MemoryCache

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

MemoryCache is a thread-safe in-memory Cache with TTL-based expiry, keyed by subject name.

func NewMemoryCache

func NewMemoryCache(ttl time.Duration) *MemoryCache

func (*MemoryCache) Delete

func (m *MemoryCache) Delete(_ context.Context, subject string)

func (*MemoryCache) Get

func (m *MemoryCache) Get(_ context.Context, subject string) (*jsonschema.Schema, bool)

func (*MemoryCache) Set

func (m *MemoryCache) Set(_ context.Context, subject string, schema *jsonschema.Schema)

type Options

type Options func(*remoteRegistryConfig)

func WithAPIKey

func WithAPIKey(apiKey, headerName string) Options

WithAPIKey configures API key authentication with a custom header name. If headerName is empty, it defaults to "X-API-Key".

func WithBasicAuth

func WithBasicAuth(username, password string) Options

WithBasicAuth configures basic authentication with username and password.

func WithBearerToken

func WithBearerToken(token string) Options

WithBearerToken configures bearer token authentication.

func WithCache

func WithCache(cache Cache) Options

WithCache replaces the default MemoryCache with a custom Cache implementation.

func WithCacheRefreshDuration

func WithCacheRefreshDuration(d time.Duration) Options

func WithCustomHeader

func WithCustomHeader(headerName, headerValue string) Options

WithCustomHeader configures a custom header for authentication.

func WithTimeout

func WithTimeout(d time.Duration) Options

type SchemaRegistry

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

SchemaRegistry fetches schemas from a remote schema registry service and caches them locally to reduce latency and network calls.

func NewRemoteSchemaRegistry

func NewRemoteSchemaRegistry(baseURL string, logger *zap.Logger, opts ...Options) (*SchemaRegistry, error)

func (*SchemaRegistry) DeleteSchema

func (*SchemaRegistry) GetSchema

func (*SchemaRegistry) RegisterSchema

func (*SchemaRegistry) Type

func (r *SchemaRegistry) Type() string

Jump to

Keyboard shortcuts

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