Table of Contents

Class AvroSharpSerializer<T>

Namespace
AvroSharp.Confluent
Assembly
AvroSharp.Confluent.dll

Writes values in Confluent Schema Registry framing: a type generated by AvroSharp (from .avsc files or [AvroSerializable]), a primitive, or generic values (AvroSharpGeneric). It derives from Confluent's Confluent.SchemaRegistry.AsyncSerializer<T, TParsedSchema>, so subject name strategies, registration, use.latest.version, schema ID strategies, references and rules are Confluent's own code; only the Avro encoding is AvroSharp's. The bytes are those of Confluent's Avro serializer for the same schema and value.

public sealed class AvroSharpSerializer<T> : AsyncSerializer<T, AvroSchema>, IAsyncSerializer<T>, ISerializer<T>

Type Parameters

T

The type written.

Inheritance
AsyncSerde<AvroSchema>
AsyncSerializer<T, AvroSchema>
AvroSharpSerializer<T>
Implements
IAsyncSerializer<T>
ISerializer<T>
Inherited Members
AsyncSerializer<T, AvroSchema>.SerializeAsync(T, SerializationContext)

Remarks

It is both asynchronous and synchronous (Confluent.Kafka.ISerializer<T>), so producer.Produce works too. Confluent.Kafka's producer builder has a SetValueSerializer for each, so pass it as one of them, such as (ISerializer<T>)serializer, or use AvroSharpSerdeExtensions, which set the synchronous one. Once a topic's schema ID is known, the synchronous path writes without a task. It waits for the registry the first time, and on every message with use.latest.version, use.latest.with.metadata or use.schema.id, whose rules can run asynchronously.

Constructors

AvroSharpSerializer(ISchemaRegistryClient, AvroSharpSerializerConfig?, RuleRegistry?)

Creates a serializer of a generated type or a primitive, which AvroTypes knows. Generated types register themselves on .NET 5 and later; on .NET Standard, pass the type's AvroTypeInfo to the other constructor, or register it first.

AvroSharpSerializer(ISchemaRegistryClient, AvroTypeInfo<T>, AvroSharpSerializerConfig?, RuleRegistry?)

Creates a serializer of the type that type reads and writes.

Methods

ParseSchema(Schema)
Serialize(T, SerializationContext)

Writes a value without a task once the topic's schema ID is known; until then, and with settings whose rules can run asynchronously, it waits for SerializeAsync(T, SerializationContext).

SerializeAsync(T, SerializationContext)

Writes a value: its schema ID (registered or looked up once per subject), then its Avro encoding.