Documentation
¶
Index ¶
- type AvroValidator
- type JSONSchemaValidator
- type ProtobufValidator
- type Registry
- type SchemaConfig
- type SchemaType
- type StorageRegistry
- func (r *StorageRegistry) CheckCompatibility(ctx context.Context, name string, schemaType SchemaType, content string) error
- func (r *StorageRegistry) GetLatestValidator(ctx context.Context, name string) (Validator, int, error)
- func (r *StorageRegistry) GetValidator(ctx context.Context, name string, version int) (Validator, error)
- func (r *StorageRegistry) Register(ctx context.Context, name string, schemaType SchemaType, content string) (int, error)
- func (r *StorageRegistry) SetStorage(s storage.Storage)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvroValidator ¶
type AvroValidator struct {
// contains filtered or unexported fields
}
func NewAvroValidator ¶
func NewAvroValidator(schemaStr string) (*AvroValidator, error)
func (*AvroValidator) Type ¶
func (v *AvroValidator) Type() SchemaType
type JSONSchemaValidator ¶
type JSONSchemaValidator struct {
// contains filtered or unexported fields
}
func NewJSONSchemaValidator ¶
func NewJSONSchemaValidator(schemaStr string) (*JSONSchemaValidator, error)
func (*JSONSchemaValidator) Type ¶
func (v *JSONSchemaValidator) Type() SchemaType
type ProtobufValidator ¶
type ProtobufValidator struct {
// contains filtered or unexported fields
}
func NewProtobufValidator ¶
func NewProtobufValidator(schemaStr string) (*ProtobufValidator, error)
func (*ProtobufValidator) Type ¶
func (v *ProtobufValidator) Type() SchemaType
type Registry ¶
type Registry interface {
Register(ctx context.Context, name string, schemaType SchemaType, content string) (int, error)
GetValidator(ctx context.Context, name string, version int) (Validator, error)
GetLatestValidator(ctx context.Context, name string) (Validator, int, error)
CheckCompatibility(ctx context.Context, name string, schemaType SchemaType, content string) error
}
Registry defines the interface for the global schema registry.
type SchemaConfig ¶
type SchemaConfig struct {
Type SchemaType `json:"type"`
Schema string `json:"schema"` // The raw schema definition or URL
}
SchemaConfig contains the configuration for schema validation.
type SchemaType ¶
type SchemaType string
SchemaType defines the supported schema formats.
const ( Avro SchemaType = "avro" JSONSchema SchemaType = "json" Protobuf SchemaType = "protobuf" )
type StorageRegistry ¶
type StorageRegistry struct {
// contains filtered or unexported fields
}
StorageRegistry implements Registry using the storage backend.
func NewStorageRegistry ¶
func NewStorageRegistry(s storage.Storage) *StorageRegistry
NewStorageRegistry creates a new StorageRegistry.
func (*StorageRegistry) CheckCompatibility ¶
func (r *StorageRegistry) CheckCompatibility(ctx context.Context, name string, schemaType SchemaType, content string) error
CheckCompatibility verifies if the new schema is compatible with previous versions. For now, it implements a basic check.
func (*StorageRegistry) GetLatestValidator ¶
func (r *StorageRegistry) GetLatestValidator(ctx context.Context, name string) (Validator, int, error)
GetLatestValidator retrieves a validator for the latest schema version.
func (*StorageRegistry) GetValidator ¶
func (r *StorageRegistry) GetValidator(ctx context.Context, name string, version int) (Validator, error)
GetValidator retrieves a validator for a specific schema version.
func (*StorageRegistry) Register ¶
func (r *StorageRegistry) Register(ctx context.Context, name string, schemaType SchemaType, content string) (int, error)
Register adds a new schema version to the registry.
func (*StorageRegistry) SetStorage ¶
func (r *StorageRegistry) SetStorage(s storage.Storage)
SetStorage updates the storage backend.
type Validator ¶
type Validator interface {
Validate(ctx context.Context, data map[string]any) error
Type() SchemaType
}
Validator defines the interface for schema validation.
func NewValidator ¶
func NewValidator(config SchemaConfig) (Validator, error)
NewValidator creates a new validator based on the provided configuration.