dynamic_modules: adds body read/write callbacks#38102
dynamic_modules: adds body read/write callbacks#38102mattklein123 merged 14 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
|
cc @bplotnick |
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Hi, sorry to ask here but I couldn't find any other place where this is being discussed: is it technically possible to expand the feature set of dynamic modules in the future, e.g. with the equivalent of Lua's Thanks! |
|
Hi @isker! Nothing stops us from implementing that functionality and any other things available in other extension mechanism. Especially for the callout stuff it's of course within my radar and stay tuned! It's just the beginning! |
|
Metrics will be soon worked on by me or @bplotnick ;) |
|
That’s very exciting 🌞. Thanks for all your work on this. |
mattklein123
left a comment
There was a problem hiding this comment.
At a high level, it's not clear to me that exposing io::Read/io::Write is the best abstraction for this. Why not just operate on lifetime bound EnvoyBuffers? This will allow no copy when the caller doesn't need to copy, and if they need to copy they can copy themselves?
/wait
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
|
@mattklein123 that's indeed a good question and the answer is like i wish i could use (btw I think maybe we should rename Rust |
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
|
Can you just return a vector of EnvoyBuffer slices with appropriate lifetimes? That seems fine. |
|
yeah that should work as long as the number of slices is not that huge (i assume so). let me rework the pr /wait |
|
ok so for reading, the raw Vec<EnvoyBuffer<'a>> works well, but for writing it's a bit tricky. The underlying buffer::RawSlice is not resizable so without some wrapper on Vec<EnvoyBuffer<'a>> it's not possible to provider the "replace body" functionality, which is my primary use case. However, even if i have the wrapper and allows the access to the raw buffer:Instance functionality, it still lacks the function to "shrink" the buffer in case of the new body is smaller than the original size. (to write the json, the callsite cannot know the size before hand and the serialization often writes a smaller bytes at time calling Write::write). So i will add the inverse version of buffer::Instance::drain |
This comment was marked as outdated.
This comment was marked as outdated.
|
sorry, let me think about it more |
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
|
@mattklein123 it took me a while but finally managed to make it in a simple state by simply using |
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
|
/retest |
|
@mattklein123 PTAL! |
| /// Get the currently buffered request body. The body is represented as a list of [`EnvoyBuffer`]. | ||
| /// Memory contents pointed by each [`EnvoyBuffer`] is mutable and can be modified in place. |
There was a problem hiding this comment.
In looking at this more it seems kind of confusing that EnvoyBuffer supports both mut and not mut access, as I don't think mutability is safe or works correctly in all cases? For example header map stuff? Is it safe in all cases even if there is a mutable borrow on the filter? Do we need to split the EnvoyBuffer into a read only and mutable type?
/wait-any
There was a problem hiding this comment.
Do we need to split the EnvoyBuffer into a read only and mutable type?
yeah agree this is confusing and I was thinking about the exact same thing about having two EnvoyBuffers kinds for mutable and non-mutable version. I think the headers should be returned with immutable version. I will follow up in the separate PR in a bit
There was a problem hiding this comment.
OK sounds good you can fix in a follow up. Personally I I would call this one EnvoyMutBuffer and leave the other one as is.
Commit Message: dynamic_modules: adds body reader/writer functionality Additional Description: This adds the following ABI functions: * envoy_dynamic_module_callback_http_get_request_body_vector_size * envoy_dynamic_module_callback_http_append_request_body * envoy_dynamic_module_callback_http_drain_request_body * envoy_dynamic_module_callback_http_get_response_body_vector * envoy_dynamic_module_callback_http_get_response_body_vector_size * envoy_dynamic_module_callback_http_append_response_body * envoy_dynamic_module_callback_http_drain_response_body which allows the modules to read and write HTTP body buffers, including the ability to replace the entire body with a new one. This completes the initial series of dynamic module feature patches and after this, the documentation and integration tests will be worked on. Risk Level: low Testing: done Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Commit Message: dynamic_modules: add EnvoyMutBuffer in Rust SDK Additional Description: This is a follow up on #38102 (comment) Risk Level: n/a Testing: existing ones Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Commit Message: dynamic_modules: add EnvoyMutBuffer in Rust SDK Additional Description: This is a follow up on envoyproxy/envoy#38102 (comment) Risk Level: n/a Testing: existing ones Docs Changes: n/a Release Notes: n/a Platform Specific Features: n/a --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Commit Message: dynamic_modules: adds body reader/writer functionality
Additional Description:
This adds the following ABI functions:
which allows the modules to read and write HTTP body buffers, including
the ability to replace the entire body with a new one.
This completes the initial series of dynamic module feature patches
and after this, the documentation and integration tests will be worked on.
Risk Level: low
Testing: done
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a