-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
I am building a network filter that has to move the content of an Envoy::Buffer into a proprietary library (calling it X in the rest of this description) while avoiding copies as far as possible. The filter has to convert from an Envoy::Buffer to a X::Buffer and then allow the library to access the content beyond the scope of the current onData() call. The X::Buffer interface is very similar to Envoy::Buffer, with an X::Buffer instance acting as a container for buffer slices. One of the differences is that X::Buffer has methods to transfer ownership of buffer slices, e.g. extractFrontSlice(), popFrontSlice(), pushFrontSlice(). My understanding is that Envoy::Buffer::getRawSlices() provides a read-only view on the slices, and that no mechanism exists to extract slices without copying. In other words I want to avoid using Envoy::Buffer::copyOut() or Envoy::Buffer::linearize(). I could implement a convoluted mechanism where each slice in the Envoy::Buffer::RawSliceVector is wrapped in a new object that keeps a reference and refcount on the source Envoy::Buffer, and then inject those new slice objects into the X::Buffer instance, effectively indirectly “transferring ownership” of the Envoy::Buffer slices. I would much rather prefer implementing the X::Buffer interface as a simple mapping of the Envoy::Buffer interface. I also understand that not all Envoy::Buffer instances are Envoy::Buffer::OwnedImpl instances and that the implementation for the new method(s) would sometimes result in a copy.
I am available to implement the required changes.