Documentation ¶
Index ¶
- Constants
- func Expect(actual, expected interface{}) error
- func ResolveReferences(c schemaregistry.Client, schema schemaregistry.SchemaInfo, ...) error
- func TopicNameStrategy(topic string, serdeType Type, schema schemaregistry.SchemaInfo) (string, error)
- type BaseDeserializer
- type BaseSerializer
- func (s *BaseSerializer) ConfigureSerializer(client schemaregistry.Client, serdeType Type, conf *SerializerConfig) error
- func (s *BaseSerializer) GetID(topic string, msg interface{}, info schemaregistry.SchemaInfo) (int, error)
- func (s *BaseSerializer) WriteBytes(id int, msgBytes []byte) ([]byte, error)
- type Deserializer
- type DeserializerConfig
- type FailFunc
- type MessageFactory
- type Serde
- type Serializer
- type SerializerConfig
- type SubjectNameStrategyFunc
- type Type
Constants ¶
const ( // KeySerde denotes a key Serde KeySerde = 1 // ValueSerde denotes a value Serde ValueSerde = 2 )
const ( // EnableValidation enables validation EnableValidation = true // DisableValidation disables validation DisableValidation = false )
Variables ¶
This section is empty.
Functions ¶
func Expect ¶
func Expect(actual, expected interface{}) error
Expect compares the actual and expected values
func ResolveReferences ¶
func ResolveReferences(c schemaregistry.Client, schema schemaregistry.SchemaInfo, deps map[string]string) error
ResolveReferences resolves schema references
func TopicNameStrategy ¶
func TopicNameStrategy(topic string, serdeType Type, schema schemaregistry.SchemaInfo) (string, error)
TopicNameStrategy creates a subject name by appending -[key|value] to the topic name.
Types ¶
type BaseDeserializer ¶
type BaseDeserializer struct { Serde Conf *DeserializerConfig MessageFactory MessageFactory }
BaseDeserializer represents basic deserializer info
func (*BaseDeserializer) ConfigureDeserializer ¶
func (s *BaseDeserializer) ConfigureDeserializer(client schemaregistry.Client, serdeType Type, conf *DeserializerConfig) error
ConfigureDeserializer configures the Deserializer
func (*BaseDeserializer) GetSchema ¶
func (s *BaseDeserializer) GetSchema(topic string, payload []byte) (schemaregistry.SchemaInfo, error)
GetSchema returns a schema for a payload
type BaseSerializer ¶
type BaseSerializer struct { Serde Conf *SerializerConfig }
BaseSerializer represents basic serializer info
func (*BaseSerializer) ConfigureSerializer ¶
func (s *BaseSerializer) ConfigureSerializer(client schemaregistry.Client, serdeType Type, conf *SerializerConfig) error
ConfigureSerializer configures the Serializer
func (*BaseSerializer) GetID ¶
func (s *BaseSerializer) GetID(topic string, msg interface{}, info schemaregistry.SchemaInfo) (int, error)
GetID returns a schema ID for the given schema
func (*BaseSerializer) WriteBytes ¶
func (s *BaseSerializer) WriteBytes(id int, msgBytes []byte) ([]byte, error)
WriteBytes writes the serialized payload prepended by the magicByte
type Deserializer ¶
type Deserializer interface { ConfigureDeserializer(client schemaregistry.Client, serdeType Type, conf *DeserializerConfig) error // Deserialize will call the MessageFactory to create an object // into which we will unmarshal data. Deserialize(topic string, payload []byte) (interface{}, error) // DeserializeInto will unmarshal data into the given object. DeserializeInto(topic string, payload []byte, msg interface{}) error Close() }
Deserializer represents a deserializer
type DeserializerConfig ¶
type DeserializerConfig struct { }
DeserializerConfig is used to pass multiple configuration options to the deserializers.
func NewDeserializerConfig ¶
func NewDeserializerConfig() *DeserializerConfig
NewDeserializerConfig returns a new configuration instance with sane defaults.
type FailFunc ¶
FailFunc is a function to call in case of failure
var MaybeFail FailFunc
MaybeFail represents a fail function
func InitFailFunc ¶
InitFailFunc returns an initial fail function
type MessageFactory ¶
MessageFactory is a factory function, which should return a pointer to an instance into which we will unmarshal wire data. For Avro, the name will be the name of the Avro type if it has one. For JSON Schema, the name will be empty. For Protobuf, the name will be the name of the message type.
type Serde ¶
type Serde struct { Client schemaregistry.Client SerdeType Type SubjectNameStrategy SubjectNameStrategyFunc }
Serde is a common instance for both the serializers and deserializers
type Serializer ¶
type Serializer interface { ConfigureSerializer(client schemaregistry.Client, serdeType Type, conf *SerializerConfig) error // Serialize will serialize the given message, which should be a pointer. // For example, in Protobuf, messages are always a pointer to a struct and never just a struct. Serialize(topic string, msg interface{}) ([]byte, error) Close() }
Serializer represents a serializer
type SerializerConfig ¶
type SerializerConfig struct { // AutoRegisterSchemas determines whether to automatically register schemas during serialization AutoRegisterSchemas bool // UseSchemaID specifies a schema ID to use during serialization UseSchemaID int // UseLatestVersion specifies whether to use the latest schema version during serialization UseLatestVersion bool // NormalizeSchemas determines whether to normalize schemas during serialization NormalizeSchemas bool }
SerializerConfig is used to pass multiple configuration options to the serializers.
func NewSerializerConfig ¶
func NewSerializerConfig() *SerializerConfig
NewSerializerConfig returns a new configuration instance with sane defaults.
type SubjectNameStrategyFunc ¶
type SubjectNameStrategyFunc func(topic string, serdeType Type, schema schemaregistry.SchemaInfo) (string, error)
SubjectNameStrategyFunc determines the subject for the given parameters