confluent-kafka-dotnet
Show / Hide Table of Contents

Class ProtobufSerializer<T>

Protobuf Serializer.

Inheritance
object
AsyncSerde<FileDescriptorSet>
AsyncSerializer<T, FileDescriptorSet>
ProtobufSerializer<T>
Implements
IAsyncSerializer<T>
Inherited Members
AsyncSerializer<T, FileDescriptorSet>.autoRegisterSchema
AsyncSerializer<T, FileDescriptorSet>.normalizeSchemas
AsyncSerializer<T, FileDescriptorSet>.schemaIdEncoder
AsyncSerializer<T, FileDescriptorSet>.initialBufferSize
AsyncSerializer<T, FileDescriptorSet>.subjectsRegistered
AsyncSerializer<T, FileDescriptorSet>.SerializeAsync(T, SerializationContext)
AsyncSerde<FileDescriptorSet>.schemaRegistryClient
AsyncSerde<FileDescriptorSet>.ruleRegistry
AsyncSerde<FileDescriptorSet>.useSchemaId
AsyncSerde<FileDescriptorSet>.useLatestVersion
AsyncSerde<FileDescriptorSet>.latestCompatibilityStrict
AsyncSerde<FileDescriptorSet>.useLatestWithMetadata
AsyncSerde<FileDescriptorSet>.subjectNameStrategy
AsyncSerde<FileDescriptorSet>.serdeMutex
AsyncSerde<FileDescriptorSet>.GetSubjectName(string, bool, string)
AsyncSerde<FileDescriptorSet>.GetWriterSchema(string, SchemaId, string)
AsyncSerde<FileDescriptorSet>.GetParsedSchema(Schema)
AsyncSerde<FileDescriptorSet>.ResolveReferences(Schema)
AsyncSerde<FileDescriptorSet>.GetMigrations(string, Schema, RegisteredSchema)
AsyncSerde<FileDescriptorSet>.GetReaderSchema(string, Schema)
AsyncSerde<FileDescriptorSet>.ExecuteMigrations(IList<Migration>, bool, string, string, Headers, object)
AsyncSerde<FileDescriptorSet>.ExecuteRules(bool, string, string, Headers, RuleMode, Schema, Schema, object, FieldTransformer)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Confluent.SchemaRegistry.Serdes
Assembly: Confluent.SchemaRegistry.Serdes.Protobuf.dll
Syntax
public class ProtobufSerializer<T> : AsyncSerializer<T, FileDescriptorSet>, IAsyncSerializer<T> where T : IMessage<T>, new()
Type Parameters
Name Description
T
Remarks

Serialization format: byte 0: A magic byte that identifies this as a message with Confluent Platform framing. bytes 1-4: Unique global id of the Protobuf schema that was used for encoding (as registered in Confluent Schema Registry), big endian. following bytes: 1. A size-prefixed array of indices that identify the specific message type in the schema (a given schema can contain many message types and they can be nested). Size and indices are unsigned varints. The common case where the message type is the first message in the schema (i.e. index data would be [1,0]) is encoded as a single 0 byte as an optimization. 2. The protobuf serialized data.

Constructors

ProtobufSerializer(ISchemaRegistryClient, ProtobufSerializerConfig, RuleRegistry)

Initialize a new instance of the ProtobufSerializer class.

Declaration
public ProtobufSerializer(ISchemaRegistryClient schemaRegistryClient, ProtobufSerializerConfig config = null, RuleRegistry ruleRegistry = null)
Parameters
Type Name Description
ISchemaRegistryClient schemaRegistryClient
ProtobufSerializerConfig config
RuleRegistry ruleRegistry

Methods

IgnoreReference(string)

Declaration
protected override bool IgnoreReference(string name)
Parameters
Type Name Description
string name
Returns
Type Description
bool
Overrides
AsyncSerde<FileDescriptorSet>.IgnoreReference(string)

ParseSchema(Schema)

Declaration
protected override Task<FileDescriptorSet> ParseSchema(Schema schema)
Parameters
Type Name Description
Schema schema
Returns
Type Description
Task<FileDescriptorSet>
Overrides
Confluent.SchemaRegistry.AsyncSerde<Google.Protobuf.Reflection.FileDescriptorSet>.ParseSchema(Confluent.SchemaRegistry.Schema)

SerializeAsync(T, SerializationContext)

Serialize an instance of type T to a byte array in Protobuf format. The serialized data is preceeded by:

  1. A "magic byte" (1 byte) that identifies this as a message with Confluent Platform framing.
  2. The id of the schema as registered in Confluent's Schema Registry (4 bytes, network byte order).
  3. An size-prefixed array of indices that identify the specific message type in the schema (a given schema can contain many message types and they can be nested). Size and indices are unsigned varints. The common case where the message type is the first message in the schema (i.e. index data would be [1,0]) is encoded as simply a single 0 byte as an optimization. This call may block or throw on first use for a particular topic during schema registration / verification.
Declaration
public override Task<byte[]> SerializeAsync(T value, SerializationContext context)
Parameters
Type Name Description
T value

The value to serialize.

SerializationContext context

Context relevant to the serialize operation.

Returns
Type Description
Task<byte[]>

A Task that completes with value serialized as a byte array.

Overrides
Confluent.SchemaRegistry.AsyncSerializer<T, Google.Protobuf.Reflection.FileDescriptorSet>.SerializeAsync(T, Confluent.Kafka.SerializationContext)

Implements

IAsyncSerializer<T>
In this article