Class AvroDeserializerBuilder<T>
EXPERIMENTAL: subject to change or removal.
A builder of AvroDeserializer<T> instances, for use with SetValueDeserializerBuilder(IAsyncDeserializerBuilder<TValue>) and its key counterpart.
The consumer constructs the deserializer during its own construction,
supplying its configuration and whether the deserializer is for the
message key or value, and owns the result. There is no need to adapt the
deserializer with AsSyncOverAsync() - the consumer does so itself.
Inheritance
Implements
Inherited Members
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Avro.dll
Syntax
public class AvroDeserializerBuilder<T> : SchemaRegistrySerdeBuilder<AvroDeserializerBuilder<T>>, IAsyncDeserializerBuilder<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Examples
using var consumer = new ConsumerBuilder<string, User>(consumerConfig)
.SetValueDeserializerBuilder(new AvroDeserializerBuilder<User>()
.SetSchemaRegistryConfig(schemaRegistryConfig))
.Build();
Methods
Build(IEnumerable<KeyValuePair<string, string>>, bool)
Build a deserializer.
Declaration
public IAsyncDeserializer<T> Build(IEnumerable<KeyValuePair<string, string>> config, bool isKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<KeyValuePair<string, string>> | config | The configuration of the consumer the deserializer will be used by. |
| bool | isKey | Whether the deserializer will be used to deserialize message keys (true) or message values (false). |
Returns
| Type | Description |
|---|---|
| IAsyncDeserializer<T> | The deserializer. |
SetDeserializerConfig(AvroDeserializerConfig)
The deserializer configuration (refer to AvroDeserializerConfig).
Declaration
public AvroDeserializerBuilder<T> SetDeserializerConfig(AvroDeserializerConfig deserializerConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| AvroDeserializerConfig | deserializerConfig |
Returns
| Type | Description |
|---|---|
| AvroDeserializerBuilder<T> |
SetDeserializerInit(Func<AvroDeserializer<T>, Task>)
EXPERIMENTAL: subject to change or removal.
Setup to run on the deserializer once it has been built, for anything
the other setters do not cover. It runs to completion within
Build; if it throws, the deserializer's owned resources are
released and the exception propagates.
Do not deserialize from it. It runs while the consumer is still being constructed, before the deserializer has been handed the resolver for the Kafka cluster id, so a subject name strategy that depends on that id - such as AssociatedNameStrategy - would resolve, and cache, the wrong subject. To warm the deserializer up, deserialize once the client has been constructed, or supply a deserializer constructed directly with KafkaClusterIdConfig configured instead of using the builder.
Declaration
public AvroDeserializerBuilder<T> SetDeserializerInit(Func<AvroDeserializer<T>, Task> deserializerInit)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<AvroDeserializer<T>, Task> | deserializerInit |
Returns
| Type | Description |
|---|---|
| AvroDeserializerBuilder<T> |