schema

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 8 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 PostgresRegistry added in v1.2.0

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

PostgresRegistry implements Registry using PostgreSQL as the storage backend.

func NewPostgresRegistry added in v1.2.0

func NewPostgresRegistry(db *sql.DB, logger *log.Logger) (*PostgresRegistry, error)

NewPostgresRegistry creates a new PostgreSQL-based schema registry.

func (*PostgresRegistry) Deactivate added in v1.2.0

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

Deactivate marks a schema version as inactive.

func (*PostgresRegistry) Get added in v1.2.0

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

Get retrieves a specific schema version.

func (*PostgresRegistry) GetLatest added in v1.2.0

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

GetLatest retrieves the latest version of a schema.

func (*PostgresRegistry) IsCompatible added in v1.2.0

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

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

func (*PostgresRegistry) List added in v1.2.0

List lists all active schemas (latest version of each).

func (*PostgresRegistry) Register added in v1.2.0

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

Register registers a new schema or creates a new version.

func (*PostgresRegistry) Validate added in v1.2.0

func (r *PostgresRegistry) 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