Class ProtobufSerializerBuilder<T>
EXPERIMENTAL: subject to change or removal.
A builder of ProtobufSerializer<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.
Inheritance
Implements
Inherited Members
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Protobuf.dll
Syntax
public class ProtobufSerializerBuilder<T> : SchemaRegistrySerdeBuilder<ProtobufSerializerBuilder<T>>, IAsyncSerializerBuilder<T> where T : IMessage<T>, new()
Type Parameters
| Name | Description |
|---|---|
| T |
Examples
using var producer = new ProducerBuilder<string, User>(producerConfig)
.SetValueSerializerBuilder(new ProtobufSerializerBuilder<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(ProtobufSerializerConfig)
The serializer configuration (refer to ProtobufSerializerConfig).
Declaration
public ProtobufSerializerBuilder<T> SetSerializerConfig(ProtobufSerializerConfig serializerConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtobufSerializerConfig | serializerConfig |
Returns
| Type | Description |
|---|---|
| ProtobufSerializerBuilder<T> |
SetSerializerInit(Func<ProtobufSerializer<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 ProtobufSerializerBuilder<T> SetSerializerInit(Func<ProtobufSerializer<T>, Task> serializerInit)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<ProtobufSerializer<T>, Task> | serializerInit |
Returns
| Type | Description |
|---|---|
| ProtobufSerializerBuilder<T> |