Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithMaxByteSliceSize ¶ added in v0.3.6
func WithMaxByteSliceSize(maxSize int) option
WithMaxByteSliceSize is the maximum size of `bytes` or `string` types the Reader will create, defaulting to 10MiB. If this size is exceeded, the Reader returns an error. This can be disabled by setting a negative number.
Types ¶
type Decoder ¶
type Decoder interface { // Decode decodes @data, in the wire format, into @output. Decode(ctx context.Context, data []byte, output interface{}) error }
Decoder is able to transform avro's wire format data into golang's concrete types
func NewDecoder ¶
func NewDecoder(schemaRepository schemaregistry.Repository, options ...option) Decoder
NewDecoder returns a concrete implementation of Decoder, that fetches schemas in schema registry
type Encoder ¶
type Encoder interface { // Encode encodes @input in the wire format Encode(input interface{}) ([]byte, error) }
Encoder is able to transform golang's concrete types into avro's wire format
func NewEncoder ¶
func NewEncoder( ctx context.Context, schemaRepository schemaregistry.Repository, subject schemaregistry.Subject, writerSchemaStr string, options ...option, ) (Encoder, error)
NewEncoder returns a concrete implementation of Decoder, that fetches schemas in schema registry Parameters:
- @schemaRepository: repository for avro schemas.
- @writerSchemaStr: avro schema, in the AVSC format, used to marshall the objects. This schema must be previously registered in the schema registry exactly as provided.
type MockDecoder ¶
MockDecoder is a special implementation of Decoder, useful for unit testing
func (*MockDecoder) AddBinding ¶
func (i *MockDecoder) AddBinding(data []byte, output interface{}, err error) *mock.Call
AddBinding mocks the decoding result of @data to the @output struct
func (*MockDecoder) AddJSONBinding ¶
AddJSONBinding mocks the decoding of @data with the JSON-encoded data in @output. Use this function when the output structure is hard to define in unit tests, ex: anonymous structs with lots of pointers.
type WireFormatEncoder ¶
WireFormatEncoder uses the Schema ID provided in the constructor to encodes Avro Messages of the same type into its Wire Format form. The `WireFormatEncoder` is used undercover by `Encoder` to deal with the Wire Format transformation step.
func NewWireFormatEncoder ¶
func NewWireFormatEncoder( ctx context.Context, schemaRepository schemaregistry.Repository, subject schemaregistry.Subject, writerSchemaStr string, ) (WireFormatEncoder, error)
NewWireFormatEncoder returns a concrete implementation of WireFormatEncoder, that fetches schemas in schema registry Parameters:
- @schemaRepository: repository for avro schemas.
- @writerSchemaStr: avro schema, in the avsc format, used to marshall the objects. This schema must be previously registered in the schema registry exactly as provided.