Skip to main content

AWS Glue Schema Registry serializers/deserializers for .NET (Avro/JSON/Protobuf).

Total Downloads
12.6K
12,586
Published
Jan 1, 1900
128y ago

Get Started

dotnet add package AWS.Glue.SchemaRegistry --version 1.0.1-linux-x64-beta
ProductVersions
.NET
net8.0

README

AWS Glue Schema Registry Serializers / De-serializers for C#

This package provides the Glue Schema Registry (GSR) serializers / de-serializers for Avro, JSON and Protobuf data formats.

Development

The C# serializers / de-serializers (SerDes) are built as bindings over existing C library of GSR SerDes. The C library is a facade over GraalVM compiled Java SerDes.

Building

Building the C / Java code

Follow the instructions in those specific projects to build them.

Building C# code
dotnet clean .
# For Debug configuration
dotnet build .
# For Release configuration
dotnet build . --configuration Release
Releasing as a nupkg

After the build steps are successful, do the following:

dotnet pack -c Release --no-build

This outputs: ./bin/Release/AWSGsrSerDe.1.0.0.nupkg

Running C# tests
# Set AWS environment credentials and verify that the 'test-registry' exists in AWS Glue.

# Run the test suite
dotnet test .

# Run the test suite with coverage

dotnet tool install --global dotnet-coverage
apt-get update && apt-get install libxml2
dotnet-coverage collect dotnet test -f xml -o coverage.xml

# for html report
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:**/coverage.xml -targetdir:coverage-report -reporttypes:Html

Using Csharp Glue Schema client library with KafkaFlow for SerDes

Sample serializer usage:

services.AddKafka(kafka => kafka
    .UseConsoleLog()
    .AddCluster(cluster => cluster
        .WithBrokers(new[] { "localhost:9092" })
        .AddProducer<CustomerProducer>(producer => producer
            .DefaultTopic("customer-events")
            .AddMiddlewares(m => m
                .AddSerializer<GlueSchemaRegistryKafkaFlowProtobufSerializer<Customer>>(
                    () => new GlueSchemaRegistryKafkaFlowProtobufSerializer<Customer>("config/gsr-config.properties")
                )
            )
        )
    )
);

Sample deserializer usage:

.AddConsumer(consumer => consumer
    .Topic("customer-events")
    .WithGroupId("customer-group")
    .WithBufferSize(100)
    .WithWorkersCount(10)
    .AddMiddlewares(middlewares => middlewares
        .AddDeserializer<GlueSchemaRegistryKafkaFlowProtobufDeserializer<Customer>>(
            () => new GlueSchemaRegistryKafkaFlowProtobufDeserializer<Customer>("config/gsr-config.properties")
        )
        .AddTypedHandlers(h => h.AddHandler<CustomerHandler>())
    )
)

Using Csharp Glue Schema client library for Kafka SerDes

Sample serializer usage:

private static readonly string PROTOBUF_CONFIG_PATH = "<PATH_TO_CONFIG_FILE>";
var protobufSerializer = new GlueSchemaRegistryKafkaSerializer(PROTOBUF_CONFIG_PATH);
var serialized = protobufSerializer.Serialize(message, message.Descriptor.FullName);
// send serialized bytes to Kafka using producer.Produce(serialized)

Sample deserializer usage:

private static readonly string PROTOBUF_CONFIG_PATH = "<PATH_TO_CONFIG_FILE>";
var dataConfig = new GlueSchemaRegistryDataFormatConfiguration(
    new Dictionary<string, dynamic>
    {
        { 
            GlueSchemaRegistryConstants.ProtobufMessageDescriptor, message.Descriptor 
        }
    }
);
var protobufDeserializer = new GlueSchemaRegistryKafkaDeserializer(PROTOBUF_CONFIG_PATH, dataConfig);

// read message from Kafka using serialized = consumer.Consume()
var deserializedObject = protobufDeserializer.Deserialize(message.Descriptor.FullName, serialized);

Downloads by Version

Similar & Alternative Packages

Hand-picked matching NuGet libraries based on tags & ecosystem

Depended On By

Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.This version is unlisted. Prefer a listed release unless you deliberately need this exact version for reproducibility.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.