Skip to content

Expose a producer method that accepts ReadOnlySpan<byte> #2496

@fabianoliver

Description

@fabianoliver

In high performance scenarios, it's not uncommon to serialize a payload into e.g. a pooled memory buffer.
However, since the size of shared buffers very rarely align with the actual payload size, it's unusually not feasible get get a hold of the serialized segment as a proper array. Instead, the serialized data is then commonly accessible through ReadOnlyMemory/ReadOnlySpan.

At the moment, there looks to be no way to directly produce a kafka message from such a buffer. Best we can do is to create an IProduer<byte[], byte[]>, which then means having to wastefully copy the buffer into a new array.

It would be very ueful if IProducer offered some Produce method that takes in a ReadOnlySpan for such scenarios. Naturally that would then implement sidestepping the producers configured serialisers, and writing raw data straight to librdkafka.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions