Class ProtobufDeserializerBuilder<T>
EXPERIMENTAL: subject to change or removal.
A builder of ProtobufDeserializer<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.Protobuf.dll
Syntax
public class ProtobufDeserializerBuilder<T> : SchemaRegistrySerdeBuilder<ProtobufDeserializerBuilder<T>>, IAsyncDeserializerBuilder<T> where T : class, IMessage<T>, new()
Type Parameters
| Name | Description |
|---|---|
| T |
Examples
using var consumer = new ConsumerBuilder<string, User>(consumerConfig)
.SetValueDeserializerBuilder(new ProtobufDeserializerBuilder<User>()
.SetSchemaRegistryConfig(schemaRegistryConfig))
.Build();
Properties
RequiresSchemaRegistryClient
Protobuf messages are deserialized into the generated type, so no schema needs to be looked up and a Schema Registry client is optional.
Declaration
protected override bool RequiresSchemaRegistryClient { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
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(ProtobufDeserializerConfig)
The deserializer configuration (refer to ProtobufDeserializerConfig).
Declaration
public ProtobufDeserializerBuilder<T> SetDeserializerConfig(ProtobufDeserializerConfig deserializerConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| ProtobufDeserializerConfig | deserializerConfig |
Returns
| Type | Description |
|---|---|
| ProtobufDeserializerBuilder<T> |
SetDeserializerInit(Func<ProtobufDeserializer<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 ProtobufDeserializerBuilder<T> SetDeserializerInit(Func<ProtobufDeserializer<T>, Task> deserializerInit)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<ProtobufDeserializer<T>, Task> | deserializerInit |
Returns
| Type | Description |
|---|---|
| ProtobufDeserializerBuilder<T> |