forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 62
Rename the WASM API files from envoy_ -> proxy_. #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // NOLINT(namespace-envoy) | ||
| #include "proxy_wasm_intrinsics.h" | ||
|
|
||
| static std::unordered_map<int32_t, std::unique_ptr<Context>> context_map; | ||
|
|
||
| static Context* ensureContext(uint32_t context_id) { | ||
| auto e = context_map.insert(std::make_pair(context_id, nullptr)); | ||
| if (e.second) | ||
| e.first->second = Context::New(context_id); | ||
| return e.first->second.get(); | ||
| } | ||
|
|
||
| static Context* getContext(uint32_t context_id) { | ||
| auto it = context_map.find(context_id); | ||
| if (it == context_map.end()) | ||
| return nullptr; | ||
| return it->second.get(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onConfigure(uint32_t ptr, uint32_t size) { | ||
| ensureContext(0)->onConfigure(std::make_unique<WasmData>(reinterpret_cast<char*>(ptr), size)); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onStart() { ensureContext(0)->onStart(); } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onCreate(uint32_t context_id) { | ||
| ensureContext(context_id)->onCreate(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterHeadersStatus proxy_onRequestHeaders(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterHeadersStatus::Continue; | ||
| return c->onRequestHeaders(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterDataStatus proxy_onRequestBody(uint32_t context_id, | ||
| uint32_t body_buffer_length, | ||
| uint32_t end_of_stream) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterDataStatus::Continue; | ||
| return c->onRequestBody(static_cast<size_t>(body_buffer_length), end_of_stream != 0); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterTrailersStatus proxy_onRequestTrailers(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterTrailersStatus::Continue; | ||
| return c->onRequestTrailers(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterHeadersStatus proxy_onResponseHeaders(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterHeadersStatus::Continue; | ||
| return c->onResponseHeaders(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterDataStatus proxy_onResponseBody(uint32_t context_id, | ||
| uint32_t body_buffer_length, | ||
| uint32_t end_of_stream) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterDataStatus::Continue; | ||
| return c->onResponseBody(static_cast<size_t>(body_buffer_length), end_of_stream != 0); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE FilterTrailersStatus proxy_onResponseTrailers(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return FilterTrailersStatus::Continue; | ||
| return c->onResponseTrailers(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void | ||
| proxy_onHttpCallResponse(uint32_t context_id, uint32_t token, uint32_t header_pairs_ptr, | ||
| uint32_t header_pairs_size, uint32_t body_ptr, uint32_t body_size, | ||
| uint32_t trailer_pairs_ptr, uint32_t trailer_pairs_size) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return; | ||
| c->onHttpCallResponse( | ||
| token, | ||
| std::make_unique<WasmData>(reinterpret_cast<char*>(header_pairs_ptr), header_pairs_size), | ||
| std::make_unique<WasmData>(reinterpret_cast<char*>(body_ptr), body_size), | ||
| std::make_unique<WasmData>(reinterpret_cast<char*>(trailer_pairs_ptr), trailer_pairs_size)); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onDone(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return; | ||
| c->onDone(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onLog(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return; | ||
| c->onLog(); | ||
| } | ||
|
|
||
| extern "C" EMSCRIPTEN_KEEPALIVE void proxy_onDelete(uint32_t context_id) { | ||
| auto c = getContext(context_id); | ||
| if (!c) | ||
| return; | ||
| c->onDelete(); | ||
| context_map.erase(context_id); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the "NOLINT" used by build system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
./tools/check_format.py will complain if the namespace is missing, but since this is for the API, it is essentially external code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could exclude
api/wasmfrom that check in./tools/check_format.py'scheckNamespace.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍