schema

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateJSONSchema

func ValidateJSONSchema(schemaContent string, payload []byte) (*schema_pb.ValidationResult, error)

ValidateJSONSchema validates a JSON payload against a JSON Schema

Types

type RedisRegistry

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

RedisRegistry implements Registry using Redis as the storage backend

func NewRedisRegistry

func NewRedisRegistry(redisClient *redis.Client, logger *log.Logger) *RedisRegistry

NewRedisRegistry creates a new Redis-based schema registry

func (*RedisRegistry) Deactivate

func (r *RedisRegistry) Deactivate(ctx context.Context, schemaID string, version int32) error

Deactivate marks a schema version as inactive

func (*RedisRegistry) Get

func (r *RedisRegistry) Get(ctx context.Context, schemaID string, version int32) (*schema_pb.Schema, error)

Get retrieves a specific schema version

func (*RedisRegistry) GetLatest

func (r *RedisRegistry) GetLatest(ctx context.Context, schemaID string) (*schema_pb.Schema, error)

GetLatest retrieves the latest version of a schema

func (*RedisRegistry) IsCompatible

func (r *RedisRegistry) IsCompatible(ctx context.Context, schemaID string, newContent string) (bool, error)

IsCompatible checks if a new schema content is compatible with existing versions

func (*RedisRegistry) List

func (r *RedisRegistry) List(ctx context.Context) ([]*schema_pb.Schema, error)

List lists all active schemas

func (*RedisRegistry) Register

func (r *RedisRegistry) Register(ctx context.Context, schema *schema_pb.Schema) (SchemaMetadata, error)

Register registers a new schema or creates a new version

func (*RedisRegistry) Validate

func (r *RedisRegistry) Validate(ctx context.Context, schemaID string, version int32, payload []byte) (*schema_pb.ValidationResult, error)

Validate validates a JSON payload against a schema

type Registry

type Registry interface {
	// Register registers a new schema or updates an existing one
	Register(ctx context.Context, schema *schema_pb.Schema) (SchemaMetadata, error)

	// Get retrieves a specific schema version
	Get(ctx context.Context, schemaID string, version int32) (*schema_pb.Schema, error)

	// GetLatest retrieves the latest version of a schema
	GetLatest(ctx context.Context, schemaID string) (*schema_pb.Schema, error)

	// List lists all active schemas
	List(ctx context.Context) ([]*schema_pb.Schema, error)

	// Deactivate marks a schema version as inactive
	Deactivate(ctx context.Context, schemaID string, version int32) error

	// Validate validates a JSON payload against a schema
	Validate(ctx context.Context, schemaID string, version int32, payload []byte) (*schema_pb.ValidationResult, error)

	// IsCompatible checks if a new schema content is compatible with existing versions
	IsCompatible(ctx context.Context, schemaID string, newContent string) (bool, error)
}

Registry manages message schemas

type SchemaMetadata

type SchemaMetadata struct {
	SchemaID      string
	LatestVersion int32
	TotalVersions int32
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

SchemaMetadata contains metadata about a schema

Jump to

Keyboard shortcuts

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