Documentation
¶
Index ¶
- type CompatibilityMode
- type DefaultValidator
- type DeleteSchemaRequest
- type DeleteSchemaResponse
- type DeleteSubjectRequest
- type DeleteSubjectResponse
- type ErrorCode
- type GetCompatibilityRequest
- type GetCompatibilityResponse
- type GetLatestSchemaRequest
- type GetLatestSchemaResponse
- type GetSchemaBySubjectVersionRequest
- type GetSchemaBySubjectVersionResponse
- type GetSchemaRequest
- type GetSchemaResponse
- type ListSubjectsRequest
- type ListSubjectsResponse
- type ListVersionsRequest
- type ListVersionsResponse
- type RegisterSchemaRequest
- type RegisterSchemaResponse
- type RegistryStats
- type Schema
- type SchemaFormat
- type SchemaID
- type SchemaMetadata
- type SchemaReference
- type SchemaRegistry
- func (sr *SchemaRegistry) DeleteSchema(req *DeleteSchemaRequest) (*DeleteSchemaResponse, error)
- func (sr *SchemaRegistry) DeleteSubject(req *DeleteSubjectRequest) (*DeleteSubjectResponse, error)
- func (sr *SchemaRegistry) GetCompatibility(req *GetCompatibilityRequest) (*GetCompatibilityResponse, error)
- func (sr *SchemaRegistry) GetLatestSchema(req *GetLatestSchemaRequest) (*GetLatestSchemaResponse, error)
- func (sr *SchemaRegistry) GetSchema(req *GetSchemaRequest) (*GetSchemaResponse, error)
- func (sr *SchemaRegistry) GetSchemaBySubjectVersion(req *GetSchemaBySubjectVersionRequest) (*GetSchemaBySubjectVersionResponse, error)
- func (sr *SchemaRegistry) ListSubjects(req *ListSubjectsRequest) (*ListSubjectsResponse, error)
- func (sr *SchemaRegistry) ListVersions(req *ListVersionsRequest) (*ListVersionsResponse, error)
- func (sr *SchemaRegistry) RegisterSchema(req *RegisterSchemaRequest) (*RegisterSchemaResponse, error)
- func (sr *SchemaRegistry) SetGlobalCompatibility(mode CompatibilityMode) error
- func (sr *SchemaRegistry) Stats() RegistryStats
- func (sr *SchemaRegistry) TestCompatibility(req *TestCompatibilityRequest) (*TestCompatibilityResponse, error)
- func (sr *SchemaRegistry) UpdateCompatibility(req *UpdateCompatibilityRequest) (*UpdateCompatibilityResponse, error)
- type SchemaValidator
- type SchemaWithReferences
- type Subject
- type SubjectVersion
- type TestCompatibilityRequest
- type TestCompatibilityResponse
- type UpdateCompatibilityRequest
- type UpdateCompatibilityResponse
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompatibilityMode ¶
type CompatibilityMode string
CompatibilityMode defines how schema evolution is validated
const ( // CompatibilityNone allows any schema change CompatibilityNone CompatibilityMode = "NONE" // CompatibilityBackward allows deletion of fields and addition of optional fields // New schema can read data written with old schema CompatibilityBackward CompatibilityMode = "BACKWARD" // CompatibilityForward allows addition of fields and deletion of optional fields // Old schema can read data written with new schema CompatibilityForward CompatibilityMode = "FORWARD" // CompatibilityFull is both backward and forward compatible CompatibilityFull CompatibilityMode = "FULL" // CompatibilityBackwardTransitive checks compatibility against all previous versions CompatibilityBackwardTransitive CompatibilityMode = "BACKWARD_TRANSITIVE" // CompatibilityForwardTransitive checks compatibility against all previous versions CompatibilityForwardTransitive CompatibilityMode = "FORWARD_TRANSITIVE" // CompatibilityFullTransitive checks compatibility against all previous versions CompatibilityFullTransitive CompatibilityMode = "FULL_TRANSITIVE" )
type DefaultValidator ¶
type DefaultValidator struct{}
DefaultValidator provides basic schema validation
func NewDefaultValidator ¶
func NewDefaultValidator() *DefaultValidator
NewDefaultValidator creates a new default validator
func (*DefaultValidator) CheckCompatibility ¶
func (v *DefaultValidator) CheckCompatibility(format SchemaFormat, oldSchema, newSchema string, mode CompatibilityMode) (bool, error)
CheckCompatibility checks if two schemas are compatible
func (*DefaultValidator) Validate ¶
func (v *DefaultValidator) Validate(format SchemaFormat, definition string) error
Validate validates a schema definition
type DeleteSchemaRequest ¶
DeleteSchemaRequest deletes a schema version
type DeleteSchemaResponse ¶
type DeleteSchemaResponse struct {
ErrorCode ErrorCode
}
DeleteSchemaResponse confirms deletion
type DeleteSubjectRequest ¶
type DeleteSubjectRequest struct {
Subject Subject
}
DeleteSubjectRequest deletes all versions of a subject
type DeleteSubjectResponse ¶
DeleteSubjectResponse confirms deletion
type GetCompatibilityRequest ¶
type GetCompatibilityRequest struct {
Subject Subject
}
GetCompatibilityRequest retrieves compatibility mode for a subject
type GetCompatibilityResponse ¶
type GetCompatibilityResponse struct {
Compatibility CompatibilityMode
ErrorCode ErrorCode
}
GetCompatibilityResponse returns compatibility mode
type GetLatestSchemaRequest ¶
type GetLatestSchemaRequest struct {
Subject Subject
}
GetLatestSchemaRequest retrieves the latest schema for a subject
type GetLatestSchemaResponse ¶
GetLatestSchemaResponse returns the latest schema
type GetSchemaBySubjectVersionRequest ¶
GetSchemaBySubjectVersionRequest retrieves a schema by subject and version
type GetSchemaBySubjectVersionResponse ¶
GetSchemaBySubjectVersionResponse returns the schema
type GetSchemaRequest ¶
type GetSchemaRequest struct {
ID SchemaID
}
GetSchemaRequest retrieves a schema by ID
type GetSchemaResponse ¶
GetSchemaResponse returns the schema
type ListSubjectsRequest ¶
type ListSubjectsRequest struct {
Prefix string // Optional prefix filter
}
ListSubjectsRequest lists all subjects
type ListSubjectsResponse ¶
ListSubjectsResponse returns list of subjects
type ListVersionsRequest ¶
type ListVersionsRequest struct {
Subject Subject
}
ListVersionsRequest lists all versions for a subject
type ListVersionsResponse ¶
ListVersionsResponse returns list of versions
type RegisterSchemaRequest ¶
type RegisterSchemaRequest struct {
Subject Subject
Format SchemaFormat
Definition string
}
RegisterSchemaRequest registers a new schema
type RegisterSchemaResponse ¶
RegisterSchemaResponse returns the registered schema ID
type RegistryStats ¶
RegistryStats holds registry statistics
type Schema ¶
type Schema struct {
ID SchemaID
Subject Subject
Version Version
Format SchemaFormat
Definition string // The actual schema definition (JSON, Avro, Proto)
CreatedAt time.Time
UpdatedAt time.Time
}
Schema represents a schema definition
type SchemaFormat ¶
type SchemaFormat string
SchemaFormat represents the schema format/type
const ( // FormatJSON represents JSON schema format FormatJSON SchemaFormat = "JSON" // FormatAvro represents Apache Avro schema format FormatAvro SchemaFormat = "AVRO" // FormatProtobuf represents Protocol Buffers schema format FormatProtobuf SchemaFormat = "PROTOBUF" )
type SchemaMetadata ¶
type SchemaMetadata struct {
ID SchemaID
Subject Subject
Version Version
Format SchemaFormat
Fingerprint string // Hash of schema definition
CreatedAt time.Time
}
SchemaMetadata contains metadata about a schema
type SchemaReference ¶
SchemaReference represents a reference to another schema
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry manages schemas and their versions
func NewSchemaRegistry ¶
func NewSchemaRegistry(validator SchemaValidator, logger *logging.Logger) *SchemaRegistry
NewSchemaRegistry creates a new schema registry
func (*SchemaRegistry) DeleteSchema ¶
func (sr *SchemaRegistry) DeleteSchema(req *DeleteSchemaRequest) (*DeleteSchemaResponse, error)
DeleteSchema deletes a specific schema version
func (*SchemaRegistry) DeleteSubject ¶
func (sr *SchemaRegistry) DeleteSubject(req *DeleteSubjectRequest) (*DeleteSubjectResponse, error)
DeleteSubject deletes all versions of a subject
func (*SchemaRegistry) GetCompatibility ¶
func (sr *SchemaRegistry) GetCompatibility(req *GetCompatibilityRequest) (*GetCompatibilityResponse, error)
GetCompatibility retrieves compatibility mode for a subject
func (*SchemaRegistry) GetLatestSchema ¶
func (sr *SchemaRegistry) GetLatestSchema(req *GetLatestSchemaRequest) (*GetLatestSchemaResponse, error)
GetLatestSchema retrieves the latest schema for a subject
func (*SchemaRegistry) GetSchema ¶
func (sr *SchemaRegistry) GetSchema(req *GetSchemaRequest) (*GetSchemaResponse, error)
GetSchema retrieves a schema by ID
func (*SchemaRegistry) GetSchemaBySubjectVersion ¶
func (sr *SchemaRegistry) GetSchemaBySubjectVersion(req *GetSchemaBySubjectVersionRequest) (*GetSchemaBySubjectVersionResponse, error)
GetSchemaBySubjectVersion retrieves a schema by subject and version
func (*SchemaRegistry) ListSubjects ¶
func (sr *SchemaRegistry) ListSubjects(req *ListSubjectsRequest) (*ListSubjectsResponse, error)
ListSubjects lists all subjects
func (*SchemaRegistry) ListVersions ¶
func (sr *SchemaRegistry) ListVersions(req *ListVersionsRequest) (*ListVersionsResponse, error)
ListVersions lists all versions for a subject
func (*SchemaRegistry) RegisterSchema ¶
func (sr *SchemaRegistry) RegisterSchema(req *RegisterSchemaRequest) (*RegisterSchemaResponse, error)
RegisterSchema registers a new schema
func (*SchemaRegistry) SetGlobalCompatibility ¶
func (sr *SchemaRegistry) SetGlobalCompatibility(mode CompatibilityMode) error
SetGlobalCompatibility sets the global compatibility mode
func (*SchemaRegistry) Stats ¶
func (sr *SchemaRegistry) Stats() RegistryStats
Stats returns registry statistics
func (*SchemaRegistry) TestCompatibility ¶
func (sr *SchemaRegistry) TestCompatibility(req *TestCompatibilityRequest) (*TestCompatibilityResponse, error)
TestCompatibility tests if a schema is compatible
func (*SchemaRegistry) UpdateCompatibility ¶
func (sr *SchemaRegistry) UpdateCompatibility(req *UpdateCompatibilityRequest) (*UpdateCompatibilityResponse, error)
UpdateCompatibility updates compatibility mode for a subject
type SchemaValidator ¶
type SchemaValidator interface {
Validate(format SchemaFormat, definition string) error
CheckCompatibility(format SchemaFormat, oldSchema, newSchema string, mode CompatibilityMode) (bool, error)
}
SchemaValidator validates schemas and checks compatibility
type SchemaWithReferences ¶
type SchemaWithReferences struct {
Schema *Schema
References []SchemaReference
}
SchemaWithReferences represents a schema with references to other schemas
type Subject ¶
type Subject string
Subject is a namespace for schemas (typically topic-key or topic-value)
type SubjectVersion ¶
SubjectVersion represents a subject and version pair
type TestCompatibilityRequest ¶
type TestCompatibilityRequest struct {
Subject Subject
Version Version // Test against this version
Format SchemaFormat
Definition string
}
TestCompatibilityRequest tests if a schema is compatible
type TestCompatibilityResponse ¶
type TestCompatibilityResponse struct {
Compatible bool
ErrorCode ErrorCode
Message string // Error/warning message
}
TestCompatibilityResponse returns compatibility result
type UpdateCompatibilityRequest ¶
type UpdateCompatibilityRequest struct {
Subject Subject
Compatibility CompatibilityMode
}
UpdateCompatibilityRequest updates compatibility mode for a subject
type UpdateCompatibilityResponse ¶
type UpdateCompatibilityResponse struct {
ErrorCode ErrorCode
}
UpdateCompatibilityResponse confirms update