Class AvroSerializerBuilder<T>
EXPERIMENTAL: subject to change or removal.
A builder of AvroSerializer<T> instances, for use with SetValueSerializerBuilder(IAsyncSerializerBuilder<TValue>) and its key counterpart.
The producer constructs the serializer during its own construction, supplying its configuration and whether the serializer is for the message key or value, and owns the result.
Implements
Inherited Members
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Avro.dll
Syntax
public class AvroSerializerBuilder<T> : SchemaRegistrySerdeBuilder<AvroSerializerBuilder<T>>, IAsyncSerializerBuilder<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Examples
using var producer = new ProducerBuilder<string, User>(producerConfig)
.SetValueSerializerBuilder(new AvroSerializerBuilder<User>()
.SetSchemaRegistryConfig(schemaRegistryConfig))
.Build();
Methods
Build(IEnumerable<KeyValuePair<string, string>>, bool)
Build a serializer.
Declaration
public IAsyncSerializer<T> Build(IEnumerable<KeyValuePair<string, string>> config, bool isKey)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<KeyValuePair<string, string>> | config | The configuration of the producer the serializer will be used by. |
| bool | isKey | Whether the serializer will be used to serialize message keys (true) or message values (false). |
Returns
| Type | Description |
|---|---|
| IAsyncSerializer<T> | The serializer. |
SetSerializerConfig(AvroSerializerConfig)
The serializer configuration (refer to AvroSerializerConfig).
Declaration
public AvroSerializerBuilder<T> SetSerializerConfig(AvroSerializerConfig serializerConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| AvroSerializerConfig | serializerConfig |
Returns
| Type | Description |
|---|---|
| AvroSerializerBuilder<T> |
SetSerializerInit(Func<AvroSerializer<T>, Task>)
EXPERIMENTAL: subject to change or removal.
Setup to run on the serializer once it has been built, for anything
the other setters do not cover. It runs to completion within
Build; if it throws, the serializer's owned resources are
released and the exception propagates.
Do not serialize from it. It runs while the producer is still being constructed, before the serializer 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 serializer up, serialize once the client has been constructed, or supply a serializer constructed directly with KafkaClusterIdConfig configured instead of using the builder.
Declaration
public AvroSerializerBuilder<T> SetSerializerInit(Func<AvroSerializer<T>, Task> serializerInit)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<AvroSerializer<T>, Task> | serializerInit |
Returns
| Type | Description |
|---|---|
| AvroSerializerBuilder<T> |