Pluggable Avro codec interface.
Wraps an Avro library (e.g. avsc) to provide schema parsing. The codec is responsible for parsing the schema JSON string and returning an AvroSchema with encode/decode methods.
avsc
import avro from "avsc"const codec: AvroCodec = { parse(schemaJson: string) { const type = avro.Type.forSchema(JSON.parse(schemaJson)) return { encode: (value) => new Uint8Array(type.toBuffer(value)), decode: (data) => type.fromBuffer(Buffer.from(data)), } },} Copy
import avro from "avsc"const codec: AvroCodec = { parse(schemaJson: string) { const type = avro.Type.forSchema(JSON.parse(schemaJson)) return { encode: (value) => new Uint8Array(type.toBuffer(value)), decode: (data) => type.fromBuffer(Buffer.from(data)), } },}
Readonly
Parse an Avro schema JSON string into an encodable/decodable schema.
Avro schema as a JSON string.
Parsed schema with encode/decode methods.
Pluggable Avro codec interface.
Wraps an Avro library (e.g.
avsc) to provide schema parsing. The codec is responsible for parsing the schema JSON string and returning an AvroSchema with encode/decode methods.Example