-
Notifications
You must be signed in to change notification settings - Fork 5.3k
filter_state: remove checks for read-only #44343
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,6 @@ class FilterState { | |
|
|
||
| struct FilterObject { | ||
| std::shared_ptr<Object> data_; | ||
| StateType state_type_{StateType::ReadOnly}; | ||
| StreamSharingMayImpactPooling stream_sharing_{StreamSharingMayImpactPooling::None}; | ||
| std::string name_; | ||
| }; | ||
|
|
@@ -149,24 +148,28 @@ class FilterState { | |
| /** | ||
| * @param data_name the name of the data being set. | ||
| * @param data an owning pointer to the data to be stored. | ||
| * @param state_type indicates whether the object is mutable or not. | ||
| * @param life_span indicates the life span of the object: bound to the filter chain, a | ||
| * request, or a connection. | ||
| * | ||
| * Note that it is an error to call setData() twice with the same | ||
| * data_name, if the existing object is immutable. Similarly, it is an | ||
| * error to call setData() with same data_name but different state_types | ||
| * (mutable and readOnly, or readOnly and mutable) or different life_span. | ||
| * This is to enforce a single authoritative source for each piece of | ||
| * data stored in FilterState. | ||
| * Note that it is an error to call setData() twice with the same data_name, but different | ||
| * life_span. | ||
| */ | ||
| virtual void | ||
| setData(absl::string_view data_name, std::shared_ptr<Object> data, StateType state_type, | ||
| setData(absl::string_view data_name, std::shared_ptr<Object> data, | ||
| LifeSpan life_span = LifeSpan::FilterChain, | ||
| StreamSharingMayImpactPooling stream_sharing = StreamSharingMayImpactPooling::None) PURE; | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up (mutable/readonly). | ||
| * Deprecated version of setData that takes the no longer used `StateType`. | ||
| */ | ||
| void setData(absl::string_view data_name, std::shared_ptr<Object> data, StateType /*state_type*/, | ||
| LifeSpan life_span = LifeSpan::FilterChain, | ||
| StreamSharingMayImpactPooling stream_sharing = StreamSharingMayImpactPooling::None) { | ||
| return setData(data_name, std::move(data), life_span, stream_sharing); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to note that the wrong state-type (readonly) is invoked here? |
||
| } | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up. | ||
| * @return a typed pointer to the stored data or nullptr if the data does not exist or the data | ||
| * type does not match the expected type. | ||
| */ | ||
|
|
@@ -175,13 +178,13 @@ class FilterState { | |
| } | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up (mutable/readonly). | ||
| * @param data_name the name of the data being looked up. | ||
| * @return a const pointer to the stored data or nullptr if the data does not exist. | ||
| */ | ||
| virtual const Object* getDataReadOnlyGeneric(absl::string_view data_name) const PURE; | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up (mutable/readonly). | ||
| * @param data_name the name of the data being looked up. | ||
| * @return a typed pointer to the stored data or nullptr if the data does not exist or the data | ||
| * type does not match the expected type. | ||
| */ | ||
|
|
@@ -190,13 +193,13 @@ class FilterState { | |
| } | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up (mutable/readonly). | ||
| * @param data_name the name of the data being looked up. | ||
| * @return a pointer to the stored data or nullptr if the data does not exist. | ||
| */ | ||
| virtual Object* getDataMutableGeneric(absl::string_view data_name) PURE; | ||
|
|
||
| /** | ||
| * @param data_name the name of the data being looked up (mutable/readonly). | ||
| * @param data_name the name of the data being looked up. | ||
| * @return a shared pointer to the stored data or nullptr if the data does not exist. | ||
| */ | ||
| virtual std::shared_ptr<Object> getDataSharedMutableGeneric(absl::string_view data_name) PURE; | ||
|
|
||
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.
Not directly related to this PR, but I wonder if this is a similar kind of constraint that should be addressed by supporting life-span "upgrade".