confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
60 stars 862 forks source link

Add ArraySegment<byte> as native supported type #2219

Open bdelayen opened 4 months ago

bdelayen commented 4 months ago

Aim is to be able to provide pooled buffers with an adjustable offset and count to the library.

This changes very little of the existing logic and does not break existing API and works on all .NET versions.

The ArraySegment will now be natively supported (like string, long or byte[]) without needing a user provided serializer. It also allows the use of pooled buffers and will help get the maximum performance out of the library.

This is one of the least invasive ways to add support for this feature that I found. (Span<>, Memory<> need recent versions and require changing the buffer pinning code).

cla-assistant[bot] commented 4 months ago

CLA assistant check
All committers have signed the CLA.