Search Results for

    Show / Hide Table of Contents

    Class PowertoolsKafkaSerializerBase

    Base class for Kafka event serializers that provides common functionality for deserializing Kafka event structures in Lambda functions.

    Inheritance
    object
    PowertoolsKafkaSerializerBase
    PowertoolsKafkaProtobufSerializer
    Implements
    ILambdaSerializer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: AWS.Lambda.Powertools.Kafka.Protobuf
    Assembly: AWS.Lambda.Powertools.Kafka.Protobuf.dll
    Syntax
    public abstract class PowertoolsKafkaSerializerBase : ILambdaSerializer
    Examples

    Inherit from this class to implement specific formats like Avro, Protobuf or JSON.

    Constructors

    PowertoolsKafkaSerializerBase()

    Initializes a new instance of the PowertoolsKafkaSerializerBase class with default JSON serialization options.

    Declaration
    protected PowertoolsKafkaSerializerBase()

    PowertoolsKafkaSerializerBase(JsonSerializerOptions)

    Initializes a new instance of the PowertoolsKafkaSerializerBase class with custom JSON serialization options.

    Declaration
    protected PowertoolsKafkaSerializerBase(JsonSerializerOptions jsonOptions)
    Parameters
    Type Name Description
    JsonSerializerOptions jsonOptions

    Custom JSON serializer options to use during deserialization.

    PowertoolsKafkaSerializerBase(JsonSerializerOptions, JsonSerializerContext?)

    Initializes a new instance of the PowertoolsKafkaSerializerBase class with custom JSON serialization options and an optional serializer context.

    Declaration
    protected PowertoolsKafkaSerializerBase(JsonSerializerOptions jsonOptions, JsonSerializerContext? serializerContext)
    Parameters
    Type Name Description
    JsonSerializerOptions jsonOptions

    Custom JSON serializer options to use during deserialization.

    JsonSerializerContext serializerContext

    Optional JSON serializer context for AOT compatibility.

    PowertoolsKafkaSerializerBase(JsonSerializerContext)

    Initializes a new instance of the PowertoolsKafkaSerializerBase class with a JSON serializer context for AOT-compatible serialization/deserialization.

    Declaration
    protected PowertoolsKafkaSerializerBase(JsonSerializerContext serializerContext)
    Parameters
    Type Name Description
    JsonSerializerContext serializerContext

    The JSON serializer context for AOT compatibility.

    Fields

    JsonOptions

    JSON serializer options used for deserialization.

    Declaration
    protected readonly JsonSerializerOptions JsonOptions
    Field Value
    Type Description
    JsonSerializerOptions

    SerializerContext

    JSON serializer context used for AOT-compatible serialization/deserialization.

    Declaration
    protected readonly JsonSerializerContext? SerializerContext
    Field Value
    Type Description
    JsonSerializerContext

    Methods

    DeserializeComplexTypeFormat(byte[], Type, bool, SchemaMetadata?)

    Deserializes complex (non-primitive) types using format-specific implementation. Each derived class must implement this method to handle its specific format.

    Declaration
    protected abstract object? DeserializeComplexTypeFormat(byte[] data, Type targetType, bool isKey, SchemaMetadata? schemaMetadata = null)
    Parameters
    Type Name Description
    byte[] data
    Type targetType
    bool isKey
    SchemaMetadata schemaMetadata
    Returns
    Type Description
    object

    DeserializeFormatSpecific(byte[], Type, bool, SchemaMetadata?)

    Deserializes binary data using format-specific implementation.

    Declaration
    protected virtual object? DeserializeFormatSpecific(byte[] data, Type targetType, bool isKey, SchemaMetadata? schemaMetadata = null)
    Parameters
    Type Name Description
    byte[] data
    Type targetType
    bool isKey
    SchemaMetadata schemaMetadata
    Returns
    Type Description
    object

    DeserializePrimitiveValue(byte[], Type)

    Deserializes a primitive value from bytes based on the specified type.

    Declaration
    protected object? DeserializePrimitiveValue(byte[] bytes, Type valueType)
    Parameters
    Type Name Description
    byte[] bytes
    Type valueType
    Returns
    Type Description
    object

    DeserializeValue(string, Type, SchemaMetadata?)

    Deserializes a base64-encoded value into an object using the appropriate format.

    Declaration
    protected virtual object DeserializeValue(string base64Value, Type valueType, SchemaMetadata? valueSchemaMetadata = null)
    Parameters
    Type Name Description
    string base64Value
    Type valueType
    SchemaMetadata valueSchemaMetadata
    Returns
    Type Description
    object

    Deserialize<T>(Stream)

    Deserializes the Lambda input stream into the specified type. Handles Kafka events with various serialization formats.

    Declaration
    public T Deserialize<T>(Stream requestStream)
    Parameters
    Type Name Description
    Stream requestStream
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    IsPrimitiveOrSimpleType(Type)

    Checks if the specified type is a primitive or simple type.

    Declaration
    protected bool IsPrimitiveOrSimpleType(Type type)
    Parameters
    Type Name Description
    Type type
    Returns
    Type Description
    bool

    Serialize<T>(T, Stream)

    Serializes an object to JSON and writes it to the provided stream.

    Declaration
    public void Serialize<T>(T response, Stream responseStream)
    Parameters
    Type Name Description
    T response
    Stream responseStream
    Type Parameters
    Name Description
    T

    Implements

    Amazon.Lambda.Core.ILambdaSerializer
    In this article
    Back to top Powertools for AWS Lambda (.NET) API Documentation