-
Notifications
You must be signed in to change notification settings - Fork 5.4k
common inline map registry support #27928
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
Closed
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
34ecb8a
common inline map registry: complete initial version
1548f41
minor update
02ac4b3
fix format
4f7817a
fix lifetime problem and add unit test and add more detailed comments
e190a55
fix memory leak
ba3c874
fix format
e10bcd8
update comment and new function
43e3e0e
update comment
1666aea
fix format
e0eb528
fix test
9579aed
address comments
6b4b1a8
remove unnecessary scope id temporarily
024409e
minor update
15a8ed4
refactor and update the filter state example
1335bc1
fix build
af12156
minor update
2073ab6
minor fix after update filter state
a35e4bf
fix test
2b30599
fix test and update method to generate registry id
57e5fd6
Merge branch 'main' of https://github.com/envoyproxy/envoy into dev-s…
517cc93
address all comments
deb32ab
update comment
986b310
update comment
37053b4
minor update
253e444
minor update
44d4865
addre latest comment
acebae1
minor update
356135f
complete renaming and some new tests
f0fe221
Merge branch 'main' of https://github.com/envoyproxy/envoy into dev-s…
cae8989
refactor an refactor
4410897
fix build
fce7ccd
fix method name after merge main
27f3195
fix build
fff5b1b
fix test
f895088
fix build
1a476d2
address most comments
9c95b23
update comments
e64a87b
Merge branch 'main' of https://github.com/envoyproxy/envoy into dev-s…
e8b04b1
a dirty commit that shouldn't merge
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 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
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
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,51 @@ | ||
| #include "source/common/common/inline_map_registry.h" | ||
|
|
||
| namespace Envoy { | ||
|
|
||
| InlineMapRegistry::Descriptor* InlineMapRegistry::createDescriptor(absl::string_view scope_name) { | ||
| // This should never be triggered because the developer should ensure all used/managed | ||
| // descriptors are registered before main() function by static variable initialization. | ||
| RELEASE_ASSERT(!finalized_, "Registry is finalized, cannot create new descriptor"); | ||
|
|
||
| // Create the descriptor and insert it into the registry. | ||
| auto descriptor = new Descriptor(); | ||
| auto [_, inserted] = descriptors_.emplace(scope_name, descriptor); | ||
|
|
||
| // Check whether the descriptor is created repeatedly. | ||
| RELEASE_ASSERT(inserted, fmt::format("Create descriptor {} repeatedly", scope_name)); | ||
|
|
||
| return descriptor; | ||
| } | ||
|
|
||
| const InlineMapRegistry::Descriptors& InlineMapRegistry::descriptors() const { | ||
| RELEASE_ASSERT(finalized_, "Registry is not finalized, cannot get registry"); | ||
| return descriptors_; | ||
| } | ||
|
|
||
| void InlineMapRegistry::finalize(const ScopeInlineKeysVector& scope_inline_keys_vector) { | ||
| // Call once to finalize the registry and all managed descriptors. This is used to ensure | ||
| // the registry is finalized only once on multi-thread environment. | ||
| std::call_once(once_flag_, [this, &scope_inline_keys_vector]() { | ||
| finalized_ = true; | ||
|
|
||
| // Add inline keys to the descriptor based on the scope name. This is last chance to add | ||
| // inline keys to the descriptor. | ||
| for (const auto& inline_keys : scope_inline_keys_vector) { | ||
| auto iter = descriptors_.find(inline_keys.name); | ||
| if (iter == descriptors_.end()) { | ||
| // Skip the scope that is not registered. | ||
| ENVOY_LOG_MISC(warn, "Skip the scope {} that is not registered", inline_keys.name); | ||
| continue; | ||
| } | ||
|
|
||
| for (const auto& key : inline_keys.keys) { | ||
| iter->second->addInlineKey(key); | ||
| } | ||
| } | ||
|
|
||
| // Finalize all managed descriptors. | ||
| std::for_each(descriptors_.begin(), descriptors_.end(), [](auto& p) { p.second->finalize(); }); | ||
| }); | ||
| } | ||
|
|
||
| } // namespace Envoy |
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.
Uh oh!
There was an error while loading. Please reload this page.