Class ProtobufSerializer<T>
Protobuf Serializer.
Inheritance
Implements
Inherited Members
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, IList<IRuleExecutor>)
Initialize a new instance of the ProtobufSerializer class.
Declaration
public ProtobufSerializer(ISchemaRegistryClient schemaRegistryClient, ProtobufSerializerConfig config = null, IList<IRuleExecutor> ruleExecutors = null)
Parameters
Type | Name | Description |
---|---|---|
ISchemaRegistryClient | schemaRegistryClient | |
ProtobufSerializerConfig | config | |
IList<IRuleExecutor> | ruleExecutors |
Methods
ParseSchema(Schema)
Declaration
protected override Task<FileDescriptorSet> ParseSchema(Schema schema)
Parameters
Type | Name | Description |
---|---|---|
Schema | schema |
Returns
Type | Description |
---|---|
Task<FileDescriptorSet> |
Overrides
SerializeAsync(T, SerializationContext)
Serialize an instance of type T
to a byte array
in Protobuf format. The serialized data is preceeded by:
- A "magic byte" (1 byte) that identifies this as a message with Confluent Platform framing.
- The id of the schema as registered in Confluent's Schema Registry (4 bytes, network byte order).
- 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
|