Class AvroSharpDeserializer<T>
Reads values in Confluent Schema Registry framing as a type generated by AvroSharp, a primitive, or generic values (AvroSharpGeneric). The writer's schema comes from the registry by the message's schema ID (Confluent's client caches it), and the data is resolved to the type's own schema, so data of older and newer versions reads. It derives from Confluent's Confluent.SchemaRegistry.AsyncDeserializer<T, TParsedSchema>.
public sealed class AvroSharpDeserializer<T> : AsyncDeserializer<T, AvroSchema>, IAsyncDeserializer<T>, IDeserializer<T>
Type Parameters
TThe type read.
- Inheritance
-
AsyncSerde<AvroSchema>AsyncDeserializer<T, AvroSchema>AvroSharpDeserializer<T>
- Implements
-
IAsyncDeserializer<T>IDeserializer<T>
- Inherited Members
Remarks
It is both asynchronous and synchronous (Confluent.Kafka.IDeserializer<T>), which Confluent.Kafka's consumer calls.
Once a schema ID's reader is known, the synchronous path reads without a task. It waits for the registry the first
time, and on every message with use.latest.version or use.latest.with.metadata, or whose schema has
rules, which can run asynchronously.
Constructors
- AvroSharpDeserializer(ISchemaRegistryClient, AvroSharpDeserializerConfig?, RuleRegistry?)
Creates a deserializer of a generated type or a primitive, which AvroTypes knows. On .NET Standard, pass the type's
AvroTypeInfoto the other constructor, or register it first.
- AvroSharpDeserializer(ISchemaRegistryClient, AvroTypeInfo<T>, AvroSharpDeserializerConfig?, RuleRegistry?)
Creates a deserializer of the type that
typereads and writes.
- AvroSharpDeserializer(ISchemaRegistryClient, IEnumerable<Type>, AvroSharpDeserializerConfig?, RuleRegistry?)
Creates a deserializer of several record types, for a topic that carries them all: each message is read as the type of its writer's record (by the record's full name, or a type's alias), or, for a top-level union of records, of the branch the message holds.
Properties
- CustomSubjectNameStrategy
Gets or sets how subjects are named, as a function (by default, the one of the configuration's
subject.name.strategy), for names that Confluent.SchemaRegistry.SubjectNameStrategy can't express, such as a schema context (:.context:orders-value) or a team's prefix. It replaces the configuration'ssubject.name.strategy. It is asked when a topic's schema is first read, and on every message whose settings need the subject (use.latest.versionand the others), so it should give the same subject for the same topic and component.
Methods
- Deserialize(ReadOnlySpan<byte>, bool, SerializationContext)
Reads a value without a task once its schema ID's reader is known; until then, and with settings or rules that can run asynchronously, it waits for DeserializeAsync(ReadOnlyMemory<byte>, bool, SerializationContext).
- DeserializeAsync(ReadOnlyMemory<byte>, bool, SerializationContext)
Reads a value: the writer's schema by the message's schema ID, then the data resolved to the type's schema.