@qualithm/kafka-client - v0.1.6
    Preparing search index...

    Type Alias AvroCodec

    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.

    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)),
    }
    },
    }
    type AvroCodec = {
        parse: (schemaJson: string) => AvroSchema;
    }
    Index

    Properties

    Properties

    parse: (schemaJson: string) => AvroSchema

    Parse an Avro schema JSON string into an encodable/decodable schema.

    Type Declaration

      • (schemaJson: string): AvroSchema
      • Parameters

        • schemaJson: string

          Avro schema as a JSON string.

        Returns AvroSchema

        Parsed schema with encode/decode methods.