Documentation ¶
Index ¶
- type Encoder
- type GenericEncoder
- type Option
- type Registry
- func (r *Registry) GenericEncoder() *GenericEncoder
- func (r *Registry) Print()
- func (r *Registry) Register(subject string, version int, decoder jsonDecoder) error
- func (r *Registry) Sync() error
- func (r *Registry) WithLatestSchema(subject string) *Encoder
- func (r *Registry) WithSchema(subject string, version int) *Encoder
- type Subject
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder holds the reference to Registry and Subject which can be used to encode and decode messages
func NewEncoder ¶
NewEncoder return the pointer to a Encoder for given Subject from the Registry
func NewGenericEncoder ¶
NewEncoder return the pointer to a Encoder for given Subject from the Registry
func (*Encoder) Decode ¶
Decode returns the decoded go interface of avro encoded message and error if its unable to decode
func (*Encoder) Encode ¶
Encode return a byte slice with a avro encoded message. magic byte and schema id will be appended to its beginning
╔════════════════════╤════════════════════╤══════════════════════╗ ║ magic byte(1 byte) │ schema id(4 bytes) │ AVRO encoded message ║ ╚════════════════════╧════════════════════╧══════════════════════╝
type GenericEncoder ¶
type GenericEncoder struct {
// contains filtered or unexported fields
}
Encoder holds the reference to Registry and Subject which can be used to encode and decode messages
func (*GenericEncoder) Decode ¶
func (s *GenericEncoder) Decode(data []byte) (interface{}, error)
Decode returns the decoded go interface of avro encoded message and error if its unable to decode
func (*GenericEncoder) Encode ¶
func (s *GenericEncoder) Encode(data interface{}) ([]byte, error)
func (*GenericEncoder) Schema ¶
func (s *GenericEncoder) Schema() string
Schema return the subject asociated with the Encoder
type Option ¶
type Option func(*options)
Option is a type to host NewRegistry configurations
func WithBackgroundSync ¶
WithBackgroundSync returns a Configurations to create a NewRegistry with kafka dynamic schema sync. function required slice of kafka bootstrapServers and schema storageTopic as inputs
func WithLogger ¶
WithLogger returns a Configurations to create a NewRegistry with given PrefixedLogger
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry type holds schema registry details
func NewRegistry ¶
NewRegistry returns pointer to connected registry with given options or error if it's unable to connect
func (*Registry) GenericEncoder ¶
func (r *Registry) GenericEncoder() *GenericEncoder
func (*Registry) Register ¶
Register registers the given subject, version and JSON value decoder to the Registry
func (*Registry) Sync ¶
Sync function start the background schema sync from kafka topic
Newly Created Schemas will register in background and application does not require any restart
func (*Registry) WithLatestSchema ¶
WithLatestSchema returns the latest event version encoder registered under given subject
type Subject ¶
type Subject struct { Schema string `json:"subject"` // The actual AVRO subject Subject string `json:"subject"` // Subject where the subject is registered for Version int `json:"version"` // Version within this subject Id int `json:"id"` // Registry's unique id JsonDecoder jsonDecoder `json:"json_decoder"` }
Subject holds the Schema information of the registered subject