Method SerializeAsync
SerializeAsync<T>(T, string, CancellationToken)
Writes a value.
public ValueTask<byte[]> SerializeAsync<T>(T value, string transportName, CancellationToken cancellationToken = default)
Parameters
valueTThe value.
transportNamestringThe Kafka topic or Kinesis stream, which names the schema unless SchemaName does.
cancellationTokenCancellationTokenCancels the registry calls, if any are needed.
Returns
Type Parameters
TThe value's type: a type AvroTypes knows, GenericRecord or AvroValue.
Exceptions
- InvalidOperationException
The value isn't of a type the serializer can write, or the registry has no version of its schema and auto-registration is off, or a new version didn't become available.
SerializeAsync<T>(T, string, bool, CancellationToken)
Writes a key or a value.
public ValueTask<byte[]> SerializeAsync<T>(T value, string transportName, bool isKey, CancellationToken cancellationToken = default)
Parameters
valueTThe key or the value.
transportNamestringThe Kafka topic or Kinesis stream, which names the schema unless SchemaName does.
isKeyboolWhether it's a message key, which SchemaNameStrategy can name apart from values.
cancellationTokenCancellationTokenCancels the registry calls, if any are needed.
Returns
Type Parameters
TThe value's type: a type AvroTypes knows, GenericRecord or AvroValue.
Exceptions
- InvalidOperationException
The value isn't of a type the serializer can write, or the registry has no version of its schema and auto-registration is off, or a new version didn't become available.